Change loading of VMs and error messages during test.

This commit is contained in:
Daniel Kirchner
2021-05-12 14:48:37 +02:00
parent 643140e2d6
commit 06a9199967
7 changed files with 112 additions and 107 deletions
+53 -61
View File
@@ -420,82 +420,74 @@ std::optional<TestStats> runTestSuite(
int main(int argc, char const *argv[])
{
setupTerminal();
try
{
auto options = std::make_unique<solidity::test::IsolTestOptions>(&TestTool::editor);
setupTerminal();
try
{
auto options = std::make_unique<solidity::test::IsolTestOptions>(&TestTool::editor);
if (!options->parse(argc, argv))
return -1;
options->validate();
solidity::test::CommonOptions::setSingleton(std::move(options));
}
catch (std::exception const& _exception)
{
cerr << _exception.what() << endl;
auto& options = dynamic_cast<solidity::test::IsolTestOptions const&>(solidity::test::CommonOptions::get());
if (!solidity::test::loadVMs(options))
return 1;
if (options.disableSemanticTests)
cout << endl << "--- SKIPPING ALL SEMANTICS TESTS ---" << endl << endl;
TestStats global_stats{0, 0};
cout << "Running tests..." << endl << endl;
// Actually run the tests.
// Interactive tests are added in InteractiveTests.h
for (auto const& ts: g_interactiveTestsuites)
{
if (ts.needsVM && options.disableSemanticTests)
continue;
if (ts.smt && options.disableSMT)
continue;
auto stats = runTestSuite(
ts.testCaseCreator,
options,
options.testPath / ts.path,
ts.subpath,
ts.title
);
if (stats)
global_stats += *stats;
else
return 1;
}
}
auto& options = dynamic_cast<solidity::test::IsolTestOptions const&>(solidity::test::CommonOptions::get());
cout << endl << "Summary: ";
AnsiColorized(cout, !options.noColor, {BOLD, global_stats ? GREEN : RED}) <<
global_stats.successCount << "/" << global_stats.testCount;
cout << " tests successful";
if (global_stats.skippedCount > 0)
{
cout << " (";
AnsiColorized(cout, !options.noColor, {BOLD, YELLOW}) << global_stats.skippedCount;
cout << " tests skipped)";
}
cout << "." << endl;
bool disableSemantics = true;
try
{
disableSemantics = !solidity::test::EVMHost::checkVmPaths(options.vmPaths);
if (options.disableSemanticTests)
cout << "\nNOTE: Skipped semantics tests.\n" << endl;
return global_stats ? 0 : 1;
}
catch (std::runtime_error const& _exception)
catch (std::exception const& _exception)
{
cerr << "Error: " << _exception.what() << endl;
cerr << _exception.what() << endl;
return 1;
}
if (disableSemantics)
cout << endl << "--- SKIPPING ALL SEMANTICS TESTS ---" << endl << endl;
TestStats global_stats{0, 0};
cout << "Running tests..." << endl << endl;
// Actually run the tests.
// Interactive tests are added in InteractiveTests.h
for (auto const& ts: g_interactiveTestsuites)
{
if (ts.needsVM && disableSemantics)
continue;
if (ts.smt && options.disableSMT)
continue;
auto stats = runTestSuite(
ts.testCaseCreator,
options,
options.testPath / ts.path,
ts.subpath,
ts.title
);
if (stats)
global_stats += *stats;
else
return 1;
}
cout << endl << "Summary: ";
AnsiColorized(cout, !options.noColor, {BOLD, global_stats ? GREEN : RED}) <<
global_stats.successCount << "/" << global_stats.testCount;
cout << " tests successful";
if (global_stats.skippedCount > 0)
{
cout << " (";
AnsiColorized(cout, !options.noColor, {BOLD, YELLOW}) << global_stats.skippedCount;
cout << " tests skipped)";
}
cout << "." << endl;
if (disableSemantics)
cout << "\nNOTE: Skipped semantics tests because no evmc vm could be found.\n" << endl;
return global_stats ? 0 : 1;
}