mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Always count all test cases in isoltest and exit early on user request.
This commit is contained in:
parent
d7756322c0
commit
a6df7b1fb8
@ -45,8 +45,8 @@ namespace fs = boost::filesystem;
|
|||||||
struct TestStats
|
struct TestStats
|
||||||
{
|
{
|
||||||
int successCount;
|
int successCount;
|
||||||
int runCount;
|
int testCount;
|
||||||
operator bool() const { return successCount == runCount; }
|
operator bool() const { return successCount == testCount; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class TestTool
|
class TestTool
|
||||||
@ -92,9 +92,11 @@ private:
|
|||||||
string const m_name;
|
string const m_name;
|
||||||
fs::path const m_path;
|
fs::path const m_path;
|
||||||
unique_ptr<TestCase> m_test;
|
unique_ptr<TestCase> m_test;
|
||||||
|
static bool m_exitRequested;
|
||||||
};
|
};
|
||||||
|
|
||||||
string TestTool::editor;
|
string TestTool::editor;
|
||||||
|
bool TestTool::m_exitRequested = false;
|
||||||
|
|
||||||
TestTool::Result TestTool::process()
|
TestTool::Result TestTool::process()
|
||||||
{
|
{
|
||||||
@ -195,7 +197,7 @@ TestStats TestTool::processPath(
|
|||||||
std::queue<fs::path> paths;
|
std::queue<fs::path> paths;
|
||||||
paths.push(_path);
|
paths.push(_path);
|
||||||
int successCount = 0;
|
int successCount = 0;
|
||||||
int runCount = 0;
|
int testCount = 0;
|
||||||
|
|
||||||
while (!paths.empty())
|
while (!paths.empty())
|
||||||
{
|
{
|
||||||
@ -212,10 +214,15 @@ TestStats TestTool::processPath(
|
|||||||
if (fs::is_directory(entry.path()) || TestCase::isTestFilename(entry.path().filename()))
|
if (fs::is_directory(entry.path()) || TestCase::isTestFilename(entry.path().filename()))
|
||||||
paths.push(currentPath / entry.path().filename());
|
paths.push(currentPath / entry.path().filename());
|
||||||
}
|
}
|
||||||
|
else if (m_exitRequested)
|
||||||
|
{
|
||||||
|
++testCount;
|
||||||
|
paths.pop();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
++testCount;
|
||||||
TestTool testTool(_testCaseCreator, currentPath.string(), fullpath, _formatted);
|
TestTool testTool(_testCaseCreator, currentPath.string(), fullpath, _formatted);
|
||||||
++runCount;
|
|
||||||
auto result = testTool.process();
|
auto result = testTool.process();
|
||||||
|
|
||||||
switch(result)
|
switch(result)
|
||||||
@ -225,10 +232,12 @@ TestStats TestTool::processPath(
|
|||||||
switch(testTool.handleResponse(result == Result::Exception))
|
switch(testTool.handleResponse(result == Result::Exception))
|
||||||
{
|
{
|
||||||
case Request::Quit:
|
case Request::Quit:
|
||||||
return { successCount, runCount };
|
paths.pop();
|
||||||
|
m_exitRequested = true;
|
||||||
|
break;
|
||||||
case Request::Rerun:
|
case Request::Rerun:
|
||||||
cout << "Re-running test case..." << endl;
|
cout << "Re-running test case..." << endl;
|
||||||
--runCount;
|
--testCount;
|
||||||
break;
|
break;
|
||||||
case Request::Skip:
|
case Request::Skip:
|
||||||
paths.pop();
|
paths.pop();
|
||||||
@ -243,7 +252,7 @@ TestStats TestTool::processPath(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return { successCount, runCount };
|
return { successCount, testCount };
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,10 +356,10 @@ Allowed options)",
|
|||||||
|
|
||||||
cout << endl << "Syntax Test Summary: ";
|
cout << endl << "Syntax Test Summary: ";
|
||||||
FormattedScope(cout, formatted, {BOLD, stats ? GREEN : RED}) <<
|
FormattedScope(cout, formatted, {BOLD, stats ? GREEN : RED}) <<
|
||||||
stats.successCount << "/" << stats.runCount;
|
stats.successCount << "/" << stats.testCount;
|
||||||
cout << " tests successful." << endl << endl;
|
cout << " tests successful." << endl << endl;
|
||||||
|
|
||||||
global_stats.runCount += stats.runCount;
|
global_stats.testCount += stats.testCount;
|
||||||
global_stats.successCount += stats.successCount;
|
global_stats.successCount += stats.successCount;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -367,10 +376,10 @@ Allowed options)",
|
|||||||
|
|
||||||
cout << endl << "JSON AST Test Summary: ";
|
cout << endl << "JSON AST Test Summary: ";
|
||||||
FormattedScope(cout, formatted, {BOLD, stats ? GREEN : RED}) <<
|
FormattedScope(cout, formatted, {BOLD, stats ? GREEN : RED}) <<
|
||||||
stats.successCount << "/" << stats.runCount;
|
stats.successCount << "/" << stats.testCount;
|
||||||
cout << " tests successful." << endl << endl;
|
cout << " tests successful." << endl << endl;
|
||||||
|
|
||||||
global_stats.runCount += stats.runCount;
|
global_stats.testCount += stats.testCount;
|
||||||
global_stats.successCount += stats.successCount;
|
global_stats.successCount += stats.successCount;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -381,7 +390,7 @@ Allowed options)",
|
|||||||
|
|
||||||
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.runCount;
|
global_stats.successCount << "/" << global_stats.testCount;
|
||||||
cout << " tests successful." << endl;
|
cout << " tests successful." << endl;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user