From d63d41b3b545b0e13e2ee7f880120b2ba852c654 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Wed, 14 Mar 2018 12:04:04 +0100 Subject: test: Rename test/TestHelper.* to test/Options.* and add Options::validate(). --- test/ExecutionFramework.h | 2 +- test/Options.cpp | 100 +++++++++++++++++++++ test/Options.h | 56 ++++++++++++ test/RPCSession.cpp | 2 +- test/TestHelper.cpp | 86 ------------------ test/TestHelper.h | 55 ------------ test/boostTest.cpp | 7 +- test/libdevcore/Checksum.cpp | 2 +- test/libdevcore/IndentedWriter.cpp | 2 +- test/libdevcore/JSON.cpp | 2 +- test/libdevcore/StringUtils.cpp | 2 +- test/libdevcore/SwarmHash.cpp | 2 +- test/libdevcore/UTF8.cpp | 2 +- test/libdevcore/Whiskers.cpp | 2 +- test/libevmasm/Optimiser.cpp | 2 +- test/libevmasm/SourceLocation.cpp | 2 +- test/libjulia/Common.cpp | 2 +- test/libjulia/Parser.cpp | 2 +- test/liblll/Compiler.cpp | 2 +- test/liblll/EndToEndTest.cpp | 2 +- test/libsolidity/ASTJSON.cpp | 2 +- test/libsolidity/AnalysisFramework.cpp | 2 +- test/libsolidity/Assembly.cpp | 2 +- test/libsolidity/Imports.cpp | 2 +- test/libsolidity/InlineAssembly.cpp | 2 +- test/libsolidity/JSONCompiler.cpp | 4 +- test/libsolidity/Metadata.cpp | 4 +- test/libsolidity/SemVerMatcher.cpp | 2 +- test/libsolidity/SolidityABIJSON.cpp | 2 +- test/libsolidity/SolidityEndToEndTest.cpp | 2 +- test/libsolidity/SolidityExpressionCompiler.cpp | 2 +- test/libsolidity/SolidityNameAndTypeResolution.cpp | 2 +- test/libsolidity/SolidityNatspecJSON.cpp | 2 +- test/libsolidity/SolidityParser.cpp | 4 +- test/libsolidity/ViewPureChecker.cpp | 2 +- 35 files changed, 191 insertions(+), 179 deletions(-) create mode 100644 test/Options.cpp create mode 100644 test/Options.h delete mode 100644 test/TestHelper.cpp delete mode 100644 test/TestHelper.h (limited to 'test') diff --git a/test/ExecutionFramework.h b/test/ExecutionFramework.h index a7971b81..ee8da322 100644 --- a/test/ExecutionFramework.h +++ b/test/ExecutionFramework.h @@ -22,7 +22,7 @@ #pragma once -#include +#include #include #include diff --git a/test/Options.cpp b/test/Options.cpp new file mode 100644 index 00000000..ff4a7c98 --- /dev/null +++ b/test/Options.cpp @@ -0,0 +1,100 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +/** @file TestHelper.h +* @author Marko Simovic +* @date 2014 +*/ + +#include + +#include +#include + +#include + +using namespace std; +using namespace dev::test; + +Options const& Options::get() +{ + static Options instance; + return instance; +} + +Options::Options() +{ + auto const& suite = boost::unit_test::framework::master_test_suite(); + for (auto i = 0; i < suite.argc; i++) + if (string(suite.argv[i]) == "--ipcpath" && i + 1 < suite.argc) + { + ipcPath = suite.argv[i + 1]; + i++; + } + else if (string(suite.argv[i]) == "--testpath" && i + 1 < suite.argc) + { + testPath = suite.argv[i + 1]; + i++; + } + else if (string(suite.argv[i]) == "--optimize") + optimize = true; + else if (string(suite.argv[i]) == "--evm-version") + { + evmVersionString = i + 1 < suite.argc ? suite.argv[i + 1] : "INVALID"; + ++i; + } + else if (string(suite.argv[i]) == "--show-messages") + showMessages = true; + else if (string(suite.argv[i]) == "--no-ipc") + disableIPC = true; + else if (string(suite.argv[i]) == "--no-smt") + disableSMT = true; + + if (!disableIPC && ipcPath.empty()) + if (auto path = getenv("ETH_TEST_IPC")) + ipcPath = path; + + if (testPath.empty()) + if (auto path = getenv("ETH_TEST_PATH")) + testPath = path; +} + +void Options::validate() const +{ + solAssert( + !dev::test::Options::get().testPath.empty(), + "No test path specified. The --testpath argument is required." + ); + if (!disableIPC) + solAssert( + !dev::test::Options::get().ipcPath.empty(), + "No ipc path specified. The --ipcpath argument is required, unless --no-ipc is used." + ); +} + +dev::solidity::EVMVersion Options::evmVersion() const +{ + if (!evmVersionString.empty()) + { + // We do this check as opposed to in the constructor because the BOOST_REQUIRE + // macros cannot yet be used in the constructor. + auto version = solidity::EVMVersion::fromString(evmVersionString); + BOOST_REQUIRE_MESSAGE(version, "Invalid EVM version: " + evmVersionString); + return *version; + } + else + return dev::solidity::EVMVersion(); +} diff --git a/test/Options.h b/test/Options.h new file mode 100644 index 00000000..9bc69876 --- /dev/null +++ b/test/Options.h @@ -0,0 +1,56 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +/** @file TestHelper.h + */ + +#pragma once + +#include + +#include +#include +#include + +#include + +namespace dev +{ +namespace test +{ + +struct Options: boost::noncopyable +{ + std::string ipcPath; + boost::filesystem::path testPath; + bool showMessages = false; + bool optimize = false; + bool disableIPC = false; + bool disableSMT = false; + + void validate() const; + solidity::EVMVersion evmVersion() const; + + static Options const& get(); + +private: + std::string evmVersionString; + + Options(); +}; + +} +} diff --git a/test/RPCSession.cpp b/test/RPCSession.cpp index 54871057..03b1341c 100644 --- a/test/RPCSession.cpp +++ b/test/RPCSession.cpp @@ -21,7 +21,7 @@ #include -#include +#include #include diff --git a/test/TestHelper.cpp b/test/TestHelper.cpp deleted file mode 100644 index 77fa204f..00000000 --- a/test/TestHelper.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - This file is part of solidity. - - solidity is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - solidity is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with solidity. If not, see . -*/ -/** @file TestHelper.h -* @author Marko Simovic -* @date 2014 -*/ - -#include - -#include - -#include - -using namespace std; -using namespace dev::test; - -Options const& Options::get() -{ - static Options instance; - return instance; -} - -Options::Options() -{ - auto const& suite = boost::unit_test::framework::master_test_suite(); - for (auto i = 0; i < suite.argc; i++) - if (string(suite.argv[i]) == "--ipcpath" && i + 1 < suite.argc) - { - ipcPath = suite.argv[i + 1]; - i++; - } - else if (string(suite.argv[i]) == "--testpath" && i + 1 < suite.argc) - { - testPath = suite.argv[i + 1]; - i++; - } - else if (string(suite.argv[i]) == "--optimize") - optimize = true; - else if (string(suite.argv[i]) == "--evm-version") - { - evmVersionString = i + 1 < suite.argc ? suite.argv[i + 1] : "INVALID"; - ++i; - } - else if (string(suite.argv[i]) == "--show-messages") - showMessages = true; - else if (string(suite.argv[i]) == "--no-ipc") - disableIPC = true; - else if (string(suite.argv[i]) == "--no-smt") - disableSMT = true; - - if (!disableIPC && ipcPath.empty()) - if (auto path = getenv("ETH_TEST_IPC")) - ipcPath = path; - - if (testPath.empty()) - if (auto path = getenv("ETH_TEST_PATH")) - testPath = path; -} - -dev::solidity::EVMVersion Options::evmVersion() const -{ - if (!evmVersionString.empty()) - { - // We do this check as opposed to in the constructor because the BOOST_REQUIRE - // macros cannot yet be used in the constructor. - auto version = solidity::EVMVersion::fromString(evmVersionString); - BOOST_REQUIRE_MESSAGE(version, "Invalid EVM version: " + evmVersionString); - return *version; - } - else - return dev::solidity::EVMVersion(); -} diff --git a/test/TestHelper.h b/test/TestHelper.h deleted file mode 100644 index f7b1d94c..00000000 --- a/test/TestHelper.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - This file is part of solidity. - - solidity is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - solidity is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with solidity. If not, see . -*/ -/** @file TestHelper.h - */ - -#pragma once - -#include - -#include -#include -#include - -#include - -namespace dev -{ -namespace test -{ - -struct Options: boost::noncopyable -{ - std::string ipcPath; - boost::filesystem::path testPath; - bool showMessages = false; - bool optimize = false; - bool disableIPC = false; - bool disableSMT = false; - - solidity::EVMVersion evmVersion() const; - - static Options const& get(); - -private: - std::string evmVersionString; - - Options(); -}; - -} -} diff --git a/test/boostTest.cpp b/test/boostTest.cpp index 8ad97db3..f16973b5 100644 --- a/test/boostTest.cpp +++ b/test/boostTest.cpp @@ -35,7 +35,7 @@ #pragma GCC diagnostic pop -#include +#include #include using namespace boost::unit_test; @@ -55,10 +55,7 @@ test_suite* init_unit_test_suite( int /*argc*/, char* /*argv*/[] ) { master_test_suite_t& master = framework::master_test_suite(); master.p_name.value = "SolidityTests"; - solAssert( - !dev::test::Options::get().testPath.empty(), - "No test path specified. The --testpath argument is required." - ); + dev::test::Options::get().validate(); solAssert(dev::solidity::test::SyntaxTest::registerTests( master, dev::test::Options::get().testPath / "libsolidity", diff --git a/test/libdevcore/Checksum.cpp b/test/libdevcore/Checksum.cpp index 4eedbd99..95066b69 100644 --- a/test/libdevcore/Checksum.cpp +++ b/test/libdevcore/Checksum.cpp @@ -22,7 +22,7 @@ #include -#include "../TestHelper.h" +#include using namespace std; diff --git a/test/libdevcore/IndentedWriter.cpp b/test/libdevcore/IndentedWriter.cpp index a694aa1b..916c99d0 100644 --- a/test/libdevcore/IndentedWriter.cpp +++ b/test/libdevcore/IndentedWriter.cpp @@ -20,7 +20,7 @@ #include -#include "../TestHelper.h" +#include using namespace std; diff --git a/test/libdevcore/JSON.cpp b/test/libdevcore/JSON.cpp index 39d71b42..39d958f5 100644 --- a/test/libdevcore/JSON.cpp +++ b/test/libdevcore/JSON.cpp @@ -21,7 +21,7 @@ #include -#include "../TestHelper.h" +#include using namespace std; diff --git a/test/libdevcore/StringUtils.cpp b/test/libdevcore/StringUtils.cpp index 597457cc..9ee93d02 100644 --- a/test/libdevcore/StringUtils.cpp +++ b/test/libdevcore/StringUtils.cpp @@ -20,7 +20,7 @@ #include -#include "../TestHelper.h" +#include using namespace std; diff --git a/test/libdevcore/SwarmHash.cpp b/test/libdevcore/SwarmHash.cpp index 1ed1da18..913586f8 100644 --- a/test/libdevcore/SwarmHash.cpp +++ b/test/libdevcore/SwarmHash.cpp @@ -20,7 +20,7 @@ #include -#include "../TestHelper.h" +#include using namespace std; diff --git a/test/libdevcore/UTF8.cpp b/test/libdevcore/UTF8.cpp index 719ada72..6de4570f 100644 --- a/test/libdevcore/UTF8.cpp +++ b/test/libdevcore/UTF8.cpp @@ -21,7 +21,7 @@ #include #include -#include "../TestHelper.h" +#include using namespace std; diff --git a/test/libdevcore/Whiskers.cpp b/test/libdevcore/Whiskers.cpp index 84149173..b12acdd7 100644 --- a/test/libdevcore/Whiskers.cpp +++ b/test/libdevcore/Whiskers.cpp @@ -20,7 +20,7 @@ #include -#include "../TestHelper.h" +#include using namespace std; diff --git a/test/libevmasm/Optimiser.cpp b/test/libevmasm/Optimiser.cpp index e6abcb53..f630b304 100644 --- a/test/libevmasm/Optimiser.cpp +++ b/test/libevmasm/Optimiser.cpp @@ -20,7 +20,7 @@ * Tests for the Solidity optimizer. */ -#include +#include #include #include diff --git a/test/libevmasm/SourceLocation.cpp b/test/libevmasm/SourceLocation.cpp index 6889b3e6..764da3cd 100644 --- a/test/libevmasm/SourceLocation.cpp +++ b/test/libevmasm/SourceLocation.cpp @@ -22,7 +22,7 @@ #include -#include "../TestHelper.h" +#include namespace dev { diff --git a/test/libjulia/Common.cpp b/test/libjulia/Common.cpp index 41f5d320..24519b01 100644 --- a/test/libjulia/Common.cpp +++ b/test/libjulia/Common.cpp @@ -21,7 +21,7 @@ #include -#include +#include #include diff --git a/test/libjulia/Parser.cpp b/test/libjulia/Parser.cpp index df905dd6..9d66658e 100644 --- a/test/libjulia/Parser.cpp +++ b/test/libjulia/Parser.cpp @@ -19,7 +19,7 @@ * Unit tests for parsing Julia. */ -#include "../TestHelper.h" +#include #include diff --git a/test/liblll/Compiler.cpp b/test/liblll/Compiler.cpp index 6c6eae3f..ebdea185 100644 --- a/test/liblll/Compiler.cpp +++ b/test/liblll/Compiler.cpp @@ -20,7 +20,7 @@ * Unit tests for the LLL compiler. */ -#include +#include #include diff --git a/test/liblll/EndToEndTest.cpp b/test/liblll/EndToEndTest.cpp index e5e70cf8..fd8099f2 100644 --- a/test/liblll/EndToEndTest.cpp +++ b/test/liblll/EndToEndTest.cpp @@ -21,7 +21,7 @@ */ #include -#include +#include #include diff --git a/test/libsolidity/ASTJSON.cpp b/test/libsolidity/ASTJSON.cpp index 9bf60b64..b44dd331 100644 --- a/test/libsolidity/ASTJSON.cpp +++ b/test/libsolidity/ASTJSON.cpp @@ -20,7 +20,7 @@ * Tests for the json ast output. */ -#include +#include #include #include diff --git a/test/libsolidity/AnalysisFramework.cpp b/test/libsolidity/AnalysisFramework.cpp index 7c335a48..4538757d 100644 --- a/test/libsolidity/AnalysisFramework.cpp +++ b/test/libsolidity/AnalysisFramework.cpp @@ -20,7 +20,7 @@ #include -#include +#include #include #include diff --git a/test/libsolidity/Assembly.cpp b/test/libsolidity/Assembly.cpp index aff610a4..5519ae0d 100644 --- a/test/libsolidity/Assembly.cpp +++ b/test/libsolidity/Assembly.cpp @@ -20,7 +20,7 @@ * Unit tests for Assembly Items from evmasm/Assembly.h */ -#include +#include #include #include diff --git a/test/libsolidity/Imports.cpp b/test/libsolidity/Imports.cpp index bc81b3b1..1b5dd4a5 100644 --- a/test/libsolidity/Imports.cpp +++ b/test/libsolidity/Imports.cpp @@ -21,7 +21,7 @@ */ #include -#include +#include #include #include diff --git a/test/libsolidity/InlineAssembly.cpp b/test/libsolidity/InlineAssembly.cpp index a4dcc4d5..34ca33e3 100644 --- a/test/libsolidity/InlineAssembly.cpp +++ b/test/libsolidity/InlineAssembly.cpp @@ -20,7 +20,7 @@ * Unit tests for inline assembly. */ -#include "../TestHelper.h" +#include #include #include diff --git a/test/libsolidity/JSONCompiler.cpp b/test/libsolidity/JSONCompiler.cpp index 285c5604..aed0a370 100644 --- a/test/libsolidity/JSONCompiler.cpp +++ b/test/libsolidity/JSONCompiler.cpp @@ -25,8 +25,8 @@ #include #include -#include "../Metadata.h" -#include "../TestHelper.h" +#include +#include using namespace std; diff --git a/test/libsolidity/Metadata.cpp b/test/libsolidity/Metadata.cpp index f1edeeb7..808bd1e1 100644 --- a/test/libsolidity/Metadata.cpp +++ b/test/libsolidity/Metadata.cpp @@ -19,8 +19,8 @@ * Unit tests for the metadata output. */ -#include "../Metadata.h" -#include "../TestHelper.h" +#include +#include #include #include #include diff --git a/test/libsolidity/SemVerMatcher.cpp b/test/libsolidity/SemVerMatcher.cpp index 08ef5277..07f8fba6 100644 --- a/test/libsolidity/SemVerMatcher.cpp +++ b/test/libsolidity/SemVerMatcher.cpp @@ -25,7 +25,7 @@ #include #include #include -#include "../TestHelper.h" +#include using namespace std; diff --git a/test/libsolidity/SolidityABIJSON.cpp b/test/libsolidity/SolidityABIJSON.cpp index 0d471b32..107abc26 100644 --- a/test/libsolidity/SolidityABIJSON.cpp +++ b/test/libsolidity/SolidityABIJSON.cpp @@ -20,7 +20,7 @@ * Unit tests for the solidity compiler JSON Interface output. */ -#include "../TestHelper.h" +#include #include #include diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 33cd1419..195ec85b 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -23,7 +23,7 @@ #include -#include +#include #include #include diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp index 5f044b44..c8adfc6e 100644 --- a/test/libsolidity/SolidityExpressionCompiler.cpp +++ b/test/libsolidity/SolidityExpressionCompiler.cpp @@ -30,7 +30,7 @@ #include #include #include -#include "../TestHelper.h" +#include using namespace std; diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 1f76c01b..c757037c 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -22,7 +22,7 @@ #include -#include +#include #include diff --git a/test/libsolidity/SolidityNatspecJSON.cpp b/test/libsolidity/SolidityNatspecJSON.cpp index 49a725e0..eeebeb74 100644 --- a/test/libsolidity/SolidityNatspecJSON.cpp +++ b/test/libsolidity/SolidityNatspecJSON.cpp @@ -20,7 +20,7 @@ * Unit tests for the solidity compiler JSON Interface output. */ -#include "../TestHelper.h" +#include #include #include #include diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp index f03b30e1..4e862f60 100644 --- a/test/libsolidity/SolidityParser.cpp +++ b/test/libsolidity/SolidityParser.cpp @@ -25,8 +25,8 @@ #include #include #include -#include "../TestHelper.h" -#include "ErrorCheck.h" +#include +#include using namespace std; diff --git a/test/libsolidity/ViewPureChecker.cpp b/test/libsolidity/ViewPureChecker.cpp index 26ff461c..a6ce6d91 100644 --- a/test/libsolidity/ViewPureChecker.cpp +++ b/test/libsolidity/ViewPureChecker.cpp @@ -20,7 +20,7 @@ #include -#include +#include #include -- cgit v1.2.3