mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Have only one source where testsuits are defined
This commit is contained in:
parent
871ea22bb9
commit
55d7d327c4
63
test/InteractiveTests.h
Normal file
63
test/InteractiveTests.h
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
This file is part of solidity.
|
||||||
|
|
||||||
|
solidity is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
solidity is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <test/TestCase.h>
|
||||||
|
#include <test/libsolidity/ASTJSONTest.h>
|
||||||
|
#include <test/libsolidity/SyntaxTest.h>
|
||||||
|
#include <test/libsolidity/SMTCheckerJSONTest.h>
|
||||||
|
#include <test/libyul/YulOptimizerTest.h>
|
||||||
|
#include <test/libyul/ObjectCompilerTest.h>
|
||||||
|
|
||||||
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
|
namespace dev
|
||||||
|
{
|
||||||
|
namespace solidity
|
||||||
|
{
|
||||||
|
namespace test
|
||||||
|
{
|
||||||
|
|
||||||
|
/** Container for all information regarding a testsuite */
|
||||||
|
struct Testsuite
|
||||||
|
{
|
||||||
|
char const* title;
|
||||||
|
boost::filesystem::path const path;
|
||||||
|
boost::filesystem::path const subpath;
|
||||||
|
bool smt;
|
||||||
|
bool ipc;
|
||||||
|
TestCase::TestCaseCreator testCaseCreator;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/// Array of testsuits that can be run interactively as well as automatically
|
||||||
|
Testsuite const g_interactiveTestsuites[] = {
|
||||||
|
/*
|
||||||
|
Title Path Subpath SMT IPC Creator function */
|
||||||
|
{"Yul Optimizer", "libyul", "yulOptimizerTests", false, false, &yul::test::YulOptimizerTest::create},
|
||||||
|
{"Yul Object Compiler", "libyul", "objectCompiler", false, false, &yul::test::ObjectCompilerTest::create},
|
||||||
|
{"Syntax", "libsolidity", "syntaxTests", false, false, &SyntaxTest::create},
|
||||||
|
{"JSON AST", "libsolidity", "ASTJSON", false, false, &ASTJSONTest::create},
|
||||||
|
{"SMT Checker", "libsolidity", "smtCheckerTests", true, false, &SyntaxTest::create},
|
||||||
|
{"SMT Checker JSON", "libsolidity", "smtCheckerTestsJSON", true, false, &SMTCheckerTest::create}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -35,16 +35,13 @@
|
|||||||
|
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
|
#include <test/InteractiveTests.h>
|
||||||
#include <test/Options.h>
|
#include <test/Options.h>
|
||||||
#include <test/libsolidity/ASTJSONTest.h>
|
|
||||||
#include <test/libsolidity/SyntaxTest.h>
|
|
||||||
#include <test/libsolidity/SMTCheckerJSONTest.h>
|
|
||||||
#include <test/libyul/YulOptimizerTest.h>
|
|
||||||
#include <test/libyul/ObjectCompilerTest.h>
|
|
||||||
|
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
#include <boost/algorithm/string/predicate.hpp>
|
#include <boost/algorithm/string/predicate.hpp>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
using namespace boost::unit_test;
|
using namespace boost::unit_test;
|
||||||
using namespace dev::solidity::test;
|
using namespace dev::solidity::test;
|
||||||
@ -129,46 +126,26 @@ test_suite* init_unit_test_suite( int /*argc*/, char* /*argv*/[] )
|
|||||||
master_test_suite_t& master = framework::master_test_suite();
|
master_test_suite_t& master = framework::master_test_suite();
|
||||||
master.p_name.value = "SolidityTests";
|
master.p_name.value = "SolidityTests";
|
||||||
dev::test::Options::get().validate();
|
dev::test::Options::get().validate();
|
||||||
solAssert(registerTests(
|
|
||||||
master,
|
// Include the interactive tests in the automatic tests as well
|
||||||
dev::test::Options::get().testPath / "libsolidity",
|
for (auto const& ts: g_interactiveTestsuites)
|
||||||
"syntaxTests",
|
|
||||||
SyntaxTest::create
|
|
||||||
) > 0, "no syntax tests found");
|
|
||||||
solAssert(registerTests(
|
|
||||||
master,
|
|
||||||
dev::test::Options::get().testPath / "libsolidity",
|
|
||||||
"ASTJSON",
|
|
||||||
ASTJSONTest::create
|
|
||||||
) > 0, "no JSON AST tests found");
|
|
||||||
solAssert(registerTests(
|
|
||||||
master,
|
|
||||||
dev::test::Options::get().testPath / "libyul",
|
|
||||||
"yulOptimizerTests",
|
|
||||||
yul::test::YulOptimizerTest::create
|
|
||||||
) > 0, "no Yul Optimizer tests found");
|
|
||||||
solAssert(registerTests(
|
|
||||||
master,
|
|
||||||
dev::test::Options::get().testPath / "libyul",
|
|
||||||
"objectCompiler",
|
|
||||||
yul::test::ObjectCompilerTest::create
|
|
||||||
) > 0, "no Yul Object compiler tests found");
|
|
||||||
if (!dev::test::Options::get().disableSMT)
|
|
||||||
{
|
{
|
||||||
solAssert(registerTests(
|
auto const& options = dev::test::Options::get();
|
||||||
master,
|
|
||||||
dev::test::Options::get().testPath / "libsolidity",
|
if (ts.smt && options.disableSMT)
|
||||||
"smtCheckerTests",
|
continue;
|
||||||
SyntaxTest::create
|
|
||||||
) > 0, "no SMT checker tests found");
|
if (ts.ipc && options.disableIPC)
|
||||||
|
continue;
|
||||||
|
|
||||||
solAssert(registerTests(
|
solAssert(registerTests(
|
||||||
master,
|
master,
|
||||||
dev::test::Options::get().testPath / "libsolidity",
|
options.testPath / ts.path,
|
||||||
"smtCheckerTestsJSON",
|
ts.subpath,
|
||||||
SMTCheckerTest::create
|
ts.testCaseCreator
|
||||||
) > 0, "no SMT checker JSON tests found");
|
) > 0, std::string("no ") + ts.title + " tests found");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dev::test::Options::get().disableIPC)
|
if (dev::test::Options::get().disableIPC)
|
||||||
{
|
{
|
||||||
for (auto suite: {
|
for (auto suite: {
|
||||||
@ -188,6 +165,7 @@ test_suite* init_unit_test_suite( int /*argc*/, char* /*argv*/[] )
|
|||||||
})
|
})
|
||||||
removeTestSuite(suite);
|
removeTestSuite(suite);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dev::test::Options::get().disableSMT)
|
if (dev::test::Options::get().disableSMT)
|
||||||
removeTestSuite("SMTChecker");
|
removeTestSuite("SMTChecker");
|
||||||
|
|
||||||
|
@ -19,11 +19,7 @@
|
|||||||
|
|
||||||
#include <test/Common.h>
|
#include <test/Common.h>
|
||||||
#include <test/libsolidity/AnalysisFramework.h>
|
#include <test/libsolidity/AnalysisFramework.h>
|
||||||
#include <test/libsolidity/SyntaxTest.h>
|
#include <test/InteractiveTests.h>
|
||||||
#include <test/libsolidity/ASTJSONTest.h>
|
|
||||||
#include <test/libsolidity/SMTCheckerJSONTest.h>
|
|
||||||
#include <test/libyul/YulOptimizerTest.h>
|
|
||||||
#include <test/libyul/ObjectCompilerTest.h>
|
|
||||||
|
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
#include <boost/algorithm/string/replace.hpp>
|
#include <boost/algorithm/string/replace.hpp>
|
||||||
@ -380,59 +376,13 @@ Allowed options)",
|
|||||||
TestStats global_stats{0, 0};
|
TestStats global_stats{0, 0};
|
||||||
|
|
||||||
// Actually run the tests.
|
// Actually run the tests.
|
||||||
// If you add new tests here, you also have to add them in boostTest.cpp
|
// Interactive tests are added in InteractiveTests.h
|
||||||
if (auto stats = runTestSuite("Syntax", testPath / "libsolidity", "syntaxTests", SyntaxTest::create, formatted))
|
for (auto const& ts: g_interactiveTestsuites)
|
||||||
global_stats += *stats;
|
|
||||||
else
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (auto stats = runTestSuite("JSON AST", testPath / "libsolidity", "ASTJSON", ASTJSONTest::create, formatted))
|
|
||||||
global_stats += *stats;
|
|
||||||
else
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (auto stats = runTestSuite(
|
|
||||||
"Yul Optimizer",
|
|
||||||
testPath / "libyul",
|
|
||||||
"yulOptimizerTests",
|
|
||||||
yul::test::YulOptimizerTest::create,
|
|
||||||
formatted
|
|
||||||
))
|
|
||||||
global_stats += *stats;
|
|
||||||
else
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (auto stats = runTestSuite(
|
|
||||||
"Yul Object Compiler",
|
|
||||||
testPath / "libyul",
|
|
||||||
"objectCompiler",
|
|
||||||
yul::test::ObjectCompilerTest::create,
|
|
||||||
formatted
|
|
||||||
))
|
|
||||||
global_stats += *stats;
|
|
||||||
else
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (!disableSMT)
|
|
||||||
{
|
{
|
||||||
if (auto stats = runTestSuite(
|
if (ts.smt && disableSMT)
|
||||||
"SMT Checker",
|
continue;
|
||||||
testPath / "libsolidity",
|
|
||||||
"smtCheckerTests",
|
|
||||||
SyntaxTest::create,
|
|
||||||
formatted
|
|
||||||
))
|
|
||||||
global_stats += *stats;
|
|
||||||
else
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (auto stats = runTestSuite(
|
if (auto stats = runTestSuite(ts.title, testPath / ts.path, ts.subpath, ts.testCaseCreator, formatted))
|
||||||
"SMT Checker JSON",
|
|
||||||
testPath / "libsolidity",
|
|
||||||
"smtCheckerTestsJSON",
|
|
||||||
SMTCheckerTest::create,
|
|
||||||
formatted
|
|
||||||
))
|
|
||||||
global_stats += *stats;
|
global_stats += *stats;
|
||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user