AnalysisFramework: Move common setup to the framework

This commit is contained in:
Kamil Śliwak 2023-08-07 12:26:44 +02:00
parent d2bfb2f737
commit 3fb2f1db88
4 changed files with 14 additions and 0 deletions

View File

@ -86,7 +86,12 @@ std::unique_ptr<CompilerStack> 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()

View File

@ -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)

View File

@ -38,6 +38,8 @@ using namespace yul;
void MemoryGuardTest::setupCompiler(CompilerStack& _compiler)
{
AnalysisFramework::setupCompiler(_compiler);
_compiler.setViaIR(true);
_compiler.setOptimiserSettings(OptimiserSettings::none());
}

View File

@ -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);