Use AnalysisFramework's error formatting and filtering features in more test cases

This commit is contained in:
Kamil Śliwak 2023-08-04 15:27:27 +02:00
parent e42242cd6f
commit 6d8b1374c5
4 changed files with 9 additions and 4 deletions

View File

@ -70,7 +70,7 @@ AnalysisFramework::parseAnalyseAndReturnError(
ErrorList errors = filteredErrors(_reportWarnings);
if (errors.size() > 1 && !_allowMultipleErrors)
BOOST_FAIL("Multiple errors found: " + formatErrors(compiler().errors()));
BOOST_FAIL("Multiple errors found: " + formatErrors(errors));
return make_pair(&compiler().ast(""), std::move(errors));
}

View File

@ -118,8 +118,7 @@ TestCase::TestResult GasTest::run(ostream& _stream, string const& _linePrefix, b
if (!compiler().parseAndAnalyze() || !compiler().compile())
{
SourceReferenceFormatter{_stream, compiler(), _formatted, false}
.printErrorInformation(compiler().errors());
_stream << formatErrors(filteredErrors(), _formatted);
return TestResult::FatalError;
}

View File

@ -44,7 +44,10 @@ TestCase::TestResult MemoryGuardTest::run(ostream& _stream, string const& _lineP
compiler().setViaIR(true);
compiler().setOptimiserSettings(OptimiserSettings::none());
if (!compiler().compile())
{
_stream << formatErrors(filteredErrors(), _formatted);
return TestResult::FatalError;
}
m_obtainedResult.clear();
for (string contractName: compiler().contractNames())

View File

@ -42,7 +42,10 @@ BOOST_AUTO_TEST_CASE(does_not_include_creation_time_only_internal_functions)
)";
compiler().setOptimiserSettings(solidity::test::CommonOptions::get().optimize);
BOOST_REQUIRE(success(sourceCode));
BOOST_REQUIRE_MESSAGE(compiler().compile(), "Compiling contract failed");
BOOST_REQUIRE_MESSAGE(
compiler().compile(),
"Contract compilation failed:\n" + formatErrors(filteredErrors(), true /* _colored */)
);
bytes const& creationBytecode = solidity::test::bytecodeSansMetadata(compiler().object("C").bytecode);
bytes const& runtimeBytecode = solidity::test::bytecodeSansMetadata(compiler().runtimeObject("C").bytecode);
BOOST_CHECK(creationBytecode.size() >= 90);