Put stripPreReleaseWarning() next to withPreamble()

This commit is contained in:
Kamil Śliwak 2023-08-11 14:54:22 +02:00
parent ec92685bcb
commit 2baf9d4d82
4 changed files with 19 additions and 16 deletions

View File

@ -18,6 +18,8 @@
#include <test/libsolidity/util/Common.h>
#include <regex>
using namespace std;
using namespace solidity;
using namespace solidity::frontend;
@ -49,3 +51,17 @@ StringMap test::withPreamble(StringMap _sources, bool _addAbicoderV1Pragma)
return _sources;
}
string test::stripPreReleaseWarning(string const& _stderrContent)
{
static regex const preReleaseWarningRegex{
R"(Warning( \(3805\))?: This is a pre-release compiler version, please do not use it in production\.\n)"
R"((\n)?)"
};
static regex const noOutputRegex{
R"(Compiler run successful, no output requested\.\n)"
};
string output = regex_replace(_stderrContent, preReleaseWarningRegex, "");
return regex_replace(std::move(output), noOutputRegex, "");
}

View File

@ -32,4 +32,6 @@ std::string withPreamble(std::string const& _sourceCode, bool _addAbicoderV1Prag
/// @returns a copy of @p _sources with preamble prepended to all sources.
StringMap withPreamble(StringMap _sources, bool _addAbicoderV1Pragma = false);
std::string stripPreReleaseWarning(std::string const& _stderrContent);
} // namespace solidity::frontend::test

View File

@ -17,6 +17,7 @@
// SPDX-License-Identifier: GPL-3.0
#include <test/solc/Common.h>
#include <test/libsolidity/util/Common.h>
#include <solc/CommandLineInterface.h>
@ -79,17 +80,3 @@ test::OptionsReaderAndMessages test::runCLI(
stripPreReleaseWarning(serr.str()),
};
}
string test::stripPreReleaseWarning(string const& _stderrContent)
{
static regex const preReleaseWarningRegex{
R"(Warning( \(3805\))?: This is a pre-release compiler version, please do not use it in production\.\n)"
R"((\n)?)"
};
static regex const noOutputRegex{
R"(Compiler run successful, no output requested\.\n)"
};
string output = regex_replace(_stderrContent, preReleaseWarningRegex, "");
return regex_replace(std::move(output), noOutputRegex, "");
}

View File

@ -67,6 +67,4 @@ OptionsReaderAndMessages runCLI(
std::string const& _standardInputContent = ""
);
std::string stripPreReleaseWarning(std::string const& _stderrContent);
} // namespace solidity::frontend::test