Use EXIT_FAILURE and EXIT_SUCCESS constants in exit() and when returning from main()

This commit is contained in:
Kamil Śliwak 2021-11-30 14:26:59 +01:00
parent 7c83559881
commit b3048ccf07
2 changed files with 11 additions and 11 deletions

View File

@ -235,10 +235,10 @@ test_suite* init_unit_test_suite(int /*argc*/, char* /*argv*/[])
{ {
bool shouldContinue = initializeOptions(); bool shouldContinue = initializeOptions();
if (!shouldContinue) if (!shouldContinue)
exit(0); exit(EXIT_SUCCESS);
if (!solidity::test::loadVMs(solidity::test::CommonOptions::get())) if (!solidity::test::loadVMs(solidity::test::CommonOptions::get()))
exit(1); exit(EXIT_FAILURE);
if (solidity::test::CommonOptions::get().disableSemanticTests) if (solidity::test::CommonOptions::get().disableSemanticTests)
cout << endl << "--- SKIPPING ALL SEMANTICS TESTS ---" << endl << endl; cout << endl << "--- SKIPPING ALL SEMANTICS TESTS ---" << endl << endl;
@ -298,12 +298,12 @@ test_suite* init_unit_test_suite(int /*argc*/, char* /*argv*/[])
catch (solidity::test::ConfigException const& exception) catch (solidity::test::ConfigException const& exception)
{ {
cerr << exception.what() << endl; cerr << exception.what() << endl;
exit(1); exit(EXIT_FAILURE);
} }
catch (std::runtime_error const& exception) catch (std::runtime_error const& exception)
{ {
cerr << exception.what() << endl; cerr << exception.what() << endl;
exit(1); exit(EXIT_FAILURE);
} }
return nullptr; return nullptr;

View File

@ -435,7 +435,7 @@ int main(int argc, char const *argv[])
bool shouldContinue = options->parse(argc, argv); bool shouldContinue = options->parse(argc, argv);
if (!shouldContinue) if (!shouldContinue)
return 0; return EXIT_SUCCESS;
options->validate(); options->validate();
CommonOptions::setSingleton(std::move(options)); CommonOptions::setSingleton(std::move(options));
@ -444,7 +444,7 @@ int main(int argc, char const *argv[])
auto& options = dynamic_cast<IsolTestOptions const&>(CommonOptions::get()); auto& options = dynamic_cast<IsolTestOptions const&>(CommonOptions::get());
if (!solidity::test::loadVMs(options)) if (!solidity::test::loadVMs(options))
return 1; return EXIT_FAILURE;
if (options.disableSemanticTests) if (options.disableSemanticTests)
cout << endl << "--- SKIPPING ALL SEMANTICS TESTS ---" << endl << endl; cout << endl << "--- SKIPPING ALL SEMANTICS TESTS ---" << endl << endl;
@ -480,7 +480,7 @@ int main(int argc, char const *argv[])
if (stats) if (stats)
global_stats += *stats; global_stats += *stats;
else else
return 1; return EXIT_FAILURE;
} }
cout << endl << "Summary: "; cout << endl << "Summary: ";
@ -498,22 +498,22 @@ int main(int argc, char const *argv[])
if (options.disableSemanticTests) if (options.disableSemanticTests)
cout << "\nNOTE: Skipped semantics tests.\n" << endl; cout << "\nNOTE: Skipped semantics tests.\n" << endl;
return global_stats ? 0 : 1; return global_stats ? EXIT_SUCCESS : EXIT_FAILURE;
} }
catch (boost::program_options::error const& exception) catch (boost::program_options::error const& exception)
{ {
cerr << exception.what() << endl; cerr << exception.what() << endl;
return 1; return EXIT_FAILURE;
} }
catch (std::runtime_error const& exception) catch (std::runtime_error const& exception)
{ {
cerr << exception.what() << endl; cerr << exception.what() << endl;
return 1; return EXIT_FAILURE;
} }
catch (...) catch (...)
{ {
cerr << "Unhandled exception caught." << endl; cerr << "Unhandled exception caught." << endl;
cerr << boost::current_exception_diagnostic_information() << endl; cerr << boost::current_exception_diagnostic_information() << endl;
return 1; return EXIT_FAILURE;
} }
} }