mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
soltest: Handle CLI validation errors gracefully
This commit is contained in:
parent
cf6704ae06
commit
7c83559881
@ -159,6 +159,8 @@ bool CommonOptions::parse(int argc, char const* const* argv)
|
||||
po::variables_map arguments;
|
||||
addOptions();
|
||||
|
||||
try
|
||||
{
|
||||
po::command_line_parser cmdLineParser(argc, argv);
|
||||
cmdLineParser.options(options);
|
||||
auto parsedOptions = cmdLineParser.run();
|
||||
@ -179,6 +181,11 @@ bool CommonOptions::parse(int argc, char const* const* argv)
|
||||
errorMessage << token;
|
||||
BOOST_THROW_EXCEPTION(std::runtime_error(errorMessage.str()));
|
||||
}
|
||||
}
|
||||
catch (po::error const& exception)
|
||||
{
|
||||
solThrow(ConfigException, exception.what());
|
||||
}
|
||||
|
||||
if (vmPaths.empty())
|
||||
{
|
||||
|
@ -222,15 +222,17 @@ bool initializeOptions()
|
||||
|
||||
// TODO: Prototype -- why isn't this declared in the boost headers?
|
||||
// TODO: replace this with a (global) fixture.
|
||||
test_suite* init_unit_test_suite( int /*argc*/, char* /*argv*/[] );
|
||||
test_suite* init_unit_test_suite(int /*argc*/, char* /*argv*/[]);
|
||||
|
||||
test_suite* init_unit_test_suite( int /*argc*/, char* /*argv*/[] )
|
||||
test_suite* init_unit_test_suite(int /*argc*/, char* /*argv*/[])
|
||||
{
|
||||
using namespace solidity::test;
|
||||
|
||||
master_test_suite_t& master = framework::master_test_suite();
|
||||
master.p_name.value = "SolidityTests";
|
||||
|
||||
try
|
||||
{
|
||||
bool shouldContinue = initializeOptions();
|
||||
if (!shouldContinue)
|
||||
exit(0);
|
||||
@ -292,6 +294,17 @@ test_suite* init_unit_test_suite( int /*argc*/, char* /*argv*/[] )
|
||||
})
|
||||
removeTestSuite(suite);
|
||||
}
|
||||
}
|
||||
catch (solidity::test::ConfigException const& exception)
|
||||
{
|
||||
cerr << exception.what() << endl;
|
||||
exit(1);
|
||||
}
|
||||
catch (std::runtime_error const& exception)
|
||||
{
|
||||
cerr << exception.what() << endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user