TestFramework: Merge Options.h into Common.h

This commit is contained in:
Mathias Baumann 2020-01-14 17:48:17 +01:00
parent 2f1f8e25c1
commit 00e4d13975
61 changed files with 244 additions and 301 deletions

View File

@ -9,8 +9,6 @@ set(sources
InteractiveTests.h InteractiveTests.h
Metadata.cpp Metadata.cpp
Metadata.h Metadata.h
Options.cpp
Options.h
TestCase.cpp TestCase.cpp
TestCase.h TestCase.h
) )

View File

@ -15,6 +15,7 @@
along with solidity. If not, see <http://www.gnu.org/licenses/>. along with solidity. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <stdexcept>
#include <test/Common.h> #include <test/Common.h>
#include <libsolutil/Assertions.h> #include <libsolutil/Assertions.h>
@ -91,7 +92,11 @@ CommonOptions::CommonOptions(std::string _caption):
("evm-version", po::value(&evmVersionString), "which evm version to use") ("evm-version", po::value(&evmVersionString), "which evm version to use")
("testpath", po::value<fs::path>(&this->testPath)->default_value(solidity::test::testPath()), "path to test files") ("testpath", po::value<fs::path>(&this->testPath)->default_value(solidity::test::testPath()), "path to test files")
("evmonepath", po::value<fs::path>(&evmonePath)->default_value(EVMOneEnvOrDefaultPath()), "path to evmone library") ("evmonepath", po::value<fs::path>(&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 void CommonOptions::validate() const
@ -151,4 +156,20 @@ langutil::EVMVersion CommonOptions::evmVersion() const
return langutil::EVMVersion(); 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<CommonOptions const>&& _instance)
{
m_singleton = std::move(_instance);
}
std::unique_ptr<CommonOptions const> CommonOptions::m_singleton = nullptr;
} }

View File

@ -21,8 +21,8 @@
#include <liblangutil/EVMVersion.h> #include <liblangutil/EVMVersion.h>
#include <boost/filesystem/path.hpp> #include <boost/filesystem/path.hpp>
#include <boost/program_options.hpp>
#include <boost/noncopyable.hpp> #include <boost/noncopyable.hpp>
#include <boost/program_options.hpp>
namespace solidity::test namespace solidity::test
{ {
@ -48,6 +48,8 @@ struct CommonOptions: boost::noncopyable
bool optimize = false; bool optimize = false;
bool optimizeYul = false; bool optimizeYul = false;
bool disableSMT = false; bool disableSMT = false;
bool useABIEncoderV2 = false;
bool showMessages = false;
langutil::EVMVersion evmVersion() const; langutil::EVMVersion evmVersion() const;
@ -55,13 +57,18 @@ struct CommonOptions: boost::noncopyable
// Throws a ConfigException on error // Throws a ConfigException on error
virtual void validate() const; virtual void validate() const;
protected: static CommonOptions const& get();
static void setSingleton(std::unique_ptr<CommonOptions const>&& _instance);
CommonOptions(std::string caption = ""); CommonOptions(std::string caption = "");
virtual ~CommonOptions() {};
protected:
boost::program_options::options_description options; boost::program_options::options_description options;
private: private:
std::string evmVersionString; std::string evmVersionString;
static std::unique_ptr<CommonOptions const> m_singleton;
}; };
} }

View File

@ -39,19 +39,19 @@ using namespace solidity::util;
using namespace solidity::test; using namespace solidity::test;
ExecutionFramework::ExecutionFramework(): ExecutionFramework::ExecutionFramework():
ExecutionFramework(solidity::test::Options::get().evmVersion()) ExecutionFramework(solidity::test::CommonOptions::get().evmVersion())
{ {
} }
ExecutionFramework::ExecutionFramework(langutil::EVMVersion _evmVersion): ExecutionFramework::ExecutionFramework(langutil::EVMVersion _evmVersion):
m_evmVersion(_evmVersion), m_evmVersion(_evmVersion),
m_optimiserSettings(solidity::frontend::OptimiserSettings::minimal()), m_optimiserSettings(solidity::frontend::OptimiserSettings::minimal()),
m_showMessages(solidity::test::Options::get().showMessages), m_showMessages(solidity::test::CommonOptions::get().showMessages),
m_evmHost(make_shared<EVMHost>(m_evmVersion)) m_evmHost(make_shared<EVMHost>(m_evmVersion))
{ {
if (solidity::test::Options::get().optimizeYul) if (solidity::test::CommonOptions::get().optimizeYul)
m_optimiserSettings = solidity::frontend::OptimiserSettings::full(); 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_optimiserSettings = solidity::frontend::OptimiserSettings::standard();
m_evmHost->reset(); m_evmHost->reset();

View File

@ -22,7 +22,7 @@
#pragma once #pragma once
#include <test/Options.h> #include <test/Common.h>
#include <libsolidity/interface/OptimiserSettings.h> #include <libsolidity/interface/OptimiserSettings.h>
#include <libsolidity/interface/DebugSettings.h> #include <libsolidity/interface/DebugSettings.h>

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
/** @file TestHelper.h
* @author Marko Simovic <markobarko@gmail.com>
* @date 2014
*/
#include <test/Options.h>
#include <test/Common.h>
#include <liblangutil/EVMVersion.h>
#include <liblangutil/Exceptions.h>
#include <boost/test/framework.hpp>
#include <boost/filesystem.hpp>
#include <boost/program_options.hpp>
#include <boost/test/unit_test.hpp>
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);
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <test/Common.h>
#include <functional>
namespace solidity::test
{
struct Options: CommonOptions
{
bool showMessages = false;
bool useABIEncoderV2 = false;
static Options const& get();
private:
Options();
};
}

View File

@ -36,7 +36,7 @@
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#include <test/InteractiveTests.h> #include <test/InteractiveTests.h>
#include <test/Options.h> #include <test/Common.h>
#include <test/EVMHost.h> #include <test/EVMHost.h>
#include <test/Common.h> #include <test/Common.h>
@ -69,7 +69,7 @@ int registerTests(
{ {
int numTestsAdded = 0; int numTestsAdded = 0;
fs::path fullpath = _basepath / _path; 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)) if (fs::is_directory(fullpath))
{ {
test_suite* sub_suite = BOOST_TEST_SUITE(_path.filename().string()); test_suite* sub_suite = BOOST_TEST_SUITE(_path.filename().string());
@ -94,7 +94,7 @@ int registerTests(
{ {
stringstream errorStream; stringstream errorStream;
auto testCase = _testCaseCreator(config); auto testCase = _testCaseCreator(config);
if (testCase->validateSettings(solidity::test::Options::get().evmVersion())) if (testCase->validateSettings(solidity::test::CommonOptions::get().evmVersion()))
switch (testCase->run(errorStream)) switch (testCase->run(errorStream))
{ {
case TestCase::TestResult::Success: case TestCase::TestResult::Success:
@ -121,15 +121,27 @@ int registerTests(
} }
return numTestsAdded; return numTestsAdded;
} }
void initializeOptions()
{
auto const& suite = boost::unit_test::framework::master_test_suite();
auto options = std::make_unique<solidity::test::CommonOptions>();
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*/[] ) test_suite* init_unit_test_suite( int /*argc*/, char* /*argv*/[] )
{ {
master_test_suite_t& master = framework::master_test_suite(); master_test_suite_t& master = framework::master_test_suite();
master.p_name.value = "SolidityTests"; 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) if (disableSemantics)
{ {
cout << "Unable to find " << solidity::test::evmoneFilename << ". Please provide the path using -- --evmonepath <path>." << endl; cout << "Unable to find " << solidity::test::evmoneFilename << ". Please provide the path using -- --evmonepath <path>." << 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 // Include the interactive tests in the automatic tests as well
for (auto const& ts: g_interactiveTestsuites) 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) if (ts.smt && options.disableSMT)
continue; continue;
@ -172,7 +184,7 @@ test_suite* init_unit_test_suite( int /*argc*/, char* /*argv*/[] )
removeTestSuite(suite); removeTestSuite(suite);
} }
if (solidity::test::Options::get().disableSMT) if (solidity::test::CommonOptions::get().disableSMT)
removeTestSuite("SMTChecker"); removeTestSuite("SMTChecker");
return 0; return 0;

View File

@ -464,7 +464,7 @@ BOOST_AUTO_TEST_CASE(creation)
{ {
deployWallet(200); deployWallet(200);
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(m_sender, h256::AlignRight)) == encodeArgs(true)); 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))); BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(~0)) == (v2 ? encodeArgs() : encodeArgs(false)));
} }

View File

@ -20,7 +20,7 @@
* Tests for the Solidity optimizer. * Tests for the Solidity optimizer.
*/ */
#include <test/Options.h> #include <test/Common.h>
#include <libevmasm/CommonSubexpressionEliminator.h> #include <libevmasm/CommonSubexpressionEliminator.h>
#include <libevmasm/PeepholeOptimiser.h> #include <libevmasm/PeepholeOptimiser.h>
@ -236,7 +236,7 @@ BOOST_AUTO_TEST_CASE(cse_associativity2)
BOOST_AUTO_TEST_CASE(cse_double_shift_right_overflow) 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{ AssemblyItems input{
Instruction::CALLVALUE, Instruction::CALLVALUE,
@ -251,7 +251,7 @@ BOOST_AUTO_TEST_CASE(cse_double_shift_right_overflow)
BOOST_AUTO_TEST_CASE(cse_double_shift_left_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{ AssemblyItems input{
Instruction::DUP1, Instruction::DUP1,
@ -1132,7 +1132,7 @@ BOOST_AUTO_TEST_CASE(jumpdest_removal_subassemblies)
main.append(t1.toSubAssemblyTag(subId)); main.append(t1.toSubAssemblyTag(subId));
main.append(u256(8)); 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{ AssemblyItems expectationMain{
AssemblyItem(PushSubSize, 0), AssemblyItem(PushSubSize, 0),
@ -1178,7 +1178,7 @@ BOOST_AUTO_TEST_CASE(cse_sub_zero)
BOOST_AUTO_TEST_CASE(cse_remove_redundant_shift_masking) BOOST_AUTO_TEST_CASE(cse_remove_redundant_shift_masking)
{ {
if (!solidity::test::Options::get().evmVersion().hasBitwiseShifting()) if (!solidity::test::CommonOptions::get().evmVersion().hasBitwiseShifting())
return; return;
for (int i = 1; i < 256; i++) 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) BOOST_AUTO_TEST_CASE(cse_replace_too_large_shift)
{ {
if (!solidity::test::Options::get().evmVersion().hasBitwiseShifting()) if (!solidity::test::CommonOptions::get().evmVersion().hasBitwiseShifting())
return; return;
checkCSE({ checkCSE({

View File

@ -23,7 +23,7 @@
#include <liblangutil/CharStream.h> #include <liblangutil/CharStream.h>
#include <liblangutil/Exceptions.h> #include <liblangutil/Exceptions.h>
#include <test/Options.h> #include <test/Common.h>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>

View File

@ -22,7 +22,7 @@
#include <liblangutil/SourceLocation.h> #include <liblangutil/SourceLocation.h>
#include <test/Options.h> #include <test/Common.h>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>

View File

@ -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( BOTH_ENCODERS(
compileAndRun(sourceCode); compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("f(uint8)", 0), encodeArgs(u256(0))); 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( BOTH_ENCODERS(
compileAndRun(sourceCode); compileAndRun(sourceCode);
ABI_CHECK( 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; } 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 validFun{"01234567890123456789abcd"};
string invalidFun{"01234567890123456789abcdX"}; string invalidFun{"01234567890123456789abcdX"};
BOTH_ENCODERS( 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; } 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( BOTH_ENCODERS(
compileAndRun(sourceCode); compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("f(bool)", true), encodeArgs(true)); ABI_CHECK(callContractFunction("f(bool)", true), encodeArgs(true));

View File

@ -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); compileAndRun(sourceCode);
callContractFunction("f()"); 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( NEW_ENCODER(
compileAndRun(sourceCode, 0, "D"); compileAndRun(sourceCode, 0, "D");

View File

@ -20,7 +20,7 @@
#include <test/libsolidity/ABIJsonTest.h> #include <test/libsolidity/ABIJsonTest.h>
#include <test/Options.h> #include <test/Common.h>
#include <libsolidity/interface/CompilerStack.h> #include <libsolidity/interface/CompilerStack.h>
#include <libsolutil/JSON.h> #include <libsolutil/JSON.h>
@ -52,8 +52,8 @@ TestCase::TestResult ABIJsonTest::run(ostream& _stream, string const& _linePrefi
CompilerStack compiler; CompilerStack compiler;
compiler.setSources({{"", "pragma solidity >=0.0;\n" + m_source}}); compiler.setSources({{"", "pragma solidity >=0.0;\n" + m_source}});
compiler.setEVMVersion(solidity::test::Options::get().evmVersion()); compiler.setEVMVersion(solidity::test::CommonOptions::get().evmVersion());
compiler.setOptimiserSettings(solidity::test::Options::get().optimize); compiler.setOptimiserSettings(solidity::test::CommonOptions::get().optimize);
if (!compiler.parseAndAnalyze()) if (!compiler.parseAndAnalyze())
BOOST_THROW_EXCEPTION(runtime_error("Parsing contract failed")); BOOST_THROW_EXCEPTION(runtime_error("Parsing contract failed"));

View File

@ -17,7 +17,7 @@
#include <boost/algorithm/string/replace.hpp> #include <boost/algorithm/string/replace.hpp>
#include <test/libsolidity/ASTJSONTest.h> #include <test/libsolidity/ASTJSONTest.h>
#include <test/Options.h> #include <test/Common.h>
#include <libsolutil/AnsiColorized.h> #include <libsolutil/AnsiColorized.h>
#include <liblangutil/SourceReferenceFormatterHuman.h> #include <liblangutil/SourceReferenceFormatterHuman.h>
#include <libsolidity/ast/ASTJsonConverter.h> #include <libsolidity/ast/ASTJsonConverter.h>
@ -47,7 +47,7 @@ void replaceVersionWithTag(string& _input)
{ {
boost::algorithm::replace_all( boost::algorithm::replace_all(
_input, _input,
"\"" + solidity::test::Options::get().evmVersion().name() + "\"", "\"" + solidity::test::CommonOptions::get().evmVersion().name() + "\"",
"%EVMVERSION%" "%EVMVERSION%"
); );
} }
@ -57,7 +57,7 @@ void replaceTagWithVersion(string& _input)
boost::algorithm::replace_all( boost::algorithm::replace_all(
_input, _input,
"%EVMVERSION%", "%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; sourceIndices[m_sources[i].first] = i + 1;
} }
c.setSources(sources); c.setSources(sources);
c.setEVMVersion(solidity::test::Options::get().evmVersion()); c.setEVMVersion(solidity::test::CommonOptions::get().evmVersion());
if (c.parse()) if (c.parse())
c.analyze(); c.analyze();
else else

View File

@ -20,7 +20,7 @@
#include <test/libsolidity/AnalysisFramework.h> #include <test/libsolidity/AnalysisFramework.h>
#include <test/Options.h> #include <test/Common.h>
#include <libsolidity/interface/CompilerStack.h> #include <libsolidity/interface/CompilerStack.h>
#include <liblangutil/SourceReferenceFormatter.h> #include <liblangutil/SourceReferenceFormatter.h>
@ -51,7 +51,7 @@ AnalysisFramework::parseAnalyseAndReturnError(
{ {
compiler().reset(); compiler().reset();
compiler().setSources({{"", _insertVersionPragma ? "pragma solidity >=0.0;\n" + _source : _source}}); 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); compiler().setParserErrorRecovery(_allowRecoveryErrors);
_allowMultipleErrors = _allowMultipleErrors || _allowRecoveryErrors; _allowMultipleErrors = _allowMultipleErrors || _allowRecoveryErrors;
if (!compiler().parse()) if (!compiler().parse())

View File

@ -20,7 +20,7 @@
* Unit tests for Assembly Items from evmasm/Assembly.h * Unit tests for Assembly Items from evmasm/Assembly.h
*/ */
#include <test/Options.h> #include <test/Common.h>
#include <liblangutil/SourceLocation.h> #include <liblangutil/SourceLocation.h>
#include <libevmasm/Assembly.h> #include <libevmasm/Assembly.h>
@ -52,14 +52,14 @@ evmasm::AssemblyItems compileContract(std::shared_ptr<CharStream> _sourceCode)
{ {
ErrorList errors; ErrorList errors;
ErrorReporter errorReporter(errors); ErrorReporter errorReporter(errors);
Parser parser(errorReporter, solidity::test::Options::get().evmVersion()); Parser parser(errorReporter, solidity::test::CommonOptions::get().evmVersion());
ASTPointer<SourceUnit> sourceUnit; ASTPointer<SourceUnit> sourceUnit;
BOOST_REQUIRE_NO_THROW(sourceUnit = parser.parse(make_shared<Scanner>(_sourceCode))); BOOST_REQUIRE_NO_THROW(sourceUnit = parser.parse(make_shared<Scanner>(_sourceCode)));
BOOST_CHECK(!!sourceUnit); BOOST_CHECK(!!sourceUnit);
map<ASTNode const*, shared_ptr<DeclarationContainer>> scopes; map<ASTNode const*, shared_ptr<DeclarationContainer>> scopes;
GlobalContext globalContext; 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()), ""); solAssert(Error::containsOnlyWarnings(errorReporter.errors()), "");
resolver.registerDeclarations(*sourceUnit); resolver.registerDeclarations(*sourceUnit);
for (ASTPointer<ASTNode> const& node: sourceUnit->nodes()) for (ASTPointer<ASTNode> const& node: sourceUnit->nodes())
@ -72,7 +72,7 @@ evmasm::AssemblyItems compileContract(std::shared_ptr<CharStream> _sourceCode)
for (ASTPointer<ASTNode> const& node: sourceUnit->nodes()) for (ASTPointer<ASTNode> const& node: sourceUnit->nodes())
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get())) if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(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)); BOOST_REQUIRE_NO_THROW(checker.checkTypeRequirements(*contract));
if (!Error::containsOnlyWarnings(errorReporter.errors())) if (!Error::containsOnlyWarnings(errorReporter.errors()))
return AssemblyItems(); return AssemblyItems();
@ -81,9 +81,9 @@ evmasm::AssemblyItems compileContract(std::shared_ptr<CharStream> _sourceCode)
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get())) if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
{ {
Compiler compiler( Compiler compiler(
solidity::test::Options::get().evmVersion(), solidity::test::CommonOptions::get().evmVersion(),
RevertStrings::Default, RevertStrings::Default,
solidity::test::Options::get().optimize ? OptimiserSettings::standard() : OptimiserSettings::minimal() solidity::test::CommonOptions::get().optimize ? OptimiserSettings::standard() : OptimiserSettings::minimal()
); );
compiler.compileContract(*contract, map<ContractDefinition const*, shared_ptr<Compiler const>>{}, bytes()); compiler.compileContract(*contract, map<ContractDefinition const*, shared_ptr<Compiler const>>{}, bytes());
@ -161,12 +161,12 @@ BOOST_AUTO_TEST_CASE(location_test)
} }
)", ""); )", "");
AssemblyItems items = compileContract(sourceCode); AssemblyItems items = compileContract(sourceCode);
bool hasShifts = solidity::test::Options::get().evmVersion().hasBitwiseShifting(); bool hasShifts = solidity::test::CommonOptions::get().evmVersion().hasBitwiseShifting();
auto codegenCharStream = make_shared<CharStream>("", "--CODEGEN--"); auto codegenCharStream = make_shared<CharStream>("", "--CODEGEN--");
vector<SourceLocation> locations; vector<SourceLocation> locations;
if (solidity::test::Options::get().optimize) if (solidity::test::CommonOptions::get().optimize)
locations = locations =
vector<SourceLocation>(4, SourceLocation{2, 82, sourceCode}) + vector<SourceLocation>(4, SourceLocation{2, 82, sourceCode}) +
vector<SourceLocation>(1, SourceLocation{8, 17, codegenCharStream}) + vector<SourceLocation>(1, SourceLocation{8, 17, codegenCharStream}) +

View File

@ -93,14 +93,14 @@ BOOST_AUTO_TEST_CASE(string_storage)
m_compiler.overwriteReleaseFlag(true); m_compiler.overwriteReleaseFlag(true);
compileAndRun(sourceCode); compileAndRun(sourceCode);
auto evmVersion = solidity::test::Options::get().evmVersion(); auto evmVersion = solidity::test::CommonOptions::get().evmVersion();
if (evmVersion <= EVMVersion::byzantium()) if (evmVersion <= EVMVersion::byzantium())
CHECK_DEPLOY_GAS(134209, 130895, evmVersion); CHECK_DEPLOY_GAS(134209, 130895, evmVersion);
// This is only correct on >=Constantinople. // 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. // Costs with 0 are cases which cannot be triggered in tests.
if (evmVersion < EVMVersion::istanbul()) if (evmVersion < EVMVersion::istanbul())
@ -127,9 +127,9 @@ BOOST_AUTO_TEST_CASE(string_storage)
if (evmVersion == EVMVersion::byzantium()) if (evmVersion == EVMVersion::byzantium())
CHECK_GAS(21545, 21526, 20); CHECK_GAS(21545, 21526, 20);
// This is only correct on >=Constantinople. // 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()) if (evmVersion < EVMVersion::istanbul())
CHECK_GAS(0, 21567, 20); CHECK_GAS(0, 21567, 20);

View File

@ -44,7 +44,7 @@ public:
{ {
m_compiler.reset(); m_compiler.reset();
m_compiler.setSources({{"", "pragma solidity >=0.0;\n" + _sourceCode}}); 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); m_compiler.setEVMVersion(m_evmVersion);
BOOST_REQUIRE_MESSAGE(m_compiler.compile(), "Compiling contract failed"); BOOST_REQUIRE_MESSAGE(m_compiler.compile(), "Compiling contract failed");
@ -52,7 +52,7 @@ public:
ASTNode const& sourceUnit = m_compiler.ast(""); ASTNode const& sourceUnit = m_compiler.ast("");
BOOST_REQUIRE(items != nullptr); BOOST_REQUIRE(items != nullptr);
m_gasCosts = GasEstimator::breakToStatementLevel( m_gasCosts = GasEstimator::breakToStatementLevel(
GasEstimator(solidity::test::Options::get().evmVersion()).structuralEstimation(*items, vector<ASTNode const*>({&sourceUnit})), GasEstimator(solidity::test::CommonOptions::get().evmVersion()).structuralEstimation(*items, vector<ASTNode const*>({&sourceUnit})),
{&sourceUnit} {&sourceUnit}
); );
} }
@ -61,7 +61,7 @@ public:
{ {
compileAndRun(_sourceCode); compileAndRun(_sourceCode);
auto state = make_shared<KnownState>(); auto state = make_shared<KnownState>();
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); GasMeter::GasConsumption gas = meter.estimateMax(0, state);
u256 bytecodeSize(m_compiler.runtimeObject(m_compiler.lastContractName()).bytecode.size()); u256 bytecodeSize(m_compiler.runtimeObject(m_compiler.lastContractName()).bytecode.size());
// costs for deployment // costs for deployment
@ -71,7 +71,7 @@ public:
// Skip the tests when we force ABIEncoderV2. // Skip the tests when we force ABIEncoderV2.
// TODO: We should enable this again once the yul optimizer is activated. // 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_REQUIRE(!gas.isInfinite);
BOOST_CHECK_LE(m_gasUsed, gas.value); BOOST_CHECK_LE(m_gasUsed, gas.value);
@ -94,13 +94,13 @@ public:
gas = max(gas, gasForTransaction(hash.asBytes() + arguments, false)); 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()), *m_compiler.runtimeAssemblyItems(m_compiler.lastContractName()),
_sig _sig
); );
// Skip the tests when we force ABIEncoderV2. // Skip the tests when we force ABIEncoderV2.
// TODO: We should enable this again once the yul optimizer is activated. // 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_REQUIRE(!gas.isInfinite);
BOOST_CHECK_LE(m_gasUsed, gas.value); BOOST_CHECK_LE(m_gasUsed, gas.value);
@ -110,7 +110,7 @@ public:
static GasMeter::GasConsumption gasForTransaction(bytes const& _data, bool _isCreation) 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; GasMeter::GasConsumption gas = _isCreation ? GasCosts::txCreateGas : GasCosts::txGas;
for (auto i: _data) for (auto i: _data)
gas += i != 0 ? GasCosts::txDataNonZeroGas(evmVersion) : GasCosts::txDataZeroGas; gas += i != 0 ? GasCosts::txDataNonZeroGas(evmVersion) : GasCosts::txDataZeroGas;

View File

@ -16,7 +16,7 @@
*/ */
#include <test/libsolidity/GasTest.h> #include <test/libsolidity/GasTest.h>
#include <test/Options.h> #include <test/Common.h>
#include <libsolutil/CommonIO.h> #include <libsolutil/CommonIO.h>
#include <libsolutil/JSON.h> #include <libsolutil/JSON.h>
#include <liblangutil/SourceReferenceFormatterHuman.h> #include <liblangutil/SourceReferenceFormatterHuman.h>

View File

@ -21,7 +21,7 @@
*/ */
#include <test/libsolidity/ErrorCheck.h> #include <test/libsolidity/ErrorCheck.h>
#include <test/Options.h> #include <test/Common.h>
#include <liblangutil/Exceptions.h> #include <liblangutil/Exceptions.h>
#include <libsolidity/interface/CompilerStack.h> #include <libsolidity/interface/CompilerStack.h>
@ -47,7 +47,7 @@ BOOST_AUTO_TEST_CASE(remappings)
{"s_1.4.6/s.sol", "contract S {} pragma solidity >=0.0;"}, {"s_1.4.6/s.sol", "contract S {} pragma solidity >=0.0;"},
{"Tee/tee.sol", "contract Tee {} 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()); 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.6/s.sol", "contract SSix {} pragma solidity >=0.0;"},
{"s_1.4.7/s.sol", "contract SSeven {} 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()); 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_1.0.0/foo.sol", "contract Foo1 {} pragma solidity >=0.0;"},
{"vendor/foo_2.0.0/foo.sol", "contract Foo2 {} 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()); 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;"}, {"d/z.sol", "contract D {} pragma solidity >=0.0;"},
{"e/y/z/z.sol", "contract E {} 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()); 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;"}, {"d/z.sol", "contract D {} pragma solidity >=0.0;"},
{"e/y/z/z.sol", "contract E {} 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()); BOOST_CHECK(c.compile());
} }

View File

@ -20,7 +20,7 @@
* Unit tests for inline assembly. * Unit tests for inline assembly.
*/ */
#include <test/Options.h> #include <test/Common.h>
#include <test/libsolidity/ErrorCheck.h> #include <test/libsolidity/ErrorCheck.h>
@ -59,7 +59,7 @@ std::optional<Error> parseAndReturnFirstError(
AssemblyStack::Machine _machine = AssemblyStack::Machine::EVM 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; bool success = false;
try try
{ {
@ -126,7 +126,7 @@ Error expectError(
void parsePrintCompare(string const& _source, bool _canWarn = false) 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)); BOOST_REQUIRE(stack.parseAndAnalyze("", _source));
if (_canWarn) if (_canWarn)
BOOST_REQUIRE(Error::containsOnlyWarnings(stack.errors())); BOOST_REQUIRE(Error::containsOnlyWarnings(stack.errors()));
@ -539,7 +539,7 @@ BOOST_AUTO_TEST_CASE(print_string_literal_unicode)
{ {
string source = "{ let x := \"\\u1bac\" }"; string source = "{ let x := \"\\u1bac\" }";
string parsed = "object \"object\" {\n code { let x := \"\\xe1\\xae\\xac\" }\n}\n"; 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.parseAndAnalyze("", source));
BOOST_REQUIRE(stack.errors().empty()); BOOST_REQUIRE(stack.errors().empty());
BOOST_CHECK_EQUAL(stack.print(), parsed); BOOST_CHECK_EQUAL(stack.print(), parsed);
@ -686,42 +686,42 @@ BOOST_AUTO_TEST_CASE(keccak256)
BOOST_AUTO_TEST_CASE(returndatasize) BOOST_AUTO_TEST_CASE(returndatasize)
{ {
if (!solidity::test::Options::get().evmVersion().supportsReturndata()) if (!solidity::test::CommonOptions::get().evmVersion().supportsReturndata())
return; return;
BOOST_CHECK(successAssemble("{ let r := returndatasize() }")); BOOST_CHECK(successAssemble("{ let r := returndatasize() }"));
} }
BOOST_AUTO_TEST_CASE(returndatacopy) BOOST_AUTO_TEST_CASE(returndatacopy)
{ {
if (!solidity::test::Options::get().evmVersion().supportsReturndata()) if (!solidity::test::CommonOptions::get().evmVersion().supportsReturndata())
return; return;
BOOST_CHECK(successAssemble("{ returndatacopy(0, 32, 64) }")); BOOST_CHECK(successAssemble("{ returndatacopy(0, 32, 64) }"));
} }
BOOST_AUTO_TEST_CASE(returndatacopy_functional) BOOST_AUTO_TEST_CASE(returndatacopy_functional)
{ {
if (!solidity::test::Options::get().evmVersion().supportsReturndata()) if (!solidity::test::CommonOptions::get().evmVersion().supportsReturndata())
return; return;
BOOST_CHECK(successAssemble("{ returndatacopy(0, 32, 64) }")); BOOST_CHECK(successAssemble("{ returndatacopy(0, 32, 64) }"));
} }
BOOST_AUTO_TEST_CASE(staticcall) BOOST_AUTO_TEST_CASE(staticcall)
{ {
if (!solidity::test::Options::get().evmVersion().hasStaticCall()) if (!solidity::test::CommonOptions::get().evmVersion().hasStaticCall())
return; return;
BOOST_CHECK(successAssemble("{ pop(staticcall(10000, 0x123, 64, 0x10, 128, 0x10)) }")); BOOST_CHECK(successAssemble("{ pop(staticcall(10000, 0x123, 64, 0x10, 128, 0x10)) }"));
} }
BOOST_AUTO_TEST_CASE(create2) BOOST_AUTO_TEST_CASE(create2)
{ {
if (!solidity::test::Options::get().evmVersion().hasCreate2()) if (!solidity::test::CommonOptions::get().evmVersion().hasCreate2())
return; return;
BOOST_CHECK(successAssemble("{ pop(create2(10, 0x123, 32, 64)) }")); BOOST_CHECK(successAssemble("{ pop(create2(10, 0x123, 32, 64)) }"));
} }
BOOST_AUTO_TEST_CASE(shift) BOOST_AUTO_TEST_CASE(shift)
{ {
if (!solidity::test::Options::get().evmVersion().hasBitwiseShifting()) if (!solidity::test::CommonOptions::get().evmVersion().hasBitwiseShifting())
return; return;
BOOST_CHECK(successAssemble("{ pop(shl(10, 32)) }")); BOOST_CHECK(successAssemble("{ pop(shl(10, 32)) }"));
BOOST_CHECK(successAssemble("{ pop(shr(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) BOOST_AUTO_TEST_CASE(shift_constantinople_warning)
{ {
if (solidity::test::Options::get().evmVersion().hasBitwiseShifting()) if (solidity::test::CommonOptions::get().evmVersion().hasBitwiseShifting())
return; return;
CHECK_PARSE_WARNING("{ pop(shl(10, 32)) }", TypeError, "The \"shl\" instruction is only available for Constantinople-compatible VMs"); 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"); CHECK_PARSE_WARNING("{ pop(shr(10, 32)) }", TypeError, "The \"shr\" instruction is only available for Constantinople-compatible VMs");

View File

@ -20,7 +20,7 @@
*/ */
#include <test/Metadata.h> #include <test/Metadata.h>
#include <test/Options.h> #include <test/Common.h>
#include <libsolidity/interface/CompilerStack.h> #include <libsolidity/interface/CompilerStack.h>
#include <libsolidity/interface/Version.h> #include <libsolidity/interface/Version.h>
#include <libsolutil/SwarmHash.h> #include <libsolutil/SwarmHash.h>
@ -68,8 +68,8 @@ BOOST_AUTO_TEST_CASE(metadata_stamp)
CompilerStack compilerStack; CompilerStack compilerStack;
compilerStack.overwriteReleaseFlag(release); compilerStack.overwriteReleaseFlag(release);
compilerStack.setSources({{"", std::string(sourceCode)}}); compilerStack.setSources({{"", std::string(sourceCode)}});
compilerStack.setEVMVersion(solidity::test::Options::get().evmVersion()); compilerStack.setEVMVersion(solidity::test::CommonOptions::get().evmVersion());
compilerStack.setOptimiserSettings(solidity::test::Options::get().optimize); compilerStack.setOptimiserSettings(solidity::test::CommonOptions::get().optimize);
compilerStack.setMetadataHash(metadataHash); compilerStack.setMetadataHash(metadataHash);
BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed"); BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed");
bytes const& bytecode = compilerStack.runtimeObject("test").bytecode; bytes const& bytecode = compilerStack.runtimeObject("test").bytecode;
@ -129,8 +129,8 @@ BOOST_AUTO_TEST_CASE(metadata_stamp_experimental)
CompilerStack compilerStack; CompilerStack compilerStack;
compilerStack.overwriteReleaseFlag(release); compilerStack.overwriteReleaseFlag(release);
compilerStack.setSources({{"", std::string(sourceCode)}}); compilerStack.setSources({{"", std::string(sourceCode)}});
compilerStack.setEVMVersion(solidity::test::Options::get().evmVersion()); compilerStack.setEVMVersion(solidity::test::CommonOptions::get().evmVersion());
compilerStack.setOptimiserSettings(solidity::test::Options::get().optimize); compilerStack.setOptimiserSettings(solidity::test::CommonOptions::get().optimize);
compilerStack.setMetadataHash(metadataHash); compilerStack.setMetadataHash(metadataHash);
BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed"); BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed");
bytes const& bytecode = compilerStack.runtimeObject("test").bytecode; bytes const& bytecode = compilerStack.runtimeObject("test").bytecode;
@ -191,8 +191,8 @@ BOOST_AUTO_TEST_CASE(metadata_relevant_sources)
{"A", std::string(sourceCodeA)}, {"A", std::string(sourceCodeA)},
{"B", std::string(sourceCodeB)}, {"B", std::string(sourceCodeB)},
}); });
compilerStack.setEVMVersion(solidity::test::Options::get().evmVersion()); compilerStack.setEVMVersion(solidity::test::CommonOptions::get().evmVersion());
compilerStack.setOptimiserSettings(solidity::test::Options::get().optimize); compilerStack.setOptimiserSettings(solidity::test::CommonOptions::get().optimize);
BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed"); BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed");
std::string const& serialisedMetadata = compilerStack.metadata("A"); std::string const& serialisedMetadata = compilerStack.metadata("A");
@ -232,8 +232,8 @@ BOOST_AUTO_TEST_CASE(metadata_relevant_sources_imports)
{"B", std::string(sourceCodeB)}, {"B", std::string(sourceCodeB)},
{"C", std::string(sourceCodeC)} {"C", std::string(sourceCodeC)}
}); });
compilerStack.setEVMVersion(solidity::test::Options::get().evmVersion()); compilerStack.setEVMVersion(solidity::test::CommonOptions::get().evmVersion());
compilerStack.setOptimiserSettings(solidity::test::Options::get().optimize); compilerStack.setOptimiserSettings(solidity::test::CommonOptions::get().optimize);
BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed"); BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed");
std::string const& serialisedMetadata = compilerStack.metadata("C"); std::string const& serialisedMetadata = compilerStack.metadata("C");
@ -260,8 +260,8 @@ BOOST_AUTO_TEST_CASE(metadata_useLiteralContent)
{ {
CompilerStack compilerStack; CompilerStack compilerStack;
compilerStack.setSources({{"", std::string(_src)}}); compilerStack.setSources({{"", std::string(_src)}});
compilerStack.setEVMVersion(solidity::test::Options::get().evmVersion()); compilerStack.setEVMVersion(solidity::test::CommonOptions::get().evmVersion());
compilerStack.setOptimiserSettings(solidity::test::Options::get().optimize); compilerStack.setOptimiserSettings(solidity::test::CommonOptions::get().optimize);
compilerStack.useMetadataLiteralSources(_literal); compilerStack.useMetadataLiteralSources(_literal);
BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed"); BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed");
string metadata_str = compilerStack.metadata("test"); string metadata_str = compilerStack.metadata("test");

View File

@ -19,7 +19,7 @@
*/ */
#include <test/libsolidity/AnalysisFramework.h> #include <test/libsolidity/AnalysisFramework.h>
#include <test/Options.h> #include <test/Common.h>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
@ -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()); BOOST_CHECK(c.compile());
unsigned asserts = 0; 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()); BOOST_CHECK(c.compile());
unsigned asserts = 0; unsigned asserts = 0;

View File

@ -16,7 +16,7 @@
*/ */
#include <test/libsolidity/SMTCheckerJSONTest.h> #include <test/libsolidity/SMTCheckerJSONTest.h>
#include <test/Options.h> #include <test/Common.h>
#include <libsolidity/interface/StandardCompiler.h> #include <libsolidity/interface/StandardCompiler.h>
#include <libsolutil/CommonIO.h> #include <libsolutil/CommonIO.h>
#include <libsolutil/JSON.h> #include <libsolutil/JSON.h>

View File

@ -16,7 +16,7 @@
*/ */
#include <test/libsolidity/SMTCheckerTest.h> #include <test/libsolidity/SMTCheckerTest.h>
#include <test/Options.h> #include <test/Common.h>
#include <libsolidity/formal/ModelChecker.h> #include <libsolidity/formal/ModelChecker.h>

View File

@ -25,7 +25,7 @@
#include <tuple> #include <tuple>
#include <liblangutil/Scanner.h> #include <liblangutil/Scanner.h>
#include <liblangutil/SemVerHandler.h> #include <liblangutil/SemVerHandler.h>
#include <test/Options.h> #include <test/Common.h>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>

View File

@ -13,7 +13,7 @@
*/ */
#include <test/libsolidity/SemanticTest.h> #include <test/libsolidity/SemanticTest.h>
#include <test/Options.h> #include <test/Common.h>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/predicate.hpp> #include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/trim.hpp> #include <boost/algorithm/string/trim.hpp>

View File

@ -20,7 +20,7 @@
#include <test/libsolidity/AnalysisFramework.h> #include <test/libsolidity/AnalysisFramework.h>
#include <test/Metadata.h> #include <test/Metadata.h>
#include <test/Options.h> #include <test/Common.h>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
@ -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; } 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(success(sourceCode));
BOOST_REQUIRE_MESSAGE(compiler().compile(), "Compiling contract failed"); BOOST_REQUIRE_MESSAGE(compiler().compile(), "Compiling contract failed");
bytes const& creationBytecode = solidity::test::bytecodeSansMetadata(compiler().object("C").bytecode); bytes const& creationBytecode = solidity::test::bytecodeSansMetadata(compiler().object("C").bytecode);

View File

@ -23,7 +23,7 @@
#include <test/libsolidity/SolidityExecutionFramework.h> #include <test/libsolidity/SolidityExecutionFramework.h>
#include <test/Options.h> #include <test/Common.h>
#include <test/EVMHost.h> #include <test/EVMHost.h>
#include <liblangutil/Exceptions.h> #include <liblangutil/Exceptions.h>
@ -2458,7 +2458,7 @@ BOOST_AUTO_TEST_CASE(default_fallback_throws)
compileAndRun(sourceCode); compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("f()"), encodeArgs(0)); 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( char const* sourceCode = R"YY(
contract A { contract A {
@ -3323,7 +3323,7 @@ BOOST_AUTO_TEST_CASE(generic_delegatecall)
BOOST_AUTO_TEST_CASE(generic_staticcall) BOOST_AUTO_TEST_CASE(generic_staticcall)
{ {
if (solidity::test::Options::get().evmVersion().hasStaticCall()) if (solidity::test::CommonOptions::get().evmVersion().hasStaticCall())
{ {
char const* sourceCode = R"**( char const* sourceCode = R"**(
contract A { contract A {
@ -5709,7 +5709,7 @@ BOOST_AUTO_TEST_CASE(bool_conversion)
} }
)"; )";
compileAndRun(sourceCode, 0, "C"); 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)", 0), encodeArgs(0));
ABI_CHECK(callContractFunction("f(bool)", 1), encodeArgs(1)); ABI_CHECK(callContractFunction("f(bool)", 1), encodeArgs(1));
ABI_CHECK(callContractFunction("f(bool)", 2), v2 ? encodeArgs() : 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"); compileAndRun(sourceCode, 0, "C");
// We input longer data on purpose. // 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)); ABI_CHECK(callContractFunction("f(bytes2,uint16)", string("abc"), u256(0x040102)), v2 ? encodeArgs() : encodeArgs(0));
} }
BOOST_AUTO_TEST_CASE(cleanup_bytes_types_shortening) BOOST_AUTO_TEST_CASE(cleanup_bytes_types_shortening)
@ -10007,7 +10007,7 @@ BOOST_AUTO_TEST_CASE(cleanup_address_types)
)"; )";
compileAndRun(sourceCode, 0, "C"); compileAndRun(sourceCode, 0, "C");
bool v2 = solidity::test::Options::get().useABIEncoderV2; bool v2 = solidity::test::CommonOptions::get().useABIEncoderV2;
// We input longer data on purpose. // We input longer data on purpose.
ABI_CHECK(callContractFunction("f(address)", u256("0xFFFF1234567890123456789012345678901234567890")), v2 ? encodeArgs() : encodeArgs(0)); ABI_CHECK(callContractFunction("f(address)", u256("0xFFFF1234567890123456789012345678901234567890")), v2 ? encodeArgs() : encodeArgs(0));
ABI_CHECK(callContractFunction("g(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"); 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(4)), encodeArgs(u256(0xf)));
ABI_CHECK(callContractFunction("f(uint8,uint8)", u256(0x0), u256(0x1004)), v2 ? encodeArgs() : 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"); 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(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(4)), encodeArgs(u256(-1)));
ABI_CHECK(callContractFunction("f(int8,uint8)", u256(0x0), u256(0xFF)), 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"); 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(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(1)), v2 ? encodeArgs() : encodeArgs(u256(-52)));
ABI_CHECK(callContractFunction("f(int8,int8)", u256(0x99u), u256(2)), v2 ? encodeArgs() : encodeArgs(u256(-26))); 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"); 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(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(1)), v2 ? encodeArgs() : encodeArgs(u256(-52)));
ABI_CHECK(callContractFunction("f(int16,int16)", u256(0xFF99u), u256(2)), v2 ? encodeArgs() : encodeArgs(u256(-26))); 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"); 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(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(1)), v2 ? encodeArgs() : encodeArgs(u256(-52)));
ABI_CHECK(callContractFunction("f(int32,int32)", u256(0xFFFFFF99u), u256(2)), v2 ? encodeArgs() : encodeArgs(u256(-26))); 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"); compileAndRun(sourceCode, 0, "C");
bytes const errorSignature = bytes{0x08, 0xc3, 0x79, 0xa0}; 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"); compileAndRun(sourceCode, 0, "C");
bytes const errorSignature = bytes{0x08, 0xc3, 0x79, 0xa0}; 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"); compileAndRun(sourceCode, 0, "C");
bytes const errorSignature = bytes{0x08, 0xc3, 0x79, 0xa0}; 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"); compileAndRun(sourceCode, 0, "C");
bytes const errorSignature = bytes{0x08, 0xc3, 0x79, 0xa0}; 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"); compileAndRun(sourceCode, 0, "C");
bytes const errorSignature = bytes{0x08, 0xc3, 0x79, 0xa0}; 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("f()"), encodeArgs(u256(1)));
ABI_CHECK(callContractFunction("h()"), 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( char const* sourceCode = R"YY(
contract C { contract C {
@ -12462,10 +12462,10 @@ BOOST_AUTO_TEST_CASE(bare_call_invalid_address)
BOOST_AUTO_TEST_CASE(bare_call_return_data) BOOST_AUTO_TEST_CASE(bare_call_return_data)
{ {
if (solidity::test::Options::get().evmVersion().supportsReturndata()) if (solidity::test::CommonOptions::get().evmVersion().supportsReturndata())
{ {
vector<string> calltypes = {"call", "delegatecall"}; vector<string> calltypes = {"call", "delegatecall"};
if (solidity::test::Options::get().evmVersion().hasStaticCall()) if (solidity::test::CommonOptions::get().evmVersion().hasStaticCall())
calltypes.emplace_back("staticcall"); calltypes.emplace_back("staticcall");
for (string const& calltype: calltypes) for (string const& calltype: calltypes)
{ {
@ -12589,7 +12589,7 @@ BOOST_AUTO_TEST_CASE(bare_call_return_data)
BOOST_AUTO_TEST_CASE(delegatecall_return_value) 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( char const* sourceCode = R"DELIMITER(
contract C { contract C {
@ -13390,7 +13390,7 @@ BOOST_AUTO_TEST_CASE(abi_encode_empty_string)
)"; )";
compileAndRun(sourceCode, 0, "C"); 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 Encoder V2 has slightly different padding, tested below.
ABI_CHECK(callContractFunction("f()"), encodeArgs( ABI_CHECK(callContractFunction("f()"), encodeArgs(
@ -13514,7 +13514,7 @@ BOOST_AUTO_TEST_CASE(staticcall_for_view_and_pure)
compileAndRun(sourceCode, 0, "D"); compileAndRun(sourceCode, 0, "D");
// This should work (called via CALL) // This should work (called via CALL)
ABI_CHECK(callContractFunction("f()"), encodeArgs(1)); 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) // These should throw (called via STATICCALL)
ABI_CHECK(callContractFunction("fview()"), encodeArgs()); 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) BOOST_AUTO_TEST_CASE(bitwise_shifting_constantinople)
{ {
if (!solidity::test::Options::get().evmVersion().hasBitwiseShifting()) if (!solidity::test::CommonOptions::get().evmVersion().hasBitwiseShifting())
return; return;
char const* sourceCode = R"( char const* sourceCode = R"(
contract C { contract C {
@ -13568,7 +13568,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constantinople)
BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople) BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople)
{ {
if (!solidity::test::Options::get().evmVersion().hasBitwiseShifting()) if (!solidity::test::CommonOptions::get().evmVersion().hasBitwiseShifting())
return; return;
char const* sourceCode = R"( char const* sourceCode = R"(
contract C { contract C {
@ -13635,7 +13635,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople)
BOOST_AUTO_TEST_CASE(bitwise_shifting_constantinople_combined) BOOST_AUTO_TEST_CASE(bitwise_shifting_constantinople_combined)
{ {
if (!solidity::test::Options::get().evmVersion().hasBitwiseShifting()) if (!solidity::test::CommonOptions::get().evmVersion().hasBitwiseShifting())
return; return;
char const* sourceCode = R"( char const* sourceCode = R"(
contract C { 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, "L", bytes());
compileAndRun(sourceCode, 0, "C", bytes(), map<string, Address>{{"L", m_contractAddress}}); compileAndRun(sourceCode, 0, "C", bytes(), map<string, Address>{{"L", m_contractAddress}});

View File

@ -39,7 +39,7 @@ bytes SolidityExecutionFramework::compileContract(
// Silence compiler version warning // Silence compiler version warning
std::string sourceCode = "pragma solidity >=0.0;\n"; std::string sourceCode = "pragma solidity >=0.0;\n";
if ( if (
solidity::test::Options::get().useABIEncoderV2 && solidity::test::CommonOptions::get().useABIEncoderV2 &&
_sourceCode.find("pragma experimental ABIEncoderV2;") == std::string::npos _sourceCode.find("pragma experimental ABIEncoderV2;") == std::string::npos
) )
sourceCode += "pragma experimental ABIEncoderV2;\n"; sourceCode += "pragma experimental ABIEncoderV2;\n";

View File

@ -31,7 +31,7 @@
#include <libsolidity/ast/TypeProvider.h> #include <libsolidity/ast/TypeProvider.h>
#include <libsolidity/analysis/TypeChecker.h> #include <libsolidity/analysis/TypeChecker.h>
#include <liblangutil/ErrorReporter.h> #include <liblangutil/ErrorReporter.h>
#include <test/Options.h> #include <test/Common.h>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
@ -100,7 +100,7 @@ bytes compileFirstExpression(
{ {
ErrorList errors; ErrorList errors;
ErrorReporter errorReporter(errors); ErrorReporter errorReporter(errors);
sourceUnit = Parser(errorReporter, solidity::test::Options::get().evmVersion()).parse( sourceUnit = Parser(errorReporter, solidity::test::CommonOptions::get().evmVersion()).parse(
make_shared<Scanner>(CharStream(_sourceCode, "")) make_shared<Scanner>(CharStream(_sourceCode, ""))
); );
if (!sourceUnit) if (!sourceUnit)
@ -116,7 +116,7 @@ bytes compileFirstExpression(
ErrorReporter errorReporter(errors); ErrorReporter errorReporter(errors);
GlobalContext globalContext; GlobalContext globalContext;
map<ASTNode const*, shared_ptr<DeclarationContainer>> scopes; map<ASTNode const*, shared_ptr<DeclarationContainer>> scopes;
NameAndTypeResolver resolver(globalContext, solidity::test::Options::get().evmVersion(), scopes, errorReporter); NameAndTypeResolver resolver(globalContext, solidity::test::CommonOptions::get().evmVersion(), scopes, errorReporter);
resolver.registerDeclarations(*sourceUnit); resolver.registerDeclarations(*sourceUnit);
vector<ContractDefinition const*> inheritanceHierarchy; vector<ContractDefinition const*> inheritanceHierarchy;
@ -130,7 +130,7 @@ bytes compileFirstExpression(
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get())) if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
{ {
ErrorReporter errorReporter(errors); ErrorReporter errorReporter(errors);
TypeChecker typeChecker(solidity::test::Options::get().evmVersion(), errorReporter); TypeChecker typeChecker(solidity::test::CommonOptions::get().evmVersion(), errorReporter);
BOOST_REQUIRE(typeChecker.checkTypeRequirements(*contract)); BOOST_REQUIRE(typeChecker.checkTypeRequirements(*contract));
} }
for (ASTPointer<ASTNode> const& node: sourceUnit->nodes()) for (ASTPointer<ASTNode> const& node: sourceUnit->nodes())
@ -139,7 +139,7 @@ bytes compileFirstExpression(
FirstExpressionExtractor extractor(*contract); FirstExpressionExtractor extractor(*contract);
BOOST_REQUIRE(extractor.expression() != nullptr); BOOST_REQUIRE(extractor.expression() != nullptr);
CompilerContext context(solidity::test::Options::get().evmVersion()); CompilerContext context(solidity::test::CommonOptions::get().evmVersion());
context.resetVisitedNodes(contract); context.resetVisitedNodes(contract);
context.setInheritanceHierarchy(inheritanceHierarchy); context.setInheritanceHierarchy(inheritanceHierarchy);
unsigned parametersSize = _localVariables.size(); // assume they are all one slot on the stack unsigned parametersSize = _localVariables.size(); // assume they are all one slot on the stack
@ -153,7 +153,7 @@ bytes compileFirstExpression(
ExpressionCompiler( ExpressionCompiler(
context, context,
RevertStrings::Default, RevertStrings::Default,
solidity::test::Options::get().optimize solidity::test::CommonOptions::get().optimize
).compile(*extractor.expression()); ).compile(*extractor.expression());
for (vector<string> const& function: _functions) for (vector<string> const& function: _functions)
@ -284,7 +284,7 @@ BOOST_AUTO_TEST_CASE(comparison)
bytes code = compileFirstExpression(sourceCode); bytes code = compileFirstExpression(sourceCode);
bytes expectation; bytes expectation;
if (solidity::test::Options::get().optimize) if (solidity::test::CommonOptions::get().optimize)
expectation = { expectation = {
uint8_t(Instruction::PUSH2), 0x11, 0xaa, uint8_t(Instruction::PUSH2), 0x11, 0xaa,
uint8_t(Instruction::PUSH2), 0x10, 0xaa, uint8_t(Instruction::PUSH2), 0x10, 0xaa,
@ -347,7 +347,7 @@ BOOST_AUTO_TEST_CASE(arithmetic)
bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "y"}}); bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "y"}});
bytes expectation; bytes expectation;
if (solidity::test::Options::get().optimize) if (solidity::test::CommonOptions::get().optimize)
expectation = { expectation = {
uint8_t(Instruction::PUSH1), 0x2, uint8_t(Instruction::PUSH1), 0x2,
uint8_t(Instruction::PUSH1), 0x3, uint8_t(Instruction::PUSH1), 0x3,
@ -428,7 +428,7 @@ BOOST_AUTO_TEST_CASE(unary_operators)
bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "y"}}); bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "y"}});
bytes expectation; bytes expectation;
if (solidity::test::Options::get().optimize) if (solidity::test::CommonOptions::get().optimize)
expectation = { expectation = {
uint8_t(Instruction::DUP1), uint8_t(Instruction::DUP1),
uint8_t(Instruction::PUSH1), 0x0, uint8_t(Instruction::PUSH1), 0x0,
@ -519,7 +519,7 @@ BOOST_AUTO_TEST_CASE(assignment)
// Stack: a, b // Stack: a, b
bytes expectation; bytes expectation;
if (solidity::test::Options::get().optimize) if (solidity::test::CommonOptions::get().optimize)
expectation = { expectation = {
uint8_t(Instruction::DUP1), uint8_t(Instruction::DUP1),
uint8_t(Instruction::DUP3), uint8_t(Instruction::DUP3),
@ -631,7 +631,7 @@ BOOST_AUTO_TEST_CASE(selfbalance)
bytes code = compileFirstExpression(sourceCode, {}, {}); 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)}); bytes expectation({uint8_t(Instruction::SELFBALANCE)});
BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end());

View File

@ -22,7 +22,7 @@
#include <test/libsolidity/AnalysisFramework.h> #include <test/libsolidity/AnalysisFramework.h>
#include <test/Options.h> #include <test/Common.h>
#include <libsolidity/ast/AST.h> #include <libsolidity/ast/AST.h>
@ -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."); CHECK_ERROR(sourceCode, TypeError, "Type inaccessible dynamic type is not implicitly convertible to expected type string memory.");
else else
CHECK_SUCCESS_NO_WARNINGS(sourceCode); CHECK_SUCCESS_NO_WARNINGS(sourceCode);
@ -386,7 +386,7 @@ BOOST_AUTO_TEST_CASE(returndatasize_as_variable)
vector<pair<Error::Type, std::string>> expectations(vector<pair<Error::Type, std::string>>{ vector<pair<Error::Type, std::string>> expectations(vector<pair<Error::Type, std::string>>{
{Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"} {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"))); expectations.emplace_back(make_pair(Error::Type::TypeError, std::string("\"returndatasize\" instruction is only available for Byzantium-compatible VMs")));
CHECK_ALLOW_MULTI(text, expectations); CHECK_ALLOW_MULTI(text, expectations);
} }
@ -401,7 +401,7 @@ BOOST_AUTO_TEST_CASE(create2_as_variable)
vector<pair<Error::Type, std::string>> expectations(vector<pair<Error::Type, std::string>>{ vector<pair<Error::Type, std::string>> expectations(vector<pair<Error::Type, std::string>>{
{Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"} {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"))); expectations.emplace_back(make_pair(Error::Type::TypeError, std::string("\"create2\" instruction is only available for Constantinople-compatible VMs")));
CHECK_ALLOW_MULTI(text, expectations); CHECK_ALLOW_MULTI(text, expectations);
} }
@ -416,7 +416,7 @@ BOOST_AUTO_TEST_CASE(extcodehash_as_variable)
vector<pair<Error::Type, std::string>> expectations(vector<pair<Error::Type, std::string>>{ vector<pair<Error::Type, std::string>> expectations(vector<pair<Error::Type, std::string>>{
{Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"} {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"))); expectations.emplace_back(make_pair(Error::Type::TypeError, std::string("\"extcodehash\" instruction is only available for Constantinople-compatible VMs")));
CHECK_ALLOW_MULTI(text, expectations); 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); CHECK_SUCCESS_NO_WARNINGS(sourceCode);
else else
CHECK_ERROR(sourceCode, TypeError, "\"staticcall\" is not supported by the VM version."); 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) 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"( char const* sourceCode = R"(
contract C { 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); CHECK_SUCCESS_NO_WARNINGS(sourceCode);
else else
CHECK_ERROR(sourceCode, TypeError, "Type inaccessible dynamic type is not implicitly convertible to expected type bytes memory."); 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); CHECK_SUCCESS_NO_WARNINGS(sourceCode);
else else
CHECK_ERROR(sourceCode, TypeError, "Type inaccessible dynamic type is not implicitly convertible to expected type bytes memory."); 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) 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"( char const* sourceCode = R"(
contract C { contract C {

View File

@ -20,7 +20,7 @@
* Unit tests for the solidity compiler JSON Interface output. * Unit tests for the solidity compiler JSON Interface output.
*/ */
#include <test/Options.h> #include <test/Common.h>
#include <string> #include <string>
#include <libsolutil/JSON.h> #include <libsolutil/JSON.h>
#include <libsolidity/interface/CompilerStack.h> #include <libsolidity/interface/CompilerStack.h>
@ -46,7 +46,7 @@ public:
{ {
m_compilerStack.reset(); m_compilerStack.reset();
m_compilerStack.setSources({{"", "pragma solidity >=0.0;\n" + _code}}); 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"); BOOST_REQUIRE_MESSAGE(m_compilerStack.parseAndAnalyze(), "Parsing contract failed");
Json::Value generatedDocumentation; Json::Value generatedDocumentation;
@ -67,7 +67,7 @@ public:
{ {
m_compilerStack.reset(); m_compilerStack.reset();
m_compilerStack.setSources({{"", "pragma solidity >=0.0;\n" + _code}}); 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_CHECK(!m_compilerStack.parseAndAnalyze());
BOOST_REQUIRE(Error::containsErrorOfType(m_compilerStack.errors(), Error::Type::DocstringParsingError)); BOOST_REQUIRE(Error::containsErrorOfType(m_compilerStack.errors(), Error::Type::DocstringParsingError));
} }

View File

@ -25,7 +25,7 @@
#include <liblangutil/Scanner.h> #include <liblangutil/Scanner.h>
#include <libsolidity/parsing/Parser.h> #include <libsolidity/parsing/Parser.h>
#include <liblangutil/ErrorReporter.h> #include <liblangutil/ErrorReporter.h>
#include <test/Options.h> #include <test/Common.h>
#include <test/libsolidity/ErrorCheck.h> #include <test/libsolidity/ErrorCheck.h>
#include <libsolidity/ast/ASTVisitor.h> #include <libsolidity/ast/ASTVisitor.h>
@ -44,7 +44,7 @@ ASTPointer<ContractDefinition> parseText(std::string const& _source, ErrorList&
ErrorReporter errorReporter(_errors); ErrorReporter errorReporter(_errors);
ASTPointer<SourceUnit> sourceUnit = Parser( ASTPointer<SourceUnit> sourceUnit = Parser(
errorReporter, errorReporter,
solidity::test::Options::get().evmVersion(), solidity::test::CommonOptions::get().evmVersion(),
errorRecovery errorRecovery
).parse(std::make_shared<Scanner>(CharStream(_source, ""))); ).parse(std::make_shared<Scanner>(CharStream(_source, "")));
if (!sourceUnit) if (!sourceUnit)

View File

@ -16,7 +16,7 @@
*/ */
#include <test/libsolidity/SyntaxTest.h> #include <test/libsolidity/SyntaxTest.h>
#include <test/Options.h> #include <test/Common.h>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/predicate.hpp> #include <boost/algorithm/string/predicate.hpp>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>

View File

@ -20,7 +20,7 @@
#include <test/libsolidity/AnalysisFramework.h> #include <test/libsolidity/AnalysisFramework.h>
#include <test/Options.h> #include <test/Common.h>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
@ -52,7 +52,7 @@ BOOST_AUTO_TEST_CASE(environment_access)
"this", "this",
"address(1).balance", "address(1).balance",
}; };
if (solidity::test::Options::get().evmVersion().hasStaticCall()) if (solidity::test::CommonOptions::get().evmVersion().hasStaticCall())
view.emplace_back("address(0x4242).staticcall(\"\")"); view.emplace_back("address(0x4242).staticcall(\"\")");
// ``block.blockhash`` and ``blockhash`` are tested separately below because their usage will // ``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."); CHECK_ERROR(text, TypeError, "\"staticcall\" is not supported by the VM version.");
else else
CHECK_SUCCESS_NO_WARNINGS(text); 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"); CHECK_ERROR(text, TypeError, "\"staticcall\" instruction is only available for Byzantium-compatible");
else else
CHECK_SUCCESS_NO_WARNINGS(text); CHECK_SUCCESS_NO_WARNINGS(text);

View File

@ -18,7 +18,7 @@
#include <test/libsolidity/util/TestFileParser.h> #include <test/libsolidity/util/TestFileParser.h>
#include <test/libsolidity/util/BytesUtils.h> #include <test/libsolidity/util/BytesUtils.h>
#include <test/Options.h> #include <test/Common.h>
#include <liblangutil/Common.h> #include <liblangutil/Common.h>

View File

@ -21,7 +21,7 @@
#include <libsolutil/CommonData.h> #include <libsolutil/CommonData.h>
#include <libsolutil/Exceptions.h> #include <libsolutil/Exceptions.h>
#include <test/Options.h> #include <test/Common.h>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>

View File

@ -23,7 +23,7 @@
#include <libsolutil/FixedHash.h> #include <libsolutil/FixedHash.h>
#include <libsolidity/ast/Types.h> // for IntegerType #include <libsolidity/ast/Types.h> // for IntegerType
#include <test/Options.h> #include <test/Common.h>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>

View File

@ -20,7 +20,7 @@
#include <libsolutil/IndentedWriter.h> #include <libsolutil/IndentedWriter.h>
#include <test/Options.h> #include <test/Common.h>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>

View File

@ -20,7 +20,7 @@
#include <libsolutil/IpfsHash.h> #include <libsolutil/IpfsHash.h>
#include <test/Options.h> #include <test/Common.h>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>

View File

@ -20,7 +20,7 @@
#include <libsolutil/CommonData.h> #include <libsolutil/CommonData.h>
#include <test/Options.h> #include <test/Common.h>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>

View File

@ -21,7 +21,7 @@
#include <libsolutil/JSON.h> #include <libsolutil/JSON.h>
#include <test/Options.h> #include <test/Common.h>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>

View File

@ -24,7 +24,7 @@
#include <libsolidity/ast/Types.h> // for IntegerType #include <libsolidity/ast/Types.h> // for IntegerType
#include <test/Options.h> #include <test/Common.h>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>

View File

@ -20,7 +20,7 @@
#include <libsolutil/SwarmHash.h> #include <libsolutil/SwarmHash.h>
#include <test/Options.h> #include <test/Common.h>
#include <libsolutil/Keccak256.h> #include <libsolutil/Keccak256.h>

View File

@ -21,7 +21,7 @@
#include <libsolutil/CommonData.h> #include <libsolutil/CommonData.h>
#include <libsolutil/UTF8.h> #include <libsolutil/UTF8.h>
#include <test/Options.h> #include <test/Common.h>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>

View File

@ -20,7 +20,7 @@
#include <libsolutil/Whiskers.h> #include <libsolutil/Whiskers.h>
#include <test/Options.h> #include <test/Common.h>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>

View File

@ -21,7 +21,7 @@
#include <test/libyul/Common.h> #include <test/libyul/Common.h>
#include <test/Options.h> #include <test/Common.h>
#include <liblangutil/SourceReferenceFormatter.h> #include <liblangutil/SourceReferenceFormatter.h>
@ -48,7 +48,7 @@ namespace
{ {
Dialect const& defaultDialect(bool _yul) 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<Block>, shared_ptr<yul::AsmAnalysisInfo>> yul::test::parse(string const& _source, bool _yul) pair<shared_ptr<Block>, shared_ptr<yul::AsmAnalysisInfo>> yul::test::parse(string const& _source, bool _yul)
{ {
AssemblyStack stack( AssemblyStack stack(
solidity::test::Options::get().evmVersion(), solidity::test::CommonOptions::get().evmVersion(),
_yul ? AssemblyStack::Language::Yul : AssemblyStack::Language::StrictAssembly, _yul ? AssemblyStack::Language::Yul : AssemblyStack::Language::StrictAssembly,
solidity::test::Options::get().optimize ? solidity::test::CommonOptions::get().optimize ?
solidity::frontend::OptimiserSettings::standard() : solidity::frontend::OptimiserSettings::standard() :
solidity::frontend::OptimiserSettings::minimal() solidity::frontend::OptimiserSettings::minimal()
); );

View File

@ -18,7 +18,7 @@
* Unit tests for the compilability checker. * Unit tests for the compilability checker.
*/ */
#include <test/Options.h> #include <test/Common.h>
#include <test/libyul/Common.h> #include <test/libyul/Common.h>
#include <libyul/backends/evm/EVMDialect.h> #include <libyul/backends/evm/EVMDialect.h>
@ -39,7 +39,7 @@ string check(string const& _input)
Object obj; Object obj;
std::tie(obj.code, obj.analysisInfo) = yul::test::parse(_input, false); std::tie(obj.code, obj.analysisInfo) = yul::test::parse(_input, false);
BOOST_REQUIRE(obj.code); BOOST_REQUIRE(obj.code);
map<YulString, int> functions = CompilabilityChecker::run(EVMDialect::strictAssemblyForEVM(solidity::test::Options::get().evmVersion()), obj, true); map<YulString, int> functions = CompilabilityChecker::run(EVMDialect::strictAssemblyForEVM(solidity::test::CommonOptions::get().evmVersion()), obj, true);
string out; string out;
for (auto const& function: functions) for (auto const& function: functions)
out += function.first.str() + ": " + to_string(function.second) + " "; out += function.first.str() + ": " + to_string(function.second) + " ";

View File

@ -19,7 +19,7 @@
#include <test/tools/yulInterpreter/Interpreter.h> #include <test/tools/yulInterpreter/Interpreter.h>
#include <test/Options.h> #include <test/Common.h>
#include <libyul/backends/evm/EVMDialect.h> #include <libyul/backends/evm/EVMDialect.h>
#include <libyul/backends/wasm/WasmDialect.h> #include <libyul/backends/wasm/WasmDialect.h>
@ -67,7 +67,7 @@ TestCase::TestResult EwasmTranslationTest::run(ostream& _stream, string const& _
return TestResult::FatalError; return TestResult::FatalError;
*m_object = EVMToEwasmTranslator( *m_object = EVMToEwasmTranslator(
EVMDialect::strictAssemblyForEVMObjects(solidity::test::Options::get().evmVersion()) EVMDialect::strictAssemblyForEVMObjects(solidity::test::CommonOptions::get().evmVersion())
).run(*m_object); ).run(*m_object);
// Add call to "main()". // 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) bool EwasmTranslationTest::parse(ostream& _stream, string const& _linePrefix, bool const _formatted)
{ {
AssemblyStack stack( AssemblyStack stack(
solidity::test::Options::get().evmVersion(), solidity::test::CommonOptions::get().evmVersion(),
AssemblyStack::Language::StrictAssembly, AssemblyStack::Language::StrictAssembly,
solidity::frontend::OptimiserSettings::none() solidity::frontend::OptimiserSettings::none()
); );

View File

@ -16,7 +16,7 @@
*/ */
#include <test/libyul/FunctionSideEffects.h> #include <test/libyul/FunctionSideEffects.h>
#include <test/Options.h> #include <test/Common.h>
#include <test/libyul/Common.h> #include <test/libyul/Common.h>
#include <libsolutil/AnsiColorized.h> #include <libsolutil/AnsiColorized.h>

View File

@ -18,7 +18,7 @@
* Unit tests for the code metrics. * Unit tests for the code metrics.
*/ */
#include <test/Options.h> #include <test/Common.h>
#include <test/libyul/Common.h> #include <test/libyul/Common.h>

View File

@ -19,7 +19,7 @@
* Unit tests for the Yul object parser. * Unit tests for the Yul object parser.
*/ */
#include <test/Options.h> #include <test/Common.h>
#include <test/libsolidity/ErrorCheck.h> #include <test/libsolidity/ErrorCheck.h>
@ -49,7 +49,7 @@ std::pair<bool, ErrorList> parse(string const& _source)
try try
{ {
AssemblyStack asmStack( AssemblyStack asmStack(
solidity::test::Options::get().evmVersion(), solidity::test::CommonOptions::get().evmVersion(),
AssemblyStack::Language::StrictAssembly, AssemblyStack::Language::StrictAssembly,
solidity::frontend::OptimiserSettings::none() solidity::frontend::OptimiserSettings::none()
); );
@ -240,7 +240,7 @@ BOOST_AUTO_TEST_CASE(to_string)
)"; )";
expectation = boost::replace_all_copy(expectation, "\t", " "); expectation = boost::replace_all_copy(expectation, "\t", " ");
AssemblyStack asmStack( AssemblyStack asmStack(
solidity::test::Options::get().evmVersion(), solidity::test::CommonOptions::get().evmVersion(),
AssemblyStack::Language::StrictAssembly, AssemblyStack::Language::StrictAssembly,
solidity::frontend::OptimiserSettings::none() solidity::frontend::OptimiserSettings::none()
); );

View File

@ -19,7 +19,7 @@
* Unit tests for parsing Yul. * Unit tests for parsing Yul.
*/ */
#include <test/Options.h> #include <test/Common.h>
#include <test/libsolidity/ErrorCheck.h> #include <test/libsolidity/ErrorCheck.h>
#include <test/libyul/Common.h> #include <test/libyul/Common.h>

View File

@ -18,7 +18,7 @@
* Unit tests for stack-reusing code generator. * Unit tests for stack-reusing code generator.
*/ */
#include <test/Options.h> #include <test/Common.h>
#include <libyul/AssemblyStack.h> #include <libyul/AssemblyStack.h>
#include <libevmasm/Instruction.h> #include <libevmasm/Instruction.h>

View File

@ -19,7 +19,7 @@
#include <test/tools/yulInterpreter/Interpreter.h> #include <test/tools/yulInterpreter/Interpreter.h>
#include <test/Options.h> #include <test/Common.h>
#include <libyul/backends/evm/EVMDialect.h> #include <libyul/backends/evm/EVMDialect.h>
#include <libyul/AsmParser.h> #include <libyul/AsmParser.h>
@ -99,7 +99,7 @@ void YulInterpreterTest::printIndented(ostream& _stream, string const& _output,
bool YulInterpreterTest::parse(ostream& _stream, string const& _linePrefix, bool const _formatted) bool YulInterpreterTest::parse(ostream& _stream, string const& _linePrefix, bool const _formatted)
{ {
AssemblyStack stack( AssemblyStack stack(
solidity::test::Options::get().evmVersion(), solidity::test::CommonOptions::get().evmVersion(),
AssemblyStack::Language::StrictAssembly, AssemblyStack::Language::StrictAssembly,
solidity::frontend::OptimiserSettings::none() solidity::frontend::OptimiserSettings::none()
); );

View File

@ -19,7 +19,7 @@
#include <test/libsolidity/util/SoltestErrors.h> #include <test/libsolidity/util/SoltestErrors.h>
#include <test/libyul/Common.h> #include <test/libyul/Common.h>
#include <test/Options.h> #include <test/Common.h>
#include <libyul/optimiser/BlockFlattener.h> #include <libyul/optimiser/BlockFlattener.h>
#include <libyul/optimiser/VarDeclInitializer.h> #include <libyul/optimiser/VarDeclInitializer.h>
@ -109,7 +109,7 @@ YulOptimizerTest::YulOptimizerTest(string const& _filename)
else if (dialectName == "ewasm") else if (dialectName == "ewasm")
m_dialect = &WasmDialect::instance(); m_dialect = &WasmDialect::instance();
else if (dialectName == "evm") else if (dialectName == "evm")
m_dialect = &EVMDialect::strictAssemblyForEVMObjects(solidity::test::Options::get().evmVersion()); m_dialect = &EVMDialect::strictAssemblyForEVMObjects(solidity::test::CommonOptions::get().evmVersion());
else else
BOOST_THROW_EXCEPTION(runtime_error("Invalid dialect " + dialectName)); BOOST_THROW_EXCEPTION(runtime_error("Invalid dialect " + dialectName));
@ -117,7 +117,7 @@ YulOptimizerTest::YulOptimizerTest(string const& _filename)
m_settings.erase("dialect"); m_settings.erase("dialect");
} }
else else
m_dialect = &EVMDialect::strictAssemblyForEVMObjects(solidity::test::Options::get().evmVersion()); m_dialect = &EVMDialect::strictAssemblyForEVMObjects(solidity::test::CommonOptions::get().evmVersion());
if (m_settings.count("step")) if (m_settings.count("step"))
{ {

View File

@ -13,7 +13,6 @@ target_link_libraries(yulopti PRIVATE solidity Boost::boost Boost::program_optio
add_executable(isoltest add_executable(isoltest
isoltest.cpp isoltest.cpp
IsolTestOptions.cpp IsolTestOptions.cpp
../Options.cpp
../Common.cpp ../Common.cpp
../EVMHost.cpp ../EVMHost.cpp
../TestCase.cpp ../TestCase.cpp

View File

@ -18,6 +18,7 @@
#include <libsolutil/CommonIO.h> #include <libsolutil/CommonIO.h>
#include <libsolutil/AnsiColorized.h> #include <libsolutil/AnsiColorized.h>
#include <memory>
#include <test/Common.h> #include <test/Common.h>
#include <test/tools/IsolTestOptions.h> #include <test/tools/IsolTestOptions.h>
#include <test/libsolidity/AnalysisFramework.h> #include <test/libsolidity/AnalysisFramework.h>
@ -401,20 +402,25 @@ int main(int argc, char const *argv[])
{ {
setupTerminal(); setupTerminal();
solidity::test::IsolTestOptions options(&TestTool::editor); {
auto options = std::make_unique<solidity::test::IsolTestOptions>(&TestTool::editor);
try try
{ {
if (options.parse(argc, argv)) if (!options->parse(argc, argv))
options.validate(); return -1;
else
options->validate();
solidity::test::CommonOptions::setSingleton(std::move(options));
}
catch (std::exception const& _exception)
{
cerr << _exception.what() << endl;
return 1; return 1;
}
} }
catch (std::exception const& _exception)
{ auto& options = dynamic_cast<solidity::test::IsolTestOptions const&>(solidity::test::CommonOptions::get());
cerr << _exception.what() << endl;
return 1;
}
bool disableSemantics = !solidity::test::EVMHost::getVM(options.evmonePath.string()); bool disableSemantics = !solidity::test::EVMHost::getVM(options.evmonePath.string());
if (disableSemantics) if (disableSemantics)