From cf6704ae0636fce85fda9d4dd52e1e2f86e97fac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Mon, 15 Nov 2021 18:19:37 +0100 Subject: [PATCH] isoltest: Do not return an error code from `--help` --- test/Common.h | 3 +++ test/tools/IsolTestOptions.cpp | 6 +++--- test/tools/isoltest.cpp | 5 +++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/test/Common.h b/test/Common.h index e7e211d9e..28862348f 100644 --- a/test/Common.h +++ b/test/Common.h @@ -75,6 +75,9 @@ struct CommonOptions langutil::EVMVersion evmVersion() const; virtual void addOptions(); + // @returns true if the program should continue, false if it should exit immediately without + // reporting an error. + // Throws ConfigException or std::runtime_error if parsing fails. 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 cdd1b85ab..ca7761d74 100644 --- a/test/tools/IsolTestOptions.cpp +++ b/test/tools/IsolTestOptions.cpp @@ -75,9 +75,9 @@ void IsolTestOptions::addOptions() bool IsolTestOptions::parse(int _argc, char const* const* _argv) { - bool const res = CommonOptions::parse(_argc, _argv); + bool const shouldContinue = CommonOptions::parse(_argc, _argv); - if (showHelp || !res) + if (showHelp || !shouldContinue) { std::cout << options << std::endl; return false; @@ -85,7 +85,7 @@ bool IsolTestOptions::parse(int _argc, char const* const* _argv) enforceGasTest = enforceGasTest || (evmVersion() == langutil::EVMVersion{} && !useABIEncoderV1); - return res; + return shouldContinue; } void IsolTestOptions::validate() const diff --git a/test/tools/isoltest.cpp b/test/tools/isoltest.cpp index 746cee7e6..a2ef564cb 100644 --- a/test/tools/isoltest.cpp +++ b/test/tools/isoltest.cpp @@ -433,8 +433,9 @@ int main(int argc, char const *argv[]) { auto options = std::make_unique(); - if (!options->parse(argc, argv)) - return -1; + bool shouldContinue = options->parse(argc, argv); + if (!shouldContinue) + return 0; options->validate(); CommonOptions::setSingleton(std::move(options));