Merge pull request #12436 from ethereum/testBatcher

Test batcher.
This commit is contained in:
chriseth
2022-01-04 16:21:56 +01:00
committed by GitHub
7 changed files with 204 additions and 69 deletions
+24 -8
View File
@@ -119,7 +119,8 @@ public:
TestCreator _testCaseCreator,
TestOptions const& _options,
fs::path const& _basepath,
fs::path const& _path
fs::path const& _path,
solidity::test::Batcher& _batcher
);
private:
enum class Request
@@ -269,7 +270,8 @@ TestStats TestTool::processPath(
TestCreator _testCaseCreator,
TestOptions const& _options,
fs::path const& _basepath,
fs::path const& _path
fs::path const& _path,
solidity::test::Batcher& _batcher
)
{
std::queue<fs::path> paths;
@@ -298,6 +300,11 @@ TestStats TestTool::processPath(
++testCount;
paths.pop();
}
else if (!_batcher.checkAndAdvance())
{
paths.pop();
++skippedCount;
}
else
{
++testCount;
@@ -373,7 +380,8 @@ std::optional<TestStats> runTestSuite(
TestOptions const& _options,
fs::path const& _basePath,
fs::path const& _subdirectory,
string const& _name
string const& _name,
solidity::test::Batcher& _batcher
)
{
fs::path testPath{_basePath / _subdirectory};
@@ -389,7 +397,8 @@ std::optional<TestStats> runTestSuite(
_testCaseCreator,
_options,
_basePath,
_subdirectory
_subdirectory,
_batcher
);
if (stats.skippedCount != stats.testCount)
@@ -415,21 +424,23 @@ std::optional<TestStats> runTestSuite(
int main(int argc, char const *argv[])
{
using namespace solidity::test;
try
{
setupTerminal();
{
auto options = std::make_unique<solidity::test::IsolTestOptions>();
auto options = std::make_unique<IsolTestOptions>();
if (!options->parse(argc, argv))
return -1;
options->validate();
solidity::test::CommonOptions::setSingleton(std::move(options));
CommonOptions::setSingleton(std::move(options));
}
auto& options = dynamic_cast<solidity::test::IsolTestOptions const&>(solidity::test::CommonOptions::get());
auto& options = dynamic_cast<IsolTestOptions const&>(CommonOptions::get());
if (!solidity::test::loadVMs(options))
return 1;
@@ -443,6 +454,10 @@ int main(int argc, char const *argv[])
TestStats global_stats{0, 0};
cout << "Running tests..." << endl << endl;
Batcher batcher(CommonOptions::get().selectedBatch, CommonOptions::get().batches);
if (CommonOptions::get().batches > 1)
cout << "Batch " << CommonOptions::get().selectedBatch << " out of " << CommonOptions::get().batches << endl;
// Actually run the tests.
// Interactive tests are added in InteractiveTests.h
for (auto const& ts: g_interactiveTestsuites)
@@ -458,7 +473,8 @@ int main(int argc, char const *argv[])
options,
options.testPath / ts.path,
ts.subpath,
ts.title
ts.title,
batcher
);
if (stats)
global_stats += *stats;