From 3fb2f1db8876a6890139f450db0b8661dcf10c91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Mon, 7 Aug 2023 12:26:44 +0200 Subject: [PATCH] AnalysisFramework: Move common setup to the framework --- test/libsolidity/AnalysisFramework.cpp | 5 +++++ test/libsolidity/GasTest.cpp | 5 +++++ test/libsolidity/MemoryGuardTest.cpp | 2 ++ test/libsolidity/SolidityCompiler.cpp | 2 ++ 4 files changed, 14 insertions(+) diff --git a/test/libsolidity/AnalysisFramework.cpp b/test/libsolidity/AnalysisFramework.cpp index 6f9e53e2c..dc52ffc1c 100644 --- a/test/libsolidity/AnalysisFramework.cpp +++ b/test/libsolidity/AnalysisFramework.cpp @@ -86,7 +86,12 @@ std::unique_ptr AnalysisFramework::createStack() const void AnalysisFramework::setupCompiler(CompilerStack& _compiler) { + // These are just defaults based on the (global) CLI options. + // Technically, every TestCase should override these with values passed to it in TestCase::Config. + // In practice TestCase::Config always matches global config so most test cases don't care. _compiler.setEVMVersion(solidity::test::CommonOptions::get().evmVersion()); + _compiler.setEOFVersion(solidity::test::CommonOptions::get().eofVersion()); + _compiler.setOptimiserSettings(solidity::test::CommonOptions::get().optimize); } void AnalysisFramework::executeCompilationPipeline() diff --git a/test/libsolidity/GasTest.cpp b/test/libsolidity/GasTest.cpp index 87f67dcff..5d8a69497 100644 --- a/test/libsolidity/GasTest.cpp +++ b/test/libsolidity/GasTest.cpp @@ -99,6 +99,7 @@ void GasTest::printUpdatedExpectations(std::ostream& _stream, std::string const& void GasTest::setupCompiler(CompilerStack& _compiler) { + AnalysisFramework::setupCompiler(_compiler); // Prerelease CBOR metadata varies in size due to changing version numbers and build dates. // This leads to volatile creation cost estimates. Therefore we force the compiler to @@ -112,6 +113,10 @@ void GasTest::setupCompiler(CompilerStack& _compiler) } settings.expectedExecutionsPerDeployment = m_optimiseRuns; _compiler.setOptimiserSettings(settings); + + // Intentionally ignoring EVM version specified on the command line. + // Gas expectations are only valid for the default version. + _compiler.setEVMVersion(EVMVersion{}); } TestCase::TestResult GasTest::run(std::ostream& _stream, std::string const& _linePrefix, bool _formatted) diff --git a/test/libsolidity/MemoryGuardTest.cpp b/test/libsolidity/MemoryGuardTest.cpp index d2e5d3d09..2d8cc564b 100644 --- a/test/libsolidity/MemoryGuardTest.cpp +++ b/test/libsolidity/MemoryGuardTest.cpp @@ -38,6 +38,8 @@ using namespace yul; void MemoryGuardTest::setupCompiler(CompilerStack& _compiler) { + AnalysisFramework::setupCompiler(_compiler); + _compiler.setViaIR(true); _compiler.setOptimiserSettings(OptimiserSettings::none()); } diff --git a/test/libsolidity/SolidityCompiler.cpp b/test/libsolidity/SolidityCompiler.cpp index 1d4f6851a..7cb95a99d 100644 --- a/test/libsolidity/SolidityCompiler.cpp +++ b/test/libsolidity/SolidityCompiler.cpp @@ -32,6 +32,8 @@ class SolidityCompilerFixture: protected AnalysisFramework { void setupCompiler(CompilerStack& _compiler) override { + AnalysisFramework::setupCompiler(_compiler); + // FIXME: This test was probably supposed to respect CommonOptions::get().optimize but // due to a bug it was always running with optimizer disabled and it does not pass with it. _compiler.setOptimiserSettings(false);