Infrastructure for extracting JSON AST tests.

This commit is contained in:
Daniel Kirchner
2018-08-03 20:35:50 +02:00
parent 0b20e4fd22
commit d923926ff7
5 changed files with 302 additions and 4 deletions
+1 -1
View File
@@ -3,5 +3,5 @@ target_link_libraries(solfuzzer PRIVATE libsolc evmasm ${Boost_PROGRAM_OPTIONS_L
add_executable(isoltest isoltest.cpp ../Options.cpp ../libsolidity/TestCase.cpp ../libsolidity/SyntaxTest.cpp
../libsolidity/AnalysisFramework.cpp ../libsolidity/SolidityExecutionFramework.cpp ../ExecutionFramework.cpp
../RPCSession.cpp)
../RPCSession.cpp ../libsolidity/ASTJSONTest.cpp)
target_link_libraries(isoltest PRIVATE libsolc solidity evmasm ${Boost_PROGRAM_OPTIONS_LIBRARIES} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES})
+35 -3
View File
@@ -18,6 +18,7 @@
#include <libdevcore/CommonIO.h>
#include <test/libsolidity/AnalysisFramework.h>
#include <test/libsolidity/SyntaxTest.h>
#include <test/libsolidity/ASTJSONTest.h>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/replace.hpp>
@@ -336,22 +337,53 @@ Allowed options)",
}
}
TestStats global_stats { 0, 0 };
fs::path syntaxTestPath = testPath / "libsolidity" / "syntaxTests";
if (fs::exists(syntaxTestPath) && fs::is_directory(syntaxTestPath))
{
auto stats = TestTool::processPath(SyntaxTest::create, testPath / "libsolidity", "syntaxTests", formatted);
cout << endl << "Summary: ";
cout << endl << "Syntax Test Summary: ";
FormattedScope(cout, formatted, {BOLD, stats ? GREEN : RED}) <<
stats.successCount << "/" << stats.runCount;
cout << " tests successful." << endl;
cout << " tests successful." << endl << endl;
return stats ? 0 : 1;
global_stats.runCount += stats.runCount;
global_stats.successCount += stats.successCount;
}
else
{
cerr << "Syntax tests not found. Use the --testpath argument." << endl;
return 1;
}
fs::path astJsonTestPath = testPath / "libsolidity" / "ASTJSON";
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.runCount;
cout << " tests successful." << endl << endl;
global_stats.runCount += stats.runCount;
global_stats.successCount += stats.successCount;
}
else
{
cerr << "JSON AST tests not found." << endl;
return 1;
}
cout << endl << "Summary: ";
FormattedScope(cout, formatted, {BOLD, global_stats ? GREEN : RED}) <<
global_stats.successCount << "/" << global_stats.runCount;
cout << " tests successful." << endl;
return global_stats ? 0 : 1;
}