Skip to content
This repository was archived by the owner on Oct 28, 2021. It is now read-only.

Change exit calls to returns in testeth, closes #4667 #4971

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/tools/libtesteth/ImportTest.cpp
Original file line number Diff line number Diff line change
@@ -608,7 +608,7 @@ void ImportTest::checkAllowedNetwork(string const& _network)
// Can't use boost at this point
std::cerr << TestOutputHelper::get().testName() + " Specified Network not found: "
<< _network << "\n";
exit(1);
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The caller of this function should terminate the test when this happens.

}
}

16 changes: 8 additions & 8 deletions test/tools/libtesteth/Options.cpp
Original file line number Diff line number Diff line change
@@ -127,12 +127,12 @@ Options::Options(int argc, const char** argv)
if (arg == "--help")
{
printHelp();
exit(0);
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure that the process terminates when this constructor takes this path.

}
else if (arg == "--version")
{
printVersion();
exit(0);
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure that the process terminates after the execution takes this path.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can throw an exception instead of silently returning.

}
else if (arg == "--vm" || arg == "--evmc")
{
@@ -147,7 +147,7 @@ Options::Options(int argc, const char** argv)
g_logVerbosity = 13;
#else
cerr << "--vmtrace option requires a build with cmake -DVMTRACE=1\n";
exit(1);
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure that the process terminates after the execution takes this path.

#endif
}
else if (arg == "--jsontrace")
@@ -232,7 +232,7 @@ Options::Options(int argc, const char** argv)
else
{
std::cerr << "Options file not found! Default options at: tests/src/randomCodeOptions.json\n";
exit(0);
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

}
}
else if (arg == "-t")
@@ -272,11 +272,11 @@ Options::Options(int argc, const char** argv)
if (maxCodes > 1000 || maxCodes <= 0)
{
cerr << "Argument for the option is invalid! (use range: 1...1000)\n";
exit(1);
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

}
test::RandomCodeOptions options;
cout << test::RandomCode::get().generate(maxCodes, options) << "\n";
exit(0);
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

}
else if (arg == "--createRandomTest")
{
@@ -309,7 +309,7 @@ Options::Options(int argc, const char** argv)
else if (seenSeparator)
{
cerr << "Unknown option: " + arg << "\n";
exit(1);
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

}
}

@@ -322,7 +322,7 @@ Options::Options(int argc, const char** argv)
cerr << "--createRandomTest cannot be used with any of the options: " <<
"trValueIndex, trGasIndex, trDataIndex, nonetwork, singleTest, all, " <<
"stats, filltests, fillchain \n";
exit(1);
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

}
}
else
2 changes: 1 addition & 1 deletion test/tools/libtesteth/boostTest.cpp
Original file line number Diff line number Diff line change
@@ -136,7 +136,7 @@ int main(int argc, const char* argv[])
catch (dev::test::InvalidOption const& e)
{
std::cerr << *boost::get_error_info<errinfo_comment>(e) << "\n";
exit(1);
return 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is fine.

}

dev::test::Options const& opt = dev::test::Options::get();