Put stripPreReleaseWarning() next to withPreamble()

This commit is contained in:
Kamil Śliwak
2023-08-17 17:39:27 +02:00
parent ec92685bcb
commit 2baf9d4d82
4 changed files with 19 additions and 16 deletions
+16
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, "");
}
+2
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
+1 -14
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, "");
}
-2
View File
@@ -67,6 +67,4 @@ OptionsReaderAndMessages runCLI(
std::string const& _standardInputContent = ""
);
std::string stripPreReleaseWarning(std::string const& _stderrContent);
} // namespace solidity::frontend::test