mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Extract test suite runs.
This commit is contained in:
parent
9081f803c7
commit
50247dc8d1
@ -47,6 +47,12 @@ struct TestStats
|
|||||||
int successCount;
|
int successCount;
|
||||||
int testCount;
|
int testCount;
|
||||||
operator bool() const { return successCount == testCount; }
|
operator bool() const { return successCount == testCount; }
|
||||||
|
TestStats& operator+=(TestStats const& _other)
|
||||||
|
{
|
||||||
|
successCount += _other.successCount;
|
||||||
|
testCount += _other.testCount;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class TestTool
|
class TestTool
|
||||||
@ -298,6 +304,34 @@ fs::path discoverTestPath()
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boost::optional<TestStats> runTestSuite(
|
||||||
|
string const& _name,
|
||||||
|
fs::path const& _basePath,
|
||||||
|
fs::path const& _subdirectory,
|
||||||
|
TestCase::TestCaseCreator _testCaseCreator,
|
||||||
|
bool _formatted
|
||||||
|
)
|
||||||
|
{
|
||||||
|
fs::path testPath = _basePath / _subdirectory;
|
||||||
|
|
||||||
|
if (!fs::exists(testPath) || !fs::is_directory(testPath))
|
||||||
|
{
|
||||||
|
cerr << _name << " tests not found. Use the --testpath argument." << endl;
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
TestStats stats = TestTool::processPath(_testCaseCreator, _basePath, _subdirectory, _formatted);
|
||||||
|
|
||||||
|
cout << endl << _name << " Test Summary: ";
|
||||||
|
FormattedScope(cout, _formatted, {BOLD, stats ? GREEN : RED}) <<
|
||||||
|
stats.successCount <<
|
||||||
|
"/" <<
|
||||||
|
stats.testCount;
|
||||||
|
cout << " tests successful." << endl << endl;
|
||||||
|
|
||||||
|
return stats;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
@ -352,53 +386,22 @@ Allowed options)",
|
|||||||
if (testPath.empty())
|
if (testPath.empty())
|
||||||
testPath = discoverTestPath();
|
testPath = discoverTestPath();
|
||||||
|
|
||||||
TestStats global_stats { 0, 0 };
|
TestStats global_stats{0, 0};
|
||||||
|
|
||||||
fs::path syntaxTestPath = testPath / "libsolidity" / "syntaxTests";
|
if (auto stats = runTestSuite("Syntax", testPath / "libsolidity", "syntaxTests", SyntaxTest::create, formatted))
|
||||||
|
global_stats += *stats;
|
||||||
if (fs::exists(syntaxTestPath) && fs::is_directory(syntaxTestPath))
|
|
||||||
{
|
|
||||||
auto stats = TestTool::processPath(SyntaxTest::create, testPath / "libsolidity", "syntaxTests", formatted);
|
|
||||||
|
|
||||||
cout << endl << "Syntax Test Summary: ";
|
|
||||||
FormattedScope(cout, formatted, {BOLD, stats ? GREEN : RED}) <<
|
|
||||||
stats.successCount << "/" << stats.testCount;
|
|
||||||
cout << " tests successful." << endl << endl;
|
|
||||||
|
|
||||||
global_stats.testCount += stats.testCount;
|
|
||||||
global_stats.successCount += stats.successCount;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
cerr << "Syntax tests not found. Use the --testpath argument." << endl;
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
|
|
||||||
fs::path astJsonTestPath = testPath / "libsolidity" / "ASTJSON";
|
if (auto stats = runTestSuite("JSON AST", testPath / "libsolidity", "ASTJSON", ASTJSONTest::create, formatted))
|
||||||
|
global_stats += *stats;
|
||||||
if (fs::exists(astJsonTestPath) && fs::is_directory(astJsonTestPath))
|
|
||||||
{
|
|
||||||
auto stats = TestTool::processPath(ASTJSONTest::create, testPath / "libsolidity", "ASTJSON", formatted);
|
|
||||||
|
|
||||||
cout << endl << "JSON AST Test Summary: ";
|
|
||||||
FormattedScope(cout, formatted, {BOLD, stats ? GREEN : RED}) <<
|
|
||||||
stats.successCount << "/" << stats.testCount;
|
|
||||||
cout << " tests successful." << endl << endl;
|
|
||||||
|
|
||||||
global_stats.testCount += stats.testCount;
|
|
||||||
global_stats.successCount += stats.successCount;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
cerr << "JSON AST tests not found." << endl;
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
|
|
||||||
cout << endl << "Summary: ";
|
cout << endl << "Summary: ";
|
||||||
FormattedScope(cout, formatted, {BOLD, global_stats ? GREEN : RED}) <<
|
FormattedScope(cout, formatted, {BOLD, global_stats ? GREEN : RED}) <<
|
||||||
global_stats.successCount << "/" << global_stats.testCount;
|
global_stats.successCount << "/" << global_stats.testCount;
|
||||||
cout << " tests successful." << endl;
|
cout << " tests successful." << endl;
|
||||||
|
|
||||||
|
|
||||||
return global_stats ? 0 : 1;
|
return global_stats ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user