From 6d8b1374c50c568fc710f34bccdd73544d539f4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Fri, 4 Aug 2023 15:27:27 +0200 Subject: [PATCH] Use AnalysisFramework's error formatting and filtering features in more test cases --- test/libsolidity/AnalysisFramework.cpp | 2 +- test/libsolidity/GasTest.cpp | 3 +-- test/libsolidity/MemoryGuardTest.cpp | 3 +++ test/libsolidity/SolidityCompiler.cpp | 5 ++++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/test/libsolidity/AnalysisFramework.cpp b/test/libsolidity/AnalysisFramework.cpp index cbcedfba6..47643deea 100644 --- a/test/libsolidity/AnalysisFramework.cpp +++ b/test/libsolidity/AnalysisFramework.cpp @@ -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)); } diff --git a/test/libsolidity/GasTest.cpp b/test/libsolidity/GasTest.cpp index 030472e8a..78a0ca907 100644 --- a/test/libsolidity/GasTest.cpp +++ b/test/libsolidity/GasTest.cpp @@ -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; } diff --git a/test/libsolidity/MemoryGuardTest.cpp b/test/libsolidity/MemoryGuardTest.cpp index b757e673f..06d6723f0 100644 --- a/test/libsolidity/MemoryGuardTest.cpp +++ b/test/libsolidity/MemoryGuardTest.cpp @@ -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()) diff --git a/test/libsolidity/SolidityCompiler.cpp b/test/libsolidity/SolidityCompiler.cpp index cd99cbf53..71c19e596 100644 --- a/test/libsolidity/SolidityCompiler.cpp +++ b/test/libsolidity/SolidityCompiler.cpp @@ -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);