From f47e918caaa49d6423564462c724dd0ff9dd577c Mon Sep 17 00:00:00 2001 From: Sean Hawkes Date: Sat, 18 Sep 2021 04:55:50 -0500 Subject: [PATCH] Moved program_options add_options to a helper function to allow defaults to be set by derived class constructor before immutable options are created by parent --- test/Common.cpp | 5 +++++ test/Common.h | 1 + test/tools/IsolTestOptions.cpp | 10 +++++++--- test/tools/IsolTestOptions.h | 1 + 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/test/Common.cpp b/test/Common.cpp index 9b2cfbb96..4be8e1625 100644 --- a/test/Common.cpp +++ b/test/Common.cpp @@ -91,6 +91,11 @@ CommonOptions::CommonOptions(std::string _caption): po::options_description::m_default_line_length, po::options_description::m_default_line_length - 23 ) +{ + +} + +void CommonOptions::addOptions() { options.add_options() ("evm-version", po::value(&evmVersionString), "which evm version to use") diff --git a/test/Common.h b/test/Common.h index c8a863d8c..4d97d720d 100644 --- a/test/Common.h +++ b/test/Common.h @@ -70,6 +70,7 @@ struct CommonOptions langutil::EVMVersion evmVersion() const; + virtual addOptions(); virtual bool parse(int argc, char const* const* argv); // Throws a ConfigException on error virtual void validate() const; diff --git a/test/tools/IsolTestOptions.cpp b/test/tools/IsolTestOptions.cpp index aaa087e47..487c7e8c7 100644 --- a/test/tools/IsolTestOptions.cpp +++ b/test/tools/IsolTestOptions.cpp @@ -58,6 +58,13 @@ std::string editorPath() IsolTestOptions::IsolTestOptions(std::string* _editor): CommonOptions(description) +{ + enforceViaYul = true; + enforceGasTest = (evmVersion() == langutil::EVMVersion{}); + enforceGasTestMinValue = 100000; +} + +void IsolTestOptions::addOptions() { options.add_options() ("editor", po::value(_editor)->default_value(editorPath()), "Path to editor for opening test files.") @@ -76,9 +83,6 @@ bool IsolTestOptions::parse(int _argc, char const* const* _argv) std::cout << options << std::endl; return false; } - enforceViaYul = true; - enforceGasTest = (evmVersion() == langutil::EVMVersion{}); - enforceGasTestMinValue = 100000; return res; } diff --git a/test/tools/IsolTestOptions.h b/test/tools/IsolTestOptions.h index aa9eb2564..7c1a5ebe1 100644 --- a/test/tools/IsolTestOptions.h +++ b/test/tools/IsolTestOptions.h @@ -35,6 +35,7 @@ struct IsolTestOptions: CommonOptions std::string testFilter = std::string{}; IsolTestOptions(std::string* _editor); + void addOptions() override; bool parse(int _argc, char const* const* _argv) override; void validate() const override; };