diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a6b753087..ce1c12739 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -9,8 +9,6 @@ set(sources InteractiveTests.h Metadata.cpp Metadata.h - Options.cpp - Options.h TestCase.cpp TestCase.h ) diff --git a/test/Common.cpp b/test/Common.cpp index a88871669..709840bbc 100644 --- a/test/Common.cpp +++ b/test/Common.cpp @@ -15,6 +15,7 @@ along with solidity. If not, see . */ +#include #include #include @@ -91,7 +92,11 @@ CommonOptions::CommonOptions(std::string _caption): ("evm-version", po::value(&evmVersionString), "which evm version to use") ("testpath", po::value(&this->testPath)->default_value(solidity::test::testPath()), "path to test files") ("evmonepath", po::value(&evmonePath)->default_value(EVMOneEnvOrDefaultPath()), "path to evmone library") - ("no-smt", po::bool_switch(&disableSMT), "disable SMT checker"); + ("no-smt", po::bool_switch(&disableSMT), "disable SMT checker") + ("optimize", po::bool_switch(&optimize), "enables optimization") + ("optimize-yul", po::bool_switch(&optimizeYul), "enables Yul optimization") + ("abiencoderv2", po::bool_switch(&useABIEncoderV2), "enables abi encoder v2") + ("show-messages", po::bool_switch(&showMessages), "enables message output"); } void CommonOptions::validate() const @@ -151,4 +156,20 @@ langutil::EVMVersion CommonOptions::evmVersion() const return langutil::EVMVersion(); } + +CommonOptions const& CommonOptions::get() +{ + if (!m_singleton) + throw std::runtime_error("Options not yet constructed!"); + + return *m_singleton; +} + +void CommonOptions::setSingleton(std::unique_ptr&& _instance) +{ + m_singleton = std::move(_instance); +} + +std::unique_ptr CommonOptions::m_singleton = nullptr; + } diff --git a/test/Common.h b/test/Common.h index 88b75507a..63437da13 100644 --- a/test/Common.h +++ b/test/Common.h @@ -21,8 +21,8 @@ #include #include -#include #include +#include namespace solidity::test { @@ -48,6 +48,8 @@ struct CommonOptions: boost::noncopyable bool optimize = false; bool optimizeYul = false; bool disableSMT = false; + bool useABIEncoderV2 = false; + bool showMessages = false; langutil::EVMVersion evmVersion() const; @@ -55,13 +57,18 @@ struct CommonOptions: boost::noncopyable // Throws a ConfigException on error virtual void validate() const; -protected: + static CommonOptions const& get(); + static void setSingleton(std::unique_ptr&& _instance); + CommonOptions(std::string caption = ""); + virtual ~CommonOptions() {}; +protected: boost::program_options::options_description options; private: std::string evmVersionString; + static std::unique_ptr m_singleton; }; } diff --git a/test/ExecutionFramework.cpp b/test/ExecutionFramework.cpp index 51d73284b..cc54e7a7b 100644 --- a/test/ExecutionFramework.cpp +++ b/test/ExecutionFramework.cpp @@ -39,19 +39,19 @@ using namespace solidity::util; using namespace solidity::test; ExecutionFramework::ExecutionFramework(): - ExecutionFramework(solidity::test::Options::get().evmVersion()) + ExecutionFramework(solidity::test::CommonOptions::get().evmVersion()) { } ExecutionFramework::ExecutionFramework(langutil::EVMVersion _evmVersion): m_evmVersion(_evmVersion), m_optimiserSettings(solidity::frontend::OptimiserSettings::minimal()), - m_showMessages(solidity::test::Options::get().showMessages), + m_showMessages(solidity::test::CommonOptions::get().showMessages), m_evmHost(make_shared(m_evmVersion)) { - if (solidity::test::Options::get().optimizeYul) + if (solidity::test::CommonOptions::get().optimizeYul) m_optimiserSettings = solidity::frontend::OptimiserSettings::full(); - else if (solidity::test::Options::get().optimize) + else if (solidity::test::CommonOptions::get().optimize) m_optimiserSettings = solidity::frontend::OptimiserSettings::standard(); m_evmHost->reset(); diff --git a/test/ExecutionFramework.h b/test/ExecutionFramework.h index 7cf1de82f..40e12da94 100644 --- a/test/ExecutionFramework.h +++ b/test/ExecutionFramework.h @@ -22,7 +22,7 @@ #pragma once -#include +#include #include #include diff --git a/test/Options.cpp b/test/Options.cpp deleted file mode 100644 index cb5db64b6..000000000 --- a/test/Options.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - This file is part of solidity. - - solidity is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - solidity is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with solidity. If not, see . -*/ -/** @file TestHelper.h -* @author Marko Simovic -* @date 2014 -*/ - -#include - -#include - -#include -#include - -#include -#include -#include -#include - -using namespace std; -using namespace solidity::test; -namespace fs = boost::filesystem; -namespace po = boost::program_options; - - -Options const& Options::get() -{ - static Options instance; - return instance; -} - - -Options::Options() -{ - auto const& suite = boost::unit_test::framework::master_test_suite(); - - if (suite.argc == 0) - return; - - options.add_options() - ("optimize", po::bool_switch(&optimize), "enables optimization") - ("optimize-yul", po::bool_switch(&optimizeYul), "enables Yul optimization") - ("abiencoderv2", po::bool_switch(&useABIEncoderV2), "enables abi encoder v2") - ("show-messages", po::bool_switch(&showMessages), "enables message output"); - - parse(suite.argc, suite.argv); -} diff --git a/test/Options.h b/test/Options.h deleted file mode 100644 index 13f55e018..000000000 --- a/test/Options.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - This file is part of solidity. - - solidity is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - solidity is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with solidity. If not, see . -*/ - -#pragma once - -#include - - -#include - -namespace solidity::test -{ - -struct Options: CommonOptions -{ - bool showMessages = false; - bool useABIEncoderV2 = false; - - static Options const& get(); - -private: - Options(); -}; - -} diff --git a/test/boostTest.cpp b/test/boostTest.cpp index 47b700381..2b5606546 100644 --- a/test/boostTest.cpp +++ b/test/boostTest.cpp @@ -36,7 +36,7 @@ #pragma GCC diagnostic pop #include -#include +#include #include #include @@ -69,7 +69,7 @@ int registerTests( { int numTestsAdded = 0; fs::path fullpath = _basepath / _path; - TestCase::Config config{fullpath.string(), solidity::test::Options::get().evmVersion()}; + TestCase::Config config{fullpath.string(), solidity::test::CommonOptions::get().evmVersion()}; if (fs::is_directory(fullpath)) { test_suite* sub_suite = BOOST_TEST_SUITE(_path.filename().string()); @@ -94,7 +94,7 @@ int registerTests( { stringstream errorStream; auto testCase = _testCaseCreator(config); - if (testCase->validateSettings(solidity::test::Options::get().evmVersion())) + if (testCase->validateSettings(solidity::test::CommonOptions::get().evmVersion())) switch (testCase->run(errorStream)) { case TestCase::TestResult::Success: @@ -121,15 +121,27 @@ int registerTests( } return numTestsAdded; } + +void initializeOptions() +{ + auto const& suite = boost::unit_test::framework::master_test_suite(); + + auto options = std::make_unique(); + solAssert(options->parse(suite.argc, suite.argv), "Failed to parse options!"); + options->validate(); + + solidity::test::CommonOptions::setSingleton(std::move(options)); +} } test_suite* init_unit_test_suite( int /*argc*/, char* /*argv*/[] ) { master_test_suite_t& master = framework::master_test_suite(); master.p_name.value = "SolidityTests"; - solidity::test::Options::get().validate(); - bool disableSemantics = !solidity::test::EVMHost::getVM(solidity::test::Options::get().evmonePath.string()); + initializeOptions(); + + bool disableSemantics = !solidity::test::EVMHost::getVM(solidity::test::CommonOptions::get().evmonePath.string()); if (disableSemantics) { cout << "Unable to find " << solidity::test::evmoneFilename << ". Please provide the path using -- --evmonepath ." << endl; @@ -140,7 +152,7 @@ test_suite* init_unit_test_suite( int /*argc*/, char* /*argv*/[] ) // Include the interactive tests in the automatic tests as well for (auto const& ts: g_interactiveTestsuites) { - auto const& options = solidity::test::Options::get(); + auto const& options = solidity::test::CommonOptions::get(); if (ts.smt && options.disableSMT) continue; @@ -172,7 +184,7 @@ test_suite* init_unit_test_suite( int /*argc*/, char* /*argv*/[] ) removeTestSuite(suite); } - if (solidity::test::Options::get().disableSMT) + if (solidity::test::CommonOptions::get().disableSMT) removeTestSuite("SMTChecker"); return 0; diff --git a/test/contracts/Wallet.cpp b/test/contracts/Wallet.cpp index 1ec71665a..b692b7954 100644 --- a/test/contracts/Wallet.cpp +++ b/test/contracts/Wallet.cpp @@ -464,7 +464,7 @@ BOOST_AUTO_TEST_CASE(creation) { deployWallet(200); BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(m_sender, h256::AlignRight)) == encodeArgs(true)); - bool v2 = solidity::test::Options::get().useABIEncoderV2; + bool v2 = solidity::test::CommonOptions::get().useABIEncoderV2; BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(~0)) == (v2 ? encodeArgs() : encodeArgs(false))); } diff --git a/test/libevmasm/Optimiser.cpp b/test/libevmasm/Optimiser.cpp index 0eaab67da..7a3125bfd 100644 --- a/test/libevmasm/Optimiser.cpp +++ b/test/libevmasm/Optimiser.cpp @@ -20,7 +20,7 @@ * Tests for the Solidity optimizer. */ -#include +#include #include #include @@ -236,7 +236,7 @@ BOOST_AUTO_TEST_CASE(cse_associativity2) BOOST_AUTO_TEST_CASE(cse_double_shift_right_overflow) { - if (solidity::test::Options::get().evmVersion().hasBitwiseShifting()) + if (solidity::test::CommonOptions::get().evmVersion().hasBitwiseShifting()) { AssemblyItems input{ Instruction::CALLVALUE, @@ -251,7 +251,7 @@ BOOST_AUTO_TEST_CASE(cse_double_shift_right_overflow) BOOST_AUTO_TEST_CASE(cse_double_shift_left_overflow) { - if (solidity::test::Options::get().evmVersion().hasBitwiseShifting()) + if (solidity::test::CommonOptions::get().evmVersion().hasBitwiseShifting()) { AssemblyItems input{ Instruction::DUP1, @@ -1132,7 +1132,7 @@ BOOST_AUTO_TEST_CASE(jumpdest_removal_subassemblies) main.append(t1.toSubAssemblyTag(subId)); main.append(u256(8)); - main.optimise(true, solidity::test::Options::get().evmVersion(), false, 200); + main.optimise(true, solidity::test::CommonOptions::get().evmVersion(), false, 200); AssemblyItems expectationMain{ AssemblyItem(PushSubSize, 0), @@ -1178,7 +1178,7 @@ BOOST_AUTO_TEST_CASE(cse_sub_zero) BOOST_AUTO_TEST_CASE(cse_remove_redundant_shift_masking) { - if (!solidity::test::Options::get().evmVersion().hasBitwiseShifting()) + if (!solidity::test::CommonOptions::get().evmVersion().hasBitwiseShifting()) return; for (int i = 1; i < 256; i++) @@ -1326,7 +1326,7 @@ BOOST_AUTO_TEST_CASE(cse_remove_unwanted_masking_of_address) BOOST_AUTO_TEST_CASE(cse_replace_too_large_shift) { - if (!solidity::test::Options::get().evmVersion().hasBitwiseShifting()) + if (!solidity::test::CommonOptions::get().evmVersion().hasBitwiseShifting()) return; checkCSE({ diff --git a/test/liblangutil/CharStream.cpp b/test/liblangutil/CharStream.cpp index 8c8eaca73..3b9d980c1 100644 --- a/test/liblangutil/CharStream.cpp +++ b/test/liblangutil/CharStream.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include #include diff --git a/test/liblangutil/SourceLocation.cpp b/test/liblangutil/SourceLocation.cpp index 16aa0bab4..8fe4740fd 100644 --- a/test/liblangutil/SourceLocation.cpp +++ b/test/liblangutil/SourceLocation.cpp @@ -22,7 +22,7 @@ #include -#include +#include #include diff --git a/test/libsolidity/ABIDecoderTests.cpp b/test/libsolidity/ABIDecoderTests.cpp index c3bc548ec..39bf7602c 100644 --- a/test/libsolidity/ABIDecoderTests.cpp +++ b/test/libsolidity/ABIDecoderTests.cpp @@ -82,7 +82,7 @@ BOOST_AUTO_TEST_CASE(enums) } } )"; - bool newDecoder = solidity::test::Options::get().useABIEncoderV2; + bool newDecoder = solidity::test::CommonOptions::get().useABIEncoderV2; BOTH_ENCODERS( compileAndRun(sourceCode); ABI_CHECK(callContractFunction("f(uint8)", 0), encodeArgs(u256(0))); @@ -104,7 +104,7 @@ BOOST_AUTO_TEST_CASE(cleanup) } } )"; - bool newDecoder = solidity::test::Options::get().useABIEncoderV2; + bool newDecoder = solidity::test::CommonOptions::get().useABIEncoderV2; BOTH_ENCODERS( compileAndRun(sourceCode); ABI_CHECK( @@ -573,7 +573,7 @@ BOOST_AUTO_TEST_CASE(validation_function_type) function i(function () external[] calldata a) external pure returns (uint r) { a[0]; r = 4; } } )"; - bool newDecoder = solidity::test::Options::get().useABIEncoderV2; + bool newDecoder = solidity::test::CommonOptions::get().useABIEncoderV2; string validFun{"01234567890123456789abcd"}; string invalidFun{"01234567890123456789abcdX"}; BOTH_ENCODERS( @@ -950,7 +950,7 @@ BOOST_AUTO_TEST_CASE(out_of_bounds_bool_value) function f(bool b) public pure returns (bool) { return b; } } )"; - bool newDecoder = solidity::test::Options::get().useABIEncoderV2; + bool newDecoder = solidity::test::CommonOptions::get().useABIEncoderV2; BOTH_ENCODERS( compileAndRun(sourceCode); ABI_CHECK(callContractFunction("f(bool)", true), encodeArgs(true)); diff --git a/test/libsolidity/ABIEncoderTests.cpp b/test/libsolidity/ABIEncoderTests.cpp index 426a34018..b816de6fd 100644 --- a/test/libsolidity/ABIEncoderTests.cpp +++ b/test/libsolidity/ABIEncoderTests.cpp @@ -165,7 +165,7 @@ BOOST_AUTO_TEST_CASE(memory_array_one_dim) } )"; - if (!solidity::test::Options::get().useABIEncoderV2) + if (!solidity::test::CommonOptions::get().useABIEncoderV2) { compileAndRun(sourceCode); callContractFunction("f()"); @@ -752,7 +752,7 @@ BOOST_AUTO_TEST_CASE(struct_in_constructor_indirect) } } )"; - if (solidity::test::Options::get().evmVersion().supportsReturndata()) + if (solidity::test::CommonOptions::get().evmVersion().supportsReturndata()) { NEW_ENCODER( compileAndRun(sourceCode, 0, "D"); diff --git a/test/libsolidity/ABIJsonTest.cpp b/test/libsolidity/ABIJsonTest.cpp index daaee026c..1da0193ab 100644 --- a/test/libsolidity/ABIJsonTest.cpp +++ b/test/libsolidity/ABIJsonTest.cpp @@ -20,7 +20,7 @@ #include -#include +#include #include #include @@ -52,8 +52,8 @@ TestCase::TestResult ABIJsonTest::run(ostream& _stream, string const& _linePrefi CompilerStack compiler; compiler.setSources({{"", "pragma solidity >=0.0;\n" + m_source}}); - compiler.setEVMVersion(solidity::test::Options::get().evmVersion()); - compiler.setOptimiserSettings(solidity::test::Options::get().optimize); + compiler.setEVMVersion(solidity::test::CommonOptions::get().evmVersion()); + compiler.setOptimiserSettings(solidity::test::CommonOptions::get().optimize); if (!compiler.parseAndAnalyze()) BOOST_THROW_EXCEPTION(runtime_error("Parsing contract failed")); diff --git a/test/libsolidity/ASTJSONTest.cpp b/test/libsolidity/ASTJSONTest.cpp index 3d035d608..fd65d98f8 100644 --- a/test/libsolidity/ASTJSONTest.cpp +++ b/test/libsolidity/ASTJSONTest.cpp @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include #include @@ -47,7 +47,7 @@ void replaceVersionWithTag(string& _input) { boost::algorithm::replace_all( _input, - "\"" + solidity::test::Options::get().evmVersion().name() + "\"", + "\"" + solidity::test::CommonOptions::get().evmVersion().name() + "\"", "%EVMVERSION%" ); } @@ -57,7 +57,7 @@ void replaceTagWithVersion(string& _input) boost::algorithm::replace_all( _input, "%EVMVERSION%", - "\"" + solidity::test::Options::get().evmVersion().name() + "\"" + "\"" + solidity::test::CommonOptions::get().evmVersion().name() + "\"" ); } @@ -129,7 +129,7 @@ TestCase::TestResult ASTJSONTest::run(ostream& _stream, string const& _linePrefi sourceIndices[m_sources[i].first] = i + 1; } c.setSources(sources); - c.setEVMVersion(solidity::test::Options::get().evmVersion()); + c.setEVMVersion(solidity::test::CommonOptions::get().evmVersion()); if (c.parse()) c.analyze(); else diff --git a/test/libsolidity/AnalysisFramework.cpp b/test/libsolidity/AnalysisFramework.cpp index a76af1081..be14d1cf1 100644 --- a/test/libsolidity/AnalysisFramework.cpp +++ b/test/libsolidity/AnalysisFramework.cpp @@ -20,7 +20,7 @@ #include -#include +#include #include #include @@ -51,7 +51,7 @@ AnalysisFramework::parseAnalyseAndReturnError( { compiler().reset(); compiler().setSources({{"", _insertVersionPragma ? "pragma solidity >=0.0;\n" + _source : _source}}); - compiler().setEVMVersion(solidity::test::Options::get().evmVersion()); + compiler().setEVMVersion(solidity::test::CommonOptions::get().evmVersion()); compiler().setParserErrorRecovery(_allowRecoveryErrors); _allowMultipleErrors = _allowMultipleErrors || _allowRecoveryErrors; if (!compiler().parse()) diff --git a/test/libsolidity/Assembly.cpp b/test/libsolidity/Assembly.cpp index 12b295f8c..3c403f74e 100644 --- a/test/libsolidity/Assembly.cpp +++ b/test/libsolidity/Assembly.cpp @@ -20,7 +20,7 @@ * Unit tests for Assembly Items from evmasm/Assembly.h */ -#include +#include #include #include @@ -52,14 +52,14 @@ evmasm::AssemblyItems compileContract(std::shared_ptr _sourceCode) { ErrorList errors; ErrorReporter errorReporter(errors); - Parser parser(errorReporter, solidity::test::Options::get().evmVersion()); + Parser parser(errorReporter, solidity::test::CommonOptions::get().evmVersion()); ASTPointer sourceUnit; BOOST_REQUIRE_NO_THROW(sourceUnit = parser.parse(make_shared(_sourceCode))); BOOST_CHECK(!!sourceUnit); map> scopes; GlobalContext globalContext; - NameAndTypeResolver resolver(globalContext, solidity::test::Options::get().evmVersion(), scopes, errorReporter); + NameAndTypeResolver resolver(globalContext, solidity::test::CommonOptions::get().evmVersion(), scopes, errorReporter); solAssert(Error::containsOnlyWarnings(errorReporter.errors()), ""); resolver.registerDeclarations(*sourceUnit); for (ASTPointer const& node: sourceUnit->nodes()) @@ -72,7 +72,7 @@ evmasm::AssemblyItems compileContract(std::shared_ptr _sourceCode) for (ASTPointer const& node: sourceUnit->nodes()) if (ContractDefinition* contract = dynamic_cast(node.get())) { - TypeChecker checker(solidity::test::Options::get().evmVersion(), errorReporter); + TypeChecker checker(solidity::test::CommonOptions::get().evmVersion(), errorReporter); BOOST_REQUIRE_NO_THROW(checker.checkTypeRequirements(*contract)); if (!Error::containsOnlyWarnings(errorReporter.errors())) return AssemblyItems(); @@ -81,9 +81,9 @@ evmasm::AssemblyItems compileContract(std::shared_ptr _sourceCode) if (ContractDefinition* contract = dynamic_cast(node.get())) { Compiler compiler( - solidity::test::Options::get().evmVersion(), + solidity::test::CommonOptions::get().evmVersion(), RevertStrings::Default, - solidity::test::Options::get().optimize ? OptimiserSettings::standard() : OptimiserSettings::minimal() + solidity::test::CommonOptions::get().optimize ? OptimiserSettings::standard() : OptimiserSettings::minimal() ); compiler.compileContract(*contract, map>{}, bytes()); @@ -161,12 +161,12 @@ BOOST_AUTO_TEST_CASE(location_test) } )", ""); AssemblyItems items = compileContract(sourceCode); - bool hasShifts = solidity::test::Options::get().evmVersion().hasBitwiseShifting(); + bool hasShifts = solidity::test::CommonOptions::get().evmVersion().hasBitwiseShifting(); auto codegenCharStream = make_shared("", "--CODEGEN--"); vector locations; - if (solidity::test::Options::get().optimize) + if (solidity::test::CommonOptions::get().optimize) locations = vector(4, SourceLocation{2, 82, sourceCode}) + vector(1, SourceLocation{8, 17, codegenCharStream}) + diff --git a/test/libsolidity/GasCosts.cpp b/test/libsolidity/GasCosts.cpp index d3312d7e4..1fa0bf712 100644 --- a/test/libsolidity/GasCosts.cpp +++ b/test/libsolidity/GasCosts.cpp @@ -93,14 +93,14 @@ BOOST_AUTO_TEST_CASE(string_storage) m_compiler.overwriteReleaseFlag(true); compileAndRun(sourceCode); - auto evmVersion = solidity::test::Options::get().evmVersion(); + auto evmVersion = solidity::test::CommonOptions::get().evmVersion(); if (evmVersion <= EVMVersion::byzantium()) CHECK_DEPLOY_GAS(134209, 130895, evmVersion); // This is only correct on >=Constantinople. - else if (Options::get().useABIEncoderV2) + else if (CommonOptions::get().useABIEncoderV2) { - if (Options::get().optimizeYul) + if (CommonOptions::get().optimizeYul) { // Costs with 0 are cases which cannot be triggered in tests. if (evmVersion < EVMVersion::istanbul()) @@ -127,9 +127,9 @@ BOOST_AUTO_TEST_CASE(string_storage) if (evmVersion == EVMVersion::byzantium()) CHECK_GAS(21545, 21526, 20); // This is only correct on >=Constantinople. - else if (Options::get().useABIEncoderV2) + else if (CommonOptions::get().useABIEncoderV2) { - if (Options::get().optimizeYul) + if (CommonOptions::get().optimizeYul) { if (evmVersion < EVMVersion::istanbul()) CHECK_GAS(0, 21567, 20); diff --git a/test/libsolidity/GasMeter.cpp b/test/libsolidity/GasMeter.cpp index 0020d80e4..79394855a 100644 --- a/test/libsolidity/GasMeter.cpp +++ b/test/libsolidity/GasMeter.cpp @@ -44,7 +44,7 @@ public: { m_compiler.reset(); m_compiler.setSources({{"", "pragma solidity >=0.0;\n" + _sourceCode}}); - m_compiler.setOptimiserSettings(solidity::test::Options::get().optimize); + m_compiler.setOptimiserSettings(solidity::test::CommonOptions::get().optimize); m_compiler.setEVMVersion(m_evmVersion); BOOST_REQUIRE_MESSAGE(m_compiler.compile(), "Compiling contract failed"); @@ -52,7 +52,7 @@ public: ASTNode const& sourceUnit = m_compiler.ast(""); BOOST_REQUIRE(items != nullptr); m_gasCosts = GasEstimator::breakToStatementLevel( - GasEstimator(solidity::test::Options::get().evmVersion()).structuralEstimation(*items, vector({&sourceUnit})), + GasEstimator(solidity::test::CommonOptions::get().evmVersion()).structuralEstimation(*items, vector({&sourceUnit})), {&sourceUnit} ); } @@ -61,7 +61,7 @@ public: { compileAndRun(_sourceCode); auto state = make_shared(); - PathGasMeter meter(*m_compiler.assemblyItems(m_compiler.lastContractName()), solidity::test::Options::get().evmVersion()); + PathGasMeter meter(*m_compiler.assemblyItems(m_compiler.lastContractName()), solidity::test::CommonOptions::get().evmVersion()); GasMeter::GasConsumption gas = meter.estimateMax(0, state); u256 bytecodeSize(m_compiler.runtimeObject(m_compiler.lastContractName()).bytecode.size()); // costs for deployment @@ -71,7 +71,7 @@ public: // Skip the tests when we force ABIEncoderV2. // TODO: We should enable this again once the yul optimizer is activated. - if (!solidity::test::Options::get().useABIEncoderV2) + if (!solidity::test::CommonOptions::get().useABIEncoderV2) { BOOST_REQUIRE(!gas.isInfinite); BOOST_CHECK_LE(m_gasUsed, gas.value); @@ -94,13 +94,13 @@ public: gas = max(gas, gasForTransaction(hash.asBytes() + arguments, false)); } - gas += GasEstimator(solidity::test::Options::get().evmVersion()).functionalEstimation( + gas += GasEstimator(solidity::test::CommonOptions::get().evmVersion()).functionalEstimation( *m_compiler.runtimeAssemblyItems(m_compiler.lastContractName()), _sig ); // Skip the tests when we force ABIEncoderV2. // TODO: We should enable this again once the yul optimizer is activated. - if (!solidity::test::Options::get().useABIEncoderV2) + if (!solidity::test::CommonOptions::get().useABIEncoderV2) { BOOST_REQUIRE(!gas.isInfinite); BOOST_CHECK_LE(m_gasUsed, gas.value); @@ -110,7 +110,7 @@ public: static GasMeter::GasConsumption gasForTransaction(bytes const& _data, bool _isCreation) { - auto evmVersion = solidity::test::Options::get().evmVersion(); + auto evmVersion = solidity::test::CommonOptions::get().evmVersion(); GasMeter::GasConsumption gas = _isCreation ? GasCosts::txCreateGas : GasCosts::txGas; for (auto i: _data) gas += i != 0 ? GasCosts::txDataNonZeroGas(evmVersion) : GasCosts::txDataZeroGas; diff --git a/test/libsolidity/GasTest.cpp b/test/libsolidity/GasTest.cpp index 6cb5f6cce..b1b0d56f2 100644 --- a/test/libsolidity/GasTest.cpp +++ b/test/libsolidity/GasTest.cpp @@ -16,7 +16,7 @@ */ #include -#include +#include #include #include #include diff --git a/test/libsolidity/Imports.cpp b/test/libsolidity/Imports.cpp index 7b6134d15..aa4cab9b8 100644 --- a/test/libsolidity/Imports.cpp +++ b/test/libsolidity/Imports.cpp @@ -21,7 +21,7 @@ */ #include -#include +#include #include #include @@ -47,7 +47,7 @@ BOOST_AUTO_TEST_CASE(remappings) {"s_1.4.6/s.sol", "contract S {} pragma solidity >=0.0;"}, {"Tee/tee.sol", "contract Tee {} pragma solidity >=0.0;"} }); - c.setEVMVersion(solidity::test::Options::get().evmVersion()); + c.setEVMVersion(solidity::test::CommonOptions::get().evmVersion()); BOOST_CHECK(c.compile()); } @@ -61,7 +61,7 @@ BOOST_AUTO_TEST_CASE(context_dependent_remappings) {"s_1.4.6/s.sol", "contract SSix {} pragma solidity >=0.0;"}, {"s_1.4.7/s.sol", "contract SSeven {} pragma solidity >=0.0;"} }); - c.setEVMVersion(solidity::test::Options::get().evmVersion()); + c.setEVMVersion(solidity::test::CommonOptions::get().evmVersion()); BOOST_CHECK(c.compile()); } @@ -79,7 +79,7 @@ BOOST_AUTO_TEST_CASE(context_dependent_remappings_ensure_default_and_module_pres {"vendor/foo_1.0.0/foo.sol", "contract Foo1 {} pragma solidity >=0.0;"}, {"vendor/foo_2.0.0/foo.sol", "contract Foo2 {} pragma solidity >=0.0;"} }); - c.setEVMVersion(solidity::test::Options::get().evmVersion()); + c.setEVMVersion(solidity::test::CommonOptions::get().evmVersion()); BOOST_CHECK(c.compile()); } @@ -93,7 +93,7 @@ BOOST_AUTO_TEST_CASE(context_dependent_remappings_order_independent_1) {"d/z.sol", "contract D {} pragma solidity >=0.0;"}, {"e/y/z/z.sol", "contract E {} pragma solidity >=0.0;"} }); - c.setEVMVersion(solidity::test::Options::get().evmVersion()); + c.setEVMVersion(solidity::test::CommonOptions::get().evmVersion()); BOOST_CHECK(c.compile()); } @@ -107,7 +107,7 @@ BOOST_AUTO_TEST_CASE(context_dependent_remappings_order_independent_2) {"d/z.sol", "contract D {} pragma solidity >=0.0;"}, {"e/y/z/z.sol", "contract E {} pragma solidity >=0.0;"} }); - c.setEVMVersion(solidity::test::Options::get().evmVersion()); + c.setEVMVersion(solidity::test::CommonOptions::get().evmVersion()); BOOST_CHECK(c.compile()); } diff --git a/test/libsolidity/InlineAssembly.cpp b/test/libsolidity/InlineAssembly.cpp index 4b906e475..4ca713054 100644 --- a/test/libsolidity/InlineAssembly.cpp +++ b/test/libsolidity/InlineAssembly.cpp @@ -20,7 +20,7 @@ * Unit tests for inline assembly. */ -#include +#include #include @@ -59,7 +59,7 @@ std::optional parseAndReturnFirstError( AssemblyStack::Machine _machine = AssemblyStack::Machine::EVM ) { - AssemblyStack stack(solidity::test::Options::get().evmVersion(), _language, solidity::frontend::OptimiserSettings::none()); + AssemblyStack stack(solidity::test::CommonOptions::get().evmVersion(), _language, solidity::frontend::OptimiserSettings::none()); bool success = false; try { @@ -126,7 +126,7 @@ Error expectError( void parsePrintCompare(string const& _source, bool _canWarn = false) { - AssemblyStack stack(solidity::test::Options::get().evmVersion(), AssemblyStack::Language::Assembly, OptimiserSettings::none()); + AssemblyStack stack(solidity::test::CommonOptions::get().evmVersion(), AssemblyStack::Language::Assembly, OptimiserSettings::none()); BOOST_REQUIRE(stack.parseAndAnalyze("", _source)); if (_canWarn) BOOST_REQUIRE(Error::containsOnlyWarnings(stack.errors())); @@ -539,7 +539,7 @@ BOOST_AUTO_TEST_CASE(print_string_literal_unicode) { string source = "{ let x := \"\\u1bac\" }"; string parsed = "object \"object\" {\n code { let x := \"\\xe1\\xae\\xac\" }\n}\n"; - AssemblyStack stack(solidity::test::Options::get().evmVersion(), AssemblyStack::Language::Assembly, OptimiserSettings::none()); + AssemblyStack stack(solidity::test::CommonOptions::get().evmVersion(), AssemblyStack::Language::Assembly, OptimiserSettings::none()); BOOST_REQUIRE(stack.parseAndAnalyze("", source)); BOOST_REQUIRE(stack.errors().empty()); BOOST_CHECK_EQUAL(stack.print(), parsed); @@ -686,42 +686,42 @@ BOOST_AUTO_TEST_CASE(keccak256) BOOST_AUTO_TEST_CASE(returndatasize) { - if (!solidity::test::Options::get().evmVersion().supportsReturndata()) + if (!solidity::test::CommonOptions::get().evmVersion().supportsReturndata()) return; BOOST_CHECK(successAssemble("{ let r := returndatasize() }")); } BOOST_AUTO_TEST_CASE(returndatacopy) { - if (!solidity::test::Options::get().evmVersion().supportsReturndata()) + if (!solidity::test::CommonOptions::get().evmVersion().supportsReturndata()) return; BOOST_CHECK(successAssemble("{ returndatacopy(0, 32, 64) }")); } BOOST_AUTO_TEST_CASE(returndatacopy_functional) { - if (!solidity::test::Options::get().evmVersion().supportsReturndata()) + if (!solidity::test::CommonOptions::get().evmVersion().supportsReturndata()) return; BOOST_CHECK(successAssemble("{ returndatacopy(0, 32, 64) }")); } BOOST_AUTO_TEST_CASE(staticcall) { - if (!solidity::test::Options::get().evmVersion().hasStaticCall()) + if (!solidity::test::CommonOptions::get().evmVersion().hasStaticCall()) return; BOOST_CHECK(successAssemble("{ pop(staticcall(10000, 0x123, 64, 0x10, 128, 0x10)) }")); } BOOST_AUTO_TEST_CASE(create2) { - if (!solidity::test::Options::get().evmVersion().hasCreate2()) + if (!solidity::test::CommonOptions::get().evmVersion().hasCreate2()) return; BOOST_CHECK(successAssemble("{ pop(create2(10, 0x123, 32, 64)) }")); } BOOST_AUTO_TEST_CASE(shift) { - if (!solidity::test::Options::get().evmVersion().hasBitwiseShifting()) + if (!solidity::test::CommonOptions::get().evmVersion().hasBitwiseShifting()) return; BOOST_CHECK(successAssemble("{ pop(shl(10, 32)) }")); BOOST_CHECK(successAssemble("{ pop(shr(10, 32)) }")); @@ -730,7 +730,7 @@ BOOST_AUTO_TEST_CASE(shift) BOOST_AUTO_TEST_CASE(shift_constantinople_warning) { - if (solidity::test::Options::get().evmVersion().hasBitwiseShifting()) + if (solidity::test::CommonOptions::get().evmVersion().hasBitwiseShifting()) return; CHECK_PARSE_WARNING("{ pop(shl(10, 32)) }", TypeError, "The \"shl\" instruction is only available for Constantinople-compatible VMs"); CHECK_PARSE_WARNING("{ pop(shr(10, 32)) }", TypeError, "The \"shr\" instruction is only available for Constantinople-compatible VMs"); diff --git a/test/libsolidity/Metadata.cpp b/test/libsolidity/Metadata.cpp index a8930a76f..665a17590 100644 --- a/test/libsolidity/Metadata.cpp +++ b/test/libsolidity/Metadata.cpp @@ -20,7 +20,7 @@ */ #include -#include +#include #include #include #include @@ -68,8 +68,8 @@ BOOST_AUTO_TEST_CASE(metadata_stamp) CompilerStack compilerStack; compilerStack.overwriteReleaseFlag(release); compilerStack.setSources({{"", std::string(sourceCode)}}); - compilerStack.setEVMVersion(solidity::test::Options::get().evmVersion()); - compilerStack.setOptimiserSettings(solidity::test::Options::get().optimize); + compilerStack.setEVMVersion(solidity::test::CommonOptions::get().evmVersion()); + compilerStack.setOptimiserSettings(solidity::test::CommonOptions::get().optimize); compilerStack.setMetadataHash(metadataHash); BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed"); bytes const& bytecode = compilerStack.runtimeObject("test").bytecode; @@ -129,8 +129,8 @@ BOOST_AUTO_TEST_CASE(metadata_stamp_experimental) CompilerStack compilerStack; compilerStack.overwriteReleaseFlag(release); compilerStack.setSources({{"", std::string(sourceCode)}}); - compilerStack.setEVMVersion(solidity::test::Options::get().evmVersion()); - compilerStack.setOptimiserSettings(solidity::test::Options::get().optimize); + compilerStack.setEVMVersion(solidity::test::CommonOptions::get().evmVersion()); + compilerStack.setOptimiserSettings(solidity::test::CommonOptions::get().optimize); compilerStack.setMetadataHash(metadataHash); BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed"); bytes const& bytecode = compilerStack.runtimeObject("test").bytecode; @@ -191,8 +191,8 @@ BOOST_AUTO_TEST_CASE(metadata_relevant_sources) {"A", std::string(sourceCodeA)}, {"B", std::string(sourceCodeB)}, }); - compilerStack.setEVMVersion(solidity::test::Options::get().evmVersion()); - compilerStack.setOptimiserSettings(solidity::test::Options::get().optimize); + compilerStack.setEVMVersion(solidity::test::CommonOptions::get().evmVersion()); + compilerStack.setOptimiserSettings(solidity::test::CommonOptions::get().optimize); BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed"); std::string const& serialisedMetadata = compilerStack.metadata("A"); @@ -232,8 +232,8 @@ BOOST_AUTO_TEST_CASE(metadata_relevant_sources_imports) {"B", std::string(sourceCodeB)}, {"C", std::string(sourceCodeC)} }); - compilerStack.setEVMVersion(solidity::test::Options::get().evmVersion()); - compilerStack.setOptimiserSettings(solidity::test::Options::get().optimize); + compilerStack.setEVMVersion(solidity::test::CommonOptions::get().evmVersion()); + compilerStack.setOptimiserSettings(solidity::test::CommonOptions::get().optimize); BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed"); std::string const& serialisedMetadata = compilerStack.metadata("C"); @@ -260,8 +260,8 @@ BOOST_AUTO_TEST_CASE(metadata_useLiteralContent) { CompilerStack compilerStack; compilerStack.setSources({{"", std::string(_src)}}); - compilerStack.setEVMVersion(solidity::test::Options::get().evmVersion()); - compilerStack.setOptimiserSettings(solidity::test::Options::get().optimize); + compilerStack.setEVMVersion(solidity::test::CommonOptions::get().evmVersion()); + compilerStack.setOptimiserSettings(solidity::test::CommonOptions::get().optimize); compilerStack.useMetadataLiteralSources(_literal); BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed"); string metadata_str = compilerStack.metadata("test"); diff --git a/test/libsolidity/SMTChecker.cpp b/test/libsolidity/SMTChecker.cpp index 3cf0c73f5..06862ad08 100644 --- a/test/libsolidity/SMTChecker.cpp +++ b/test/libsolidity/SMTChecker.cpp @@ -19,7 +19,7 @@ */ #include -#include +#include #include @@ -83,7 +83,7 @@ BOOST_AUTO_TEST_CASE(import_base) } )"} }); - c.setEVMVersion(solidity::test::Options::get().evmVersion()); + c.setEVMVersion(solidity::test::CommonOptions::get().evmVersion()); BOOST_CHECK(c.compile()); unsigned asserts = 0; @@ -122,7 +122,7 @@ BOOST_AUTO_TEST_CASE(import_library) } )"} }); - c.setEVMVersion(solidity::test::Options::get().evmVersion()); + c.setEVMVersion(solidity::test::CommonOptions::get().evmVersion()); BOOST_CHECK(c.compile()); unsigned asserts = 0; diff --git a/test/libsolidity/SMTCheckerJSONTest.cpp b/test/libsolidity/SMTCheckerJSONTest.cpp index 42d29fa40..82c2b446b 100644 --- a/test/libsolidity/SMTCheckerJSONTest.cpp +++ b/test/libsolidity/SMTCheckerJSONTest.cpp @@ -16,7 +16,7 @@ */ #include -#include +#include #include #include #include diff --git a/test/libsolidity/SMTCheckerTest.cpp b/test/libsolidity/SMTCheckerTest.cpp index 47ed43ba5..7db668a2d 100644 --- a/test/libsolidity/SMTCheckerTest.cpp +++ b/test/libsolidity/SMTCheckerTest.cpp @@ -16,7 +16,7 @@ */ #include -#include +#include #include diff --git a/test/libsolidity/SemVerMatcher.cpp b/test/libsolidity/SemVerMatcher.cpp index 82cc07367..36b9c8214 100644 --- a/test/libsolidity/SemVerMatcher.cpp +++ b/test/libsolidity/SemVerMatcher.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include diff --git a/test/libsolidity/SemanticTest.cpp b/test/libsolidity/SemanticTest.cpp index 4082a6ab8..eb01764bc 100644 --- a/test/libsolidity/SemanticTest.cpp +++ b/test/libsolidity/SemanticTest.cpp @@ -13,7 +13,7 @@ */ #include -#include +#include #include #include #include diff --git a/test/libsolidity/SolidityCompiler.cpp b/test/libsolidity/SolidityCompiler.cpp index 117a41187..971a74a75 100644 --- a/test/libsolidity/SolidityCompiler.cpp +++ b/test/libsolidity/SolidityCompiler.cpp @@ -20,7 +20,7 @@ #include #include -#include +#include #include @@ -40,7 +40,7 @@ BOOST_AUTO_TEST_CASE(does_not_include_creation_time_only_internal_functions) function f() internal { for (uint i = 0; i < 10; ++i) x += 3 + i; } } )"; - compiler().setOptimiserSettings(solidity::test::Options::get().optimize); + compiler().setOptimiserSettings(solidity::test::CommonOptions::get().optimize); BOOST_REQUIRE(success(sourceCode)); BOOST_REQUIRE_MESSAGE(compiler().compile(), "Compiling contract failed"); bytes const& creationBytecode = solidity::test::bytecodeSansMetadata(compiler().object("C").bytecode); diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index a1d200f89..48dbe2c43 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -23,7 +23,7 @@ #include -#include +#include #include #include @@ -2458,7 +2458,7 @@ BOOST_AUTO_TEST_CASE(default_fallback_throws) compileAndRun(sourceCode); ABI_CHECK(callContractFunction("f()"), encodeArgs(0)); - if (solidity::test::Options::get().evmVersion().hasStaticCall()) + if (solidity::test::CommonOptions::get().evmVersion().hasStaticCall()) { char const* sourceCode = R"YY( contract A { @@ -3323,7 +3323,7 @@ BOOST_AUTO_TEST_CASE(generic_delegatecall) BOOST_AUTO_TEST_CASE(generic_staticcall) { - if (solidity::test::Options::get().evmVersion().hasStaticCall()) + if (solidity::test::CommonOptions::get().evmVersion().hasStaticCall()) { char const* sourceCode = R"**( contract A { @@ -5709,7 +5709,7 @@ BOOST_AUTO_TEST_CASE(bool_conversion) } )"; compileAndRun(sourceCode, 0, "C"); - bool v2 = solidity::test::Options::get().useABIEncoderV2; + bool v2 = solidity::test::CommonOptions::get().useABIEncoderV2; ABI_CHECK(callContractFunction("f(bool)", 0), encodeArgs(0)); ABI_CHECK(callContractFunction("f(bool)", 1), encodeArgs(1)); ABI_CHECK(callContractFunction("f(bool)", 2), v2 ? encodeArgs() : encodeArgs(1)); @@ -9970,7 +9970,7 @@ BOOST_AUTO_TEST_CASE(cleanup_bytes_types) )"; compileAndRun(sourceCode, 0, "C"); // We input longer data on purpose. - bool v2 = solidity::test::Options::get().useABIEncoderV2; + bool v2 = solidity::test::CommonOptions::get().useABIEncoderV2; ABI_CHECK(callContractFunction("f(bytes2,uint16)", string("abc"), u256(0x040102)), v2 ? encodeArgs() : encodeArgs(0)); } BOOST_AUTO_TEST_CASE(cleanup_bytes_types_shortening) @@ -10007,7 +10007,7 @@ BOOST_AUTO_TEST_CASE(cleanup_address_types) )"; compileAndRun(sourceCode, 0, "C"); - bool v2 = solidity::test::Options::get().useABIEncoderV2; + bool v2 = solidity::test::CommonOptions::get().useABIEncoderV2; // We input longer data on purpose. ABI_CHECK(callContractFunction("f(address)", u256("0xFFFF1234567890123456789012345678901234567890")), v2 ? encodeArgs() : encodeArgs(0)); ABI_CHECK(callContractFunction("g(address)", u256("0xFFFF1234567890123456789012345678901234567890")), v2 ? encodeArgs() : encodeArgs(0)); @@ -11260,7 +11260,7 @@ BOOST_AUTO_TEST_CASE(shift_right_garbled) } )"; compileAndRun(sourceCode, 0, "C"); - bool v2 = solidity::test::Options::get().useABIEncoderV2; + bool v2 = solidity::test::CommonOptions::get().useABIEncoderV2; ABI_CHECK(callContractFunction("f(uint8,uint8)", u256(0x0), u256(4)), encodeArgs(u256(0xf))); ABI_CHECK(callContractFunction("f(uint8,uint8)", u256(0x0), u256(0x1004)), v2 ? encodeArgs() : encodeArgs(u256(0xf))); } @@ -11286,7 +11286,7 @@ BOOST_AUTO_TEST_CASE(shift_right_garbled_signed) } )"; compileAndRun(sourceCode, 0, "C"); - bool v2 = solidity::test::Options::get().useABIEncoderV2; + bool v2 = solidity::test::CommonOptions::get().useABIEncoderV2; ABI_CHECK(callContractFunction("f(int8,uint8)", u256(0x0), u256(3)), encodeArgs(u256(-2))); ABI_CHECK(callContractFunction("f(int8,uint8)", u256(0x0), u256(4)), encodeArgs(u256(-1))); ABI_CHECK(callContractFunction("f(int8,uint8)", u256(0x0), u256(0xFF)), encodeArgs(u256(-1))); @@ -11480,7 +11480,7 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_signextend_int8) } )"; compileAndRun(sourceCode, 0, "C"); - bool v2 = solidity::test::Options::get().useABIEncoderV2; + bool v2 = solidity::test::CommonOptions::get().useABIEncoderV2; ABI_CHECK(callContractFunction("f(int8,int8)", u256(0x99u), u256(0)), v2 ? encodeArgs() : encodeArgs(u256(-103))); ABI_CHECK(callContractFunction("f(int8,int8)", u256(0x99u), u256(1)), v2 ? encodeArgs() : encodeArgs(u256(-52))); ABI_CHECK(callContractFunction("f(int8,int8)", u256(0x99u), u256(2)), v2 ? encodeArgs() : encodeArgs(u256(-26))); @@ -11498,7 +11498,7 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_signextend_int16) } )"; compileAndRun(sourceCode, 0, "C"); - bool v2 = solidity::test::Options::get().useABIEncoderV2; + bool v2 = solidity::test::CommonOptions::get().useABIEncoderV2; ABI_CHECK(callContractFunction("f(int16,int16)", u256(0xFF99u), u256(0)), v2 ? encodeArgs() : encodeArgs(u256(-103))); ABI_CHECK(callContractFunction("f(int16,int16)", u256(0xFF99u), u256(1)), v2 ? encodeArgs() : encodeArgs(u256(-52))); ABI_CHECK(callContractFunction("f(int16,int16)", u256(0xFF99u), u256(2)), v2 ? encodeArgs() : encodeArgs(u256(-26))); @@ -11516,7 +11516,7 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_signextend_int32) } )"; compileAndRun(sourceCode, 0, "C"); - bool v2 = solidity::test::Options::get().useABIEncoderV2; + bool v2 = solidity::test::CommonOptions::get().useABIEncoderV2; ABI_CHECK(callContractFunction("f(int32,int32)", u256(0xFFFFFF99u), u256(0)), v2 ? encodeArgs() : encodeArgs(u256(-103))); ABI_CHECK(callContractFunction("f(int32,int32)", u256(0xFFFFFF99u), u256(1)), v2 ? encodeArgs() : encodeArgs(u256(-52))); ABI_CHECK(callContractFunction("f(int32,int32)", u256(0xFFFFFF99u), u256(2)), v2 ? encodeArgs() : encodeArgs(u256(-26))); @@ -12044,7 +12044,7 @@ BOOST_AUTO_TEST_CASE(revert_with_cause) } } )"; - if (solidity::test::Options::get().evmVersion().supportsReturndata()) + if (solidity::test::CommonOptions::get().evmVersion().supportsReturndata()) { compileAndRun(sourceCode, 0, "C"); bytes const errorSignature = bytes{0x08, 0xc3, 0x79, 0xa0}; @@ -12118,7 +12118,7 @@ BOOST_AUTO_TEST_CASE(require_with_message) } } )"; - if (solidity::test::Options::get().evmVersion().supportsReturndata()) + if (solidity::test::CommonOptions::get().evmVersion().supportsReturndata()) { compileAndRun(sourceCode, 0, "C"); bytes const errorSignature = bytes{0x08, 0xc3, 0x79, 0xa0}; @@ -12164,7 +12164,7 @@ BOOST_AUTO_TEST_CASE(bubble_up_error_messages) } } )"; - if (solidity::test::Options::get().evmVersion().supportsReturndata()) + if (solidity::test::CommonOptions::get().evmVersion().supportsReturndata()) { compileAndRun(sourceCode, 0, "C"); bytes const errorSignature = bytes{0x08, 0xc3, 0x79, 0xa0}; @@ -12202,7 +12202,7 @@ BOOST_AUTO_TEST_CASE(bubble_up_error_messages_through_transfer) } } )"; - if (solidity::test::Options::get().evmVersion().supportsReturndata()) + if (solidity::test::CommonOptions::get().evmVersion().supportsReturndata()) { compileAndRun(sourceCode, 0, "C"); bytes const errorSignature = bytes{0x08, 0xc3, 0x79, 0xa0}; @@ -12241,7 +12241,7 @@ BOOST_AUTO_TEST_CASE(bubble_up_error_messages_through_create) } } )"; - if (solidity::test::Options::get().evmVersion().supportsReturndata()) + if (solidity::test::CommonOptions::get().evmVersion().supportsReturndata()) { compileAndRun(sourceCode, 0, "C"); bytes const errorSignature = bytes{0x08, 0xc3, 0x79, 0xa0}; @@ -12446,7 +12446,7 @@ BOOST_AUTO_TEST_CASE(bare_call_invalid_address) ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(1))); ABI_CHECK(callContractFunction("h()"), encodeArgs(u256(1))); - if (solidity::test::Options::get().evmVersion().hasStaticCall()) + if (solidity::test::CommonOptions::get().evmVersion().hasStaticCall()) { char const* sourceCode = R"YY( contract C { @@ -12462,10 +12462,10 @@ BOOST_AUTO_TEST_CASE(bare_call_invalid_address) BOOST_AUTO_TEST_CASE(bare_call_return_data) { - if (solidity::test::Options::get().evmVersion().supportsReturndata()) + if (solidity::test::CommonOptions::get().evmVersion().supportsReturndata()) { vector calltypes = {"call", "delegatecall"}; - if (solidity::test::Options::get().evmVersion().hasStaticCall()) + if (solidity::test::CommonOptions::get().evmVersion().hasStaticCall()) calltypes.emplace_back("staticcall"); for (string const& calltype: calltypes) { @@ -12589,7 +12589,7 @@ BOOST_AUTO_TEST_CASE(bare_call_return_data) BOOST_AUTO_TEST_CASE(delegatecall_return_value) { - if (solidity::test::Options::get().evmVersion().supportsReturndata()) + if (solidity::test::CommonOptions::get().evmVersion().supportsReturndata()) { char const* sourceCode = R"DELIMITER( contract C { @@ -13390,7 +13390,7 @@ BOOST_AUTO_TEST_CASE(abi_encode_empty_string) )"; compileAndRun(sourceCode, 0, "C"); - if (!solidity::test::Options::get().useABIEncoderV2) + if (!solidity::test::CommonOptions::get().useABIEncoderV2) { // ABI Encoder V2 has slightly different padding, tested below. ABI_CHECK(callContractFunction("f()"), encodeArgs( @@ -13514,7 +13514,7 @@ BOOST_AUTO_TEST_CASE(staticcall_for_view_and_pure) compileAndRun(sourceCode, 0, "D"); // This should work (called via CALL) ABI_CHECK(callContractFunction("f()"), encodeArgs(1)); - if (solidity::test::Options::get().evmVersion().hasStaticCall()) + if (solidity::test::CommonOptions::get().evmVersion().hasStaticCall()) { // These should throw (called via STATICCALL) ABI_CHECK(callContractFunction("fview()"), encodeArgs()); @@ -13529,7 +13529,7 @@ BOOST_AUTO_TEST_CASE(staticcall_for_view_and_pure) BOOST_AUTO_TEST_CASE(bitwise_shifting_constantinople) { - if (!solidity::test::Options::get().evmVersion().hasBitwiseShifting()) + if (!solidity::test::CommonOptions::get().evmVersion().hasBitwiseShifting()) return; char const* sourceCode = R"( contract C { @@ -13568,7 +13568,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constantinople) BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople) { - if (!solidity::test::Options::get().evmVersion().hasBitwiseShifting()) + if (!solidity::test::CommonOptions::get().evmVersion().hasBitwiseShifting()) return; char const* sourceCode = R"( contract C { @@ -13635,7 +13635,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople) BOOST_AUTO_TEST_CASE(bitwise_shifting_constantinople_combined) { - if (!solidity::test::Options::get().evmVersion().hasBitwiseShifting()) + if (!solidity::test::CommonOptions::get().evmVersion().hasBitwiseShifting()) return; char const* sourceCode = R"( contract C { @@ -14391,7 +14391,7 @@ BOOST_AUTO_TEST_CASE(try_catch_library_call) } } )"; - if (solidity::test::Options::get().evmVersion().supportsReturndata()) + if (solidity::test::CommonOptions::get().evmVersion().supportsReturndata()) { compileAndRun(sourceCode, 0, "L", bytes()); compileAndRun(sourceCode, 0, "C", bytes(), map{{"L", m_contractAddress}}); diff --git a/test/libsolidity/SolidityExecutionFramework.cpp b/test/libsolidity/SolidityExecutionFramework.cpp index 27deb4d23..8f428f13f 100644 --- a/test/libsolidity/SolidityExecutionFramework.cpp +++ b/test/libsolidity/SolidityExecutionFramework.cpp @@ -39,7 +39,7 @@ bytes SolidityExecutionFramework::compileContract( // Silence compiler version warning std::string sourceCode = "pragma solidity >=0.0;\n"; if ( - solidity::test::Options::get().useABIEncoderV2 && + solidity::test::CommonOptions::get().useABIEncoderV2 && _sourceCode.find("pragma experimental ABIEncoderV2;") == std::string::npos ) sourceCode += "pragma experimental ABIEncoderV2;\n"; diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp index 56ca6d51d..0cafe42a4 100644 --- a/test/libsolidity/SolidityExpressionCompiler.cpp +++ b/test/libsolidity/SolidityExpressionCompiler.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include @@ -100,7 +100,7 @@ bytes compileFirstExpression( { ErrorList errors; ErrorReporter errorReporter(errors); - sourceUnit = Parser(errorReporter, solidity::test::Options::get().evmVersion()).parse( + sourceUnit = Parser(errorReporter, solidity::test::CommonOptions::get().evmVersion()).parse( make_shared(CharStream(_sourceCode, "")) ); if (!sourceUnit) @@ -116,7 +116,7 @@ bytes compileFirstExpression( ErrorReporter errorReporter(errors); GlobalContext globalContext; map> scopes; - NameAndTypeResolver resolver(globalContext, solidity::test::Options::get().evmVersion(), scopes, errorReporter); + NameAndTypeResolver resolver(globalContext, solidity::test::CommonOptions::get().evmVersion(), scopes, errorReporter); resolver.registerDeclarations(*sourceUnit); vector inheritanceHierarchy; @@ -130,7 +130,7 @@ bytes compileFirstExpression( if (ContractDefinition* contract = dynamic_cast(node.get())) { ErrorReporter errorReporter(errors); - TypeChecker typeChecker(solidity::test::Options::get().evmVersion(), errorReporter); + TypeChecker typeChecker(solidity::test::CommonOptions::get().evmVersion(), errorReporter); BOOST_REQUIRE(typeChecker.checkTypeRequirements(*contract)); } for (ASTPointer const& node: sourceUnit->nodes()) @@ -139,7 +139,7 @@ bytes compileFirstExpression( FirstExpressionExtractor extractor(*contract); BOOST_REQUIRE(extractor.expression() != nullptr); - CompilerContext context(solidity::test::Options::get().evmVersion()); + CompilerContext context(solidity::test::CommonOptions::get().evmVersion()); context.resetVisitedNodes(contract); context.setInheritanceHierarchy(inheritanceHierarchy); unsigned parametersSize = _localVariables.size(); // assume they are all one slot on the stack @@ -153,7 +153,7 @@ bytes compileFirstExpression( ExpressionCompiler( context, RevertStrings::Default, - solidity::test::Options::get().optimize + solidity::test::CommonOptions::get().optimize ).compile(*extractor.expression()); for (vector const& function: _functions) @@ -284,7 +284,7 @@ BOOST_AUTO_TEST_CASE(comparison) bytes code = compileFirstExpression(sourceCode); bytes expectation; - if (solidity::test::Options::get().optimize) + if (solidity::test::CommonOptions::get().optimize) expectation = { uint8_t(Instruction::PUSH2), 0x11, 0xaa, uint8_t(Instruction::PUSH2), 0x10, 0xaa, @@ -347,7 +347,7 @@ BOOST_AUTO_TEST_CASE(arithmetic) bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "y"}}); bytes expectation; - if (solidity::test::Options::get().optimize) + if (solidity::test::CommonOptions::get().optimize) expectation = { uint8_t(Instruction::PUSH1), 0x2, uint8_t(Instruction::PUSH1), 0x3, @@ -428,7 +428,7 @@ BOOST_AUTO_TEST_CASE(unary_operators) bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "y"}}); bytes expectation; - if (solidity::test::Options::get().optimize) + if (solidity::test::CommonOptions::get().optimize) expectation = { uint8_t(Instruction::DUP1), uint8_t(Instruction::PUSH1), 0x0, @@ -519,7 +519,7 @@ BOOST_AUTO_TEST_CASE(assignment) // Stack: a, b bytes expectation; - if (solidity::test::Options::get().optimize) + if (solidity::test::CommonOptions::get().optimize) expectation = { uint8_t(Instruction::DUP1), uint8_t(Instruction::DUP3), @@ -631,7 +631,7 @@ BOOST_AUTO_TEST_CASE(selfbalance) bytes code = compileFirstExpression(sourceCode, {}, {}); - if (solidity::test::Options::get().evmVersion() == EVMVersion::istanbul()) + if (solidity::test::CommonOptions::get().evmVersion() == EVMVersion::istanbul()) { bytes expectation({uint8_t(Instruction::SELFBALANCE)}); BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index e5e82d392..b19644a4c 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -22,7 +22,7 @@ #include -#include +#include #include @@ -361,7 +361,7 @@ BOOST_AUTO_TEST_CASE(dynamic_return_types_not_possible) } } )"; - if (solidity::test::Options::get().evmVersion() == EVMVersion::homestead()) + if (solidity::test::CommonOptions::get().evmVersion() == EVMVersion::homestead()) CHECK_ERROR(sourceCode, TypeError, "Type inaccessible dynamic type is not implicitly convertible to expected type string memory."); else CHECK_SUCCESS_NO_WARNINGS(sourceCode); @@ -386,7 +386,7 @@ BOOST_AUTO_TEST_CASE(returndatasize_as_variable) vector> expectations(vector>{ {Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"} }); - if (!solidity::test::Options::get().evmVersion().supportsReturndata()) + if (!solidity::test::CommonOptions::get().evmVersion().supportsReturndata()) expectations.emplace_back(make_pair(Error::Type::TypeError, std::string("\"returndatasize\" instruction is only available for Byzantium-compatible VMs"))); CHECK_ALLOW_MULTI(text, expectations); } @@ -401,7 +401,7 @@ BOOST_AUTO_TEST_CASE(create2_as_variable) vector> expectations(vector>{ {Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"} }); - if (!solidity::test::Options::get().evmVersion().hasCreate2()) + if (!solidity::test::CommonOptions::get().evmVersion().hasCreate2()) expectations.emplace_back(make_pair(Error::Type::TypeError, std::string("\"create2\" instruction is only available for Constantinople-compatible VMs"))); CHECK_ALLOW_MULTI(text, expectations); } @@ -416,7 +416,7 @@ BOOST_AUTO_TEST_CASE(extcodehash_as_variable) vector> expectations(vector>{ {Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"} }); - if (!solidity::test::Options::get().evmVersion().hasExtCodeHash()) + if (!solidity::test::CommonOptions::get().evmVersion().hasExtCodeHash()) expectations.emplace_back(make_pair(Error::Type::TypeError, std::string("\"extcodehash\" instruction is only available for Constantinople-compatible VMs"))); CHECK_ALLOW_MULTI(text, expectations); } @@ -452,7 +452,7 @@ BOOST_AUTO_TEST_CASE(address_staticcall) } )"; - if (solidity::test::Options::get().evmVersion().hasStaticCall()) + if (solidity::test::CommonOptions::get().evmVersion().hasStaticCall()) CHECK_SUCCESS_NO_WARNINGS(sourceCode); else CHECK_ERROR(sourceCode, TypeError, "\"staticcall\" is not supported by the VM version."); @@ -460,7 +460,7 @@ BOOST_AUTO_TEST_CASE(address_staticcall) BOOST_AUTO_TEST_CASE(address_staticcall_value) { - if (solidity::test::Options::get().evmVersion().hasStaticCall()) + if (solidity::test::CommonOptions::get().evmVersion().hasStaticCall()) { char const* sourceCode = R"( contract C { @@ -484,7 +484,7 @@ BOOST_AUTO_TEST_CASE(address_call_full_return_type) } )"; - if (solidity::test::Options::get().evmVersion().supportsReturndata()) + if (solidity::test::CommonOptions::get().evmVersion().supportsReturndata()) CHECK_SUCCESS_NO_WARNINGS(sourceCode); else CHECK_ERROR(sourceCode, TypeError, "Type inaccessible dynamic type is not implicitly convertible to expected type bytes memory."); @@ -501,7 +501,7 @@ BOOST_AUTO_TEST_CASE(address_delegatecall_full_return_type) } )"; - if (solidity::test::Options::get().evmVersion().supportsReturndata()) + if (solidity::test::CommonOptions::get().evmVersion().supportsReturndata()) CHECK_SUCCESS_NO_WARNINGS(sourceCode); else CHECK_ERROR(sourceCode, TypeError, "Type inaccessible dynamic type is not implicitly convertible to expected type bytes memory."); @@ -510,7 +510,7 @@ BOOST_AUTO_TEST_CASE(address_delegatecall_full_return_type) BOOST_AUTO_TEST_CASE(address_staticcall_full_return_type) { - if (solidity::test::Options::get().evmVersion().hasStaticCall()) + if (solidity::test::CommonOptions::get().evmVersion().hasStaticCall()) { char const* sourceCode = R"( contract C { diff --git a/test/libsolidity/SolidityNatspecJSON.cpp b/test/libsolidity/SolidityNatspecJSON.cpp index 24aec0547..13bd1f3b0 100644 --- a/test/libsolidity/SolidityNatspecJSON.cpp +++ b/test/libsolidity/SolidityNatspecJSON.cpp @@ -20,7 +20,7 @@ * Unit tests for the solidity compiler JSON Interface output. */ -#include +#include #include #include #include @@ -46,7 +46,7 @@ public: { m_compilerStack.reset(); m_compilerStack.setSources({{"", "pragma solidity >=0.0;\n" + _code}}); - m_compilerStack.setEVMVersion(solidity::test::Options::get().evmVersion()); + m_compilerStack.setEVMVersion(solidity::test::CommonOptions::get().evmVersion()); BOOST_REQUIRE_MESSAGE(m_compilerStack.parseAndAnalyze(), "Parsing contract failed"); Json::Value generatedDocumentation; @@ -67,7 +67,7 @@ public: { m_compilerStack.reset(); m_compilerStack.setSources({{"", "pragma solidity >=0.0;\n" + _code}}); - m_compilerStack.setEVMVersion(solidity::test::Options::get().evmVersion()); + m_compilerStack.setEVMVersion(solidity::test::CommonOptions::get().evmVersion()); BOOST_CHECK(!m_compilerStack.parseAndAnalyze()); BOOST_REQUIRE(Error::containsErrorOfType(m_compilerStack.errors(), Error::Type::DocstringParsingError)); } diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp index 58d1a0691..3087b4b0f 100644 --- a/test/libsolidity/SolidityParser.cpp +++ b/test/libsolidity/SolidityParser.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include @@ -44,7 +44,7 @@ ASTPointer parseText(std::string const& _source, ErrorList& ErrorReporter errorReporter(_errors); ASTPointer sourceUnit = Parser( errorReporter, - solidity::test::Options::get().evmVersion(), + solidity::test::CommonOptions::get().evmVersion(), errorRecovery ).parse(std::make_shared(CharStream(_source, ""))); if (!sourceUnit) diff --git a/test/libsolidity/SyntaxTest.cpp b/test/libsolidity/SyntaxTest.cpp index dc764c6b2..b28d6c9da 100644 --- a/test/libsolidity/SyntaxTest.cpp +++ b/test/libsolidity/SyntaxTest.cpp @@ -16,7 +16,7 @@ */ #include -#include +#include #include #include #include diff --git a/test/libsolidity/ViewPureChecker.cpp b/test/libsolidity/ViewPureChecker.cpp index a29d13525..3bde18d27 100644 --- a/test/libsolidity/ViewPureChecker.cpp +++ b/test/libsolidity/ViewPureChecker.cpp @@ -20,7 +20,7 @@ #include -#include +#include #include @@ -52,7 +52,7 @@ BOOST_AUTO_TEST_CASE(environment_access) "this", "address(1).balance", }; - if (solidity::test::Options::get().evmVersion().hasStaticCall()) + if (solidity::test::CommonOptions::get().evmVersion().hasStaticCall()) view.emplace_back("address(0x4242).staticcall(\"\")"); // ``block.blockhash`` and ``blockhash`` are tested separately below because their usage will @@ -105,7 +105,7 @@ BOOST_AUTO_TEST_CASE(address_staticcall) } } )"; - if (!solidity::test::Options::get().evmVersion().hasStaticCall()) + if (!solidity::test::CommonOptions::get().evmVersion().hasStaticCall()) CHECK_ERROR(text, TypeError, "\"staticcall\" is not supported by the VM version."); else CHECK_SUCCESS_NO_WARNINGS(text); @@ -121,7 +121,7 @@ BOOST_AUTO_TEST_CASE(assembly_staticcall) } } )"; - if (!solidity::test::Options::get().evmVersion().hasStaticCall()) + if (!solidity::test::CommonOptions::get().evmVersion().hasStaticCall()) CHECK_ERROR(text, TypeError, "\"staticcall\" instruction is only available for Byzantium-compatible"); else CHECK_SUCCESS_NO_WARNINGS(text); diff --git a/test/libsolidity/util/TestFileParser.cpp b/test/libsolidity/util/TestFileParser.cpp index 58314db26..4be96c88d 100644 --- a/test/libsolidity/util/TestFileParser.cpp +++ b/test/libsolidity/util/TestFileParser.cpp @@ -18,7 +18,7 @@ #include #include -#include +#include #include diff --git a/test/libsolutil/Checksum.cpp b/test/libsolutil/Checksum.cpp index bd6abad31..159c55efc 100644 --- a/test/libsolutil/Checksum.cpp +++ b/test/libsolutil/Checksum.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include #include diff --git a/test/libsolutil/CommonData.cpp b/test/libsolutil/CommonData.cpp index 5bd29c056..d8434c79d 100644 --- a/test/libsolutil/CommonData.cpp +++ b/test/libsolutil/CommonData.cpp @@ -23,7 +23,7 @@ #include #include // for IntegerType -#include +#include #include diff --git a/test/libsolutil/IndentedWriter.cpp b/test/libsolutil/IndentedWriter.cpp index fcdb096dd..3d0963e9f 100644 --- a/test/libsolutil/IndentedWriter.cpp +++ b/test/libsolutil/IndentedWriter.cpp @@ -20,7 +20,7 @@ #include -#include +#include #include diff --git a/test/libsolutil/IpfsHash.cpp b/test/libsolutil/IpfsHash.cpp index adaf30d61..4514b2f4c 100644 --- a/test/libsolutil/IpfsHash.cpp +++ b/test/libsolutil/IpfsHash.cpp @@ -20,7 +20,7 @@ #include -#include +#include #include diff --git a/test/libsolutil/IterateReplacing.cpp b/test/libsolutil/IterateReplacing.cpp index 3270baf47..d1598dbc3 100644 --- a/test/libsolutil/IterateReplacing.cpp +++ b/test/libsolutil/IterateReplacing.cpp @@ -20,7 +20,7 @@ #include -#include +#include #include diff --git a/test/libsolutil/JSON.cpp b/test/libsolutil/JSON.cpp index 32d41144a..e45c6fdec 100644 --- a/test/libsolutil/JSON.cpp +++ b/test/libsolutil/JSON.cpp @@ -21,7 +21,7 @@ #include -#include +#include #include diff --git a/test/libsolutil/StringUtils.cpp b/test/libsolutil/StringUtils.cpp index b2e1d5955..b7e653a0e 100644 --- a/test/libsolutil/StringUtils.cpp +++ b/test/libsolutil/StringUtils.cpp @@ -24,7 +24,7 @@ #include // for IntegerType -#include +#include #include diff --git a/test/libsolutil/SwarmHash.cpp b/test/libsolutil/SwarmHash.cpp index 1c2ff917e..a976bfccf 100644 --- a/test/libsolutil/SwarmHash.cpp +++ b/test/libsolutil/SwarmHash.cpp @@ -20,7 +20,7 @@ #include -#include +#include #include diff --git a/test/libsolutil/UTF8.cpp b/test/libsolutil/UTF8.cpp index 86ec4fe93..b3e969b9b 100644 --- a/test/libsolutil/UTF8.cpp +++ b/test/libsolutil/UTF8.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include #include diff --git a/test/libsolutil/Whiskers.cpp b/test/libsolutil/Whiskers.cpp index 11754711f..3f2a48733 100644 --- a/test/libsolutil/Whiskers.cpp +++ b/test/libsolutil/Whiskers.cpp @@ -20,7 +20,7 @@ #include -#include +#include #include diff --git a/test/libyul/Common.cpp b/test/libyul/Common.cpp index c80b09fa7..6ea2bb63a 100644 --- a/test/libyul/Common.cpp +++ b/test/libyul/Common.cpp @@ -21,7 +21,7 @@ #include -#include +#include #include @@ -48,7 +48,7 @@ namespace { Dialect const& defaultDialect(bool _yul) { - return _yul ? yul::Dialect::yul() : yul::EVMDialect::strictAssemblyForEVM(solidity::test::Options::get().evmVersion()); + return _yul ? yul::Dialect::yul() : yul::EVMDialect::strictAssemblyForEVM(solidity::test::CommonOptions::get().evmVersion()); } } @@ -64,9 +64,9 @@ void yul::test::printErrors(ErrorList const& _errors) pair, shared_ptr> yul::test::parse(string const& _source, bool _yul) { AssemblyStack stack( - solidity::test::Options::get().evmVersion(), + solidity::test::CommonOptions::get().evmVersion(), _yul ? AssemblyStack::Language::Yul : AssemblyStack::Language::StrictAssembly, - solidity::test::Options::get().optimize ? + solidity::test::CommonOptions::get().optimize ? solidity::frontend::OptimiserSettings::standard() : solidity::frontend::OptimiserSettings::minimal() ); diff --git a/test/libyul/CompilabilityChecker.cpp b/test/libyul/CompilabilityChecker.cpp index 23fa82cd7..51aefc610 100644 --- a/test/libyul/CompilabilityChecker.cpp +++ b/test/libyul/CompilabilityChecker.cpp @@ -18,7 +18,7 @@ * Unit tests for the compilability checker. */ -#include +#include #include #include @@ -39,7 +39,7 @@ string check(string const& _input) Object obj; std::tie(obj.code, obj.analysisInfo) = yul::test::parse(_input, false); BOOST_REQUIRE(obj.code); - map functions = CompilabilityChecker::run(EVMDialect::strictAssemblyForEVM(solidity::test::Options::get().evmVersion()), obj, true); + map functions = CompilabilityChecker::run(EVMDialect::strictAssemblyForEVM(solidity::test::CommonOptions::get().evmVersion()), obj, true); string out; for (auto const& function: functions) out += function.first.str() + ": " + to_string(function.second) + " "; diff --git a/test/libyul/EwasmTranslationTest.cpp b/test/libyul/EwasmTranslationTest.cpp index a5e01d286..fdee56bda 100644 --- a/test/libyul/EwasmTranslationTest.cpp +++ b/test/libyul/EwasmTranslationTest.cpp @@ -19,7 +19,7 @@ #include -#include +#include #include #include @@ -67,7 +67,7 @@ TestCase::TestResult EwasmTranslationTest::run(ostream& _stream, string const& _ return TestResult::FatalError; *m_object = EVMToEwasmTranslator( - EVMDialect::strictAssemblyForEVMObjects(solidity::test::Options::get().evmVersion()) + EVMDialect::strictAssemblyForEVMObjects(solidity::test::CommonOptions::get().evmVersion()) ).run(*m_object); // Add call to "main()". @@ -111,7 +111,7 @@ void EwasmTranslationTest::printIndented(ostream& _stream, string const& _output bool EwasmTranslationTest::parse(ostream& _stream, string const& _linePrefix, bool const _formatted) { AssemblyStack stack( - solidity::test::Options::get().evmVersion(), + solidity::test::CommonOptions::get().evmVersion(), AssemblyStack::Language::StrictAssembly, solidity::frontend::OptimiserSettings::none() ); diff --git a/test/libyul/FunctionSideEffects.cpp b/test/libyul/FunctionSideEffects.cpp index d7a184dc4..257faab22 100644 --- a/test/libyul/FunctionSideEffects.cpp +++ b/test/libyul/FunctionSideEffects.cpp @@ -16,7 +16,7 @@ */ #include -#include +#include #include #include diff --git a/test/libyul/Metrics.cpp b/test/libyul/Metrics.cpp index 7d1abee58..1841abc67 100644 --- a/test/libyul/Metrics.cpp +++ b/test/libyul/Metrics.cpp @@ -18,7 +18,7 @@ * Unit tests for the code metrics. */ -#include +#include #include diff --git a/test/libyul/ObjectParser.cpp b/test/libyul/ObjectParser.cpp index c8756eafb..2d932006e 100644 --- a/test/libyul/ObjectParser.cpp +++ b/test/libyul/ObjectParser.cpp @@ -19,7 +19,7 @@ * Unit tests for the Yul object parser. */ -#include +#include #include @@ -49,7 +49,7 @@ std::pair parse(string const& _source) try { AssemblyStack asmStack( - solidity::test::Options::get().evmVersion(), + solidity::test::CommonOptions::get().evmVersion(), AssemblyStack::Language::StrictAssembly, solidity::frontend::OptimiserSettings::none() ); @@ -240,7 +240,7 @@ BOOST_AUTO_TEST_CASE(to_string) )"; expectation = boost::replace_all_copy(expectation, "\t", " "); AssemblyStack asmStack( - solidity::test::Options::get().evmVersion(), + solidity::test::CommonOptions::get().evmVersion(), AssemblyStack::Language::StrictAssembly, solidity::frontend::OptimiserSettings::none() ); diff --git a/test/libyul/Parser.cpp b/test/libyul/Parser.cpp index e278383a5..95f7dd38f 100644 --- a/test/libyul/Parser.cpp +++ b/test/libyul/Parser.cpp @@ -19,7 +19,7 @@ * Unit tests for parsing Yul. */ -#include +#include #include #include diff --git a/test/libyul/StackReuseCodegen.cpp b/test/libyul/StackReuseCodegen.cpp index b9d333484..5103befb0 100644 --- a/test/libyul/StackReuseCodegen.cpp +++ b/test/libyul/StackReuseCodegen.cpp @@ -18,7 +18,7 @@ * Unit tests for stack-reusing code generator. */ -#include +#include #include #include diff --git a/test/libyul/YulInterpreterTest.cpp b/test/libyul/YulInterpreterTest.cpp index 939fa2e1e..f37d18383 100644 --- a/test/libyul/YulInterpreterTest.cpp +++ b/test/libyul/YulInterpreterTest.cpp @@ -19,7 +19,7 @@ #include -#include +#include #include #include @@ -99,7 +99,7 @@ void YulInterpreterTest::printIndented(ostream& _stream, string const& _output, bool YulInterpreterTest::parse(ostream& _stream, string const& _linePrefix, bool const _formatted) { AssemblyStack stack( - solidity::test::Options::get().evmVersion(), + solidity::test::CommonOptions::get().evmVersion(), AssemblyStack::Language::StrictAssembly, solidity::frontend::OptimiserSettings::none() ); diff --git a/test/libyul/YulOptimizerTest.cpp b/test/libyul/YulOptimizerTest.cpp index 791551bc6..609473acc 100644 --- a/test/libyul/YulOptimizerTest.cpp +++ b/test/libyul/YulOptimizerTest.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include @@ -109,7 +109,7 @@ YulOptimizerTest::YulOptimizerTest(string const& _filename) else if (dialectName == "ewasm") m_dialect = &WasmDialect::instance(); else if (dialectName == "evm") - m_dialect = &EVMDialect::strictAssemblyForEVMObjects(solidity::test::Options::get().evmVersion()); + m_dialect = &EVMDialect::strictAssemblyForEVMObjects(solidity::test::CommonOptions::get().evmVersion()); else BOOST_THROW_EXCEPTION(runtime_error("Invalid dialect " + dialectName)); @@ -117,7 +117,7 @@ YulOptimizerTest::YulOptimizerTest(string const& _filename) m_settings.erase("dialect"); } else - m_dialect = &EVMDialect::strictAssemblyForEVMObjects(solidity::test::Options::get().evmVersion()); + m_dialect = &EVMDialect::strictAssemblyForEVMObjects(solidity::test::CommonOptions::get().evmVersion()); if (m_settings.count("step")) { diff --git a/test/tools/CMakeLists.txt b/test/tools/CMakeLists.txt index 69db42107..9fabfae68 100644 --- a/test/tools/CMakeLists.txt +++ b/test/tools/CMakeLists.txt @@ -13,7 +13,6 @@ target_link_libraries(yulopti PRIVATE solidity Boost::boost Boost::program_optio add_executable(isoltest isoltest.cpp IsolTestOptions.cpp - ../Options.cpp ../Common.cpp ../EVMHost.cpp ../TestCase.cpp diff --git a/test/tools/isoltest.cpp b/test/tools/isoltest.cpp index d96091dcb..a8c8748fb 100644 --- a/test/tools/isoltest.cpp +++ b/test/tools/isoltest.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -401,20 +402,25 @@ int main(int argc, char const *argv[]) { setupTerminal(); - solidity::test::IsolTestOptions options(&TestTool::editor); + { + auto options = std::make_unique(&TestTool::editor); - try - { - if (options.parse(argc, argv)) - options.validate(); - else + try + { + if (!options->parse(argc, argv)) + return -1; + + options->validate(); + solidity::test::CommonOptions::setSingleton(std::move(options)); + } + catch (std::exception const& _exception) + { + cerr << _exception.what() << endl; return 1; + } } - catch (std::exception const& _exception) - { - cerr << _exception.what() << endl; - return 1; - } + + auto& options = dynamic_cast(solidity::test::CommonOptions::get()); bool disableSemantics = !solidity::test::EVMHost::getVM(options.evmonePath.string()); if (disableSemantics)