mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Create state test with commandline flag
This commit is contained in:
parent
d010b15523
commit
508b7f14d8
@ -27,8 +27,6 @@
|
|||||||
#include <libethereum/Client.h>
|
#include <libethereum/Client.h>
|
||||||
#include <liblll/Compiler.h>
|
#include <liblll/Compiler.h>
|
||||||
|
|
||||||
//#define FILL_TESTS
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dev::eth;
|
using namespace dev::eth;
|
||||||
|
|
||||||
@ -351,28 +349,33 @@ void executeTests(const string& _name, const string& _testPathAppendix, std::fun
|
|||||||
string testPath = getTestPath();
|
string testPath = getTestPath();
|
||||||
testPath += _testPathAppendix;
|
testPath += _testPathAppendix;
|
||||||
|
|
||||||
#ifdef FILL_TESTS
|
for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i)
|
||||||
try
|
|
||||||
{
|
{
|
||||||
cnote << "Populating tests...";
|
string arg = boost::unit_test::framework::master_test_suite().argv[i];
|
||||||
json_spirit::mValue v;
|
if (arg == "--createtest")
|
||||||
boost::filesystem::path p(__FILE__);
|
{
|
||||||
boost::filesystem::path dir = p.parent_path();
|
try
|
||||||
string s = asString(dev::contents(dir.string() + "/" + _name + "Filler.json"));
|
{
|
||||||
BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of " + dir.string() + "/" + _name + "Filler.json is empty.");
|
cnote << "Populating tests...";
|
||||||
json_spirit::read_string(s, v);
|
json_spirit::mValue v;
|
||||||
doTests(v, true);
|
boost::filesystem::path p(__FILE__);
|
||||||
writeFile(testPath + "/" + _name + ".json", asBytes(json_spirit::write_string(v, true)));
|
boost::filesystem::path dir = p.parent_path();
|
||||||
|
string s = asString(dev::contents(dir.string() + "/" + _name + "Filler.json"));
|
||||||
|
BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of " + dir.string() + "/" + _name + "Filler.json is empty.");
|
||||||
|
json_spirit::read_string(s, v);
|
||||||
|
doTests(v, true);
|
||||||
|
writeFile(testPath + "/" + _name + ".json", asBytes(json_spirit::write_string(v, true)));
|
||||||
|
}
|
||||||
|
catch (Exception const& _e)
|
||||||
|
{
|
||||||
|
BOOST_ERROR("Failed test with Exception: " << diagnostic_information(_e));
|
||||||
|
}
|
||||||
|
catch (std::exception const& _e)
|
||||||
|
{
|
||||||
|
BOOST_ERROR("Failed test with Exception: " << _e.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception const& _e)
|
|
||||||
{
|
|
||||||
BOOST_ERROR("Failed test with Exception: " << diagnostic_information(_e));
|
|
||||||
}
|
|
||||||
catch (std::exception const& _e)
|
|
||||||
{
|
|
||||||
BOOST_ERROR("Failed test with Exception: " << _e.what());
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
34
state.cpp
34
state.cpp
@ -122,6 +122,40 @@ BOOST_AUTO_TEST_CASE(stPreCompiledContracts)
|
|||||||
dev::test::executeTests("stPreCompiledContracts", "/StateTests", dev::test::doStateTests);
|
dev::test::executeTests("stPreCompiledContracts", "/StateTests", dev::test::doStateTests);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(stCreateTest)
|
||||||
|
{
|
||||||
|
for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i)
|
||||||
|
{
|
||||||
|
string arg = boost::unit_test::framework::master_test_suite().argv[i];
|
||||||
|
if (arg == "--createtest")
|
||||||
|
{
|
||||||
|
if (boost::unit_test::framework::master_test_suite().argc <= i + 2)
|
||||||
|
{
|
||||||
|
cnote << "usage: ./testeth --createtest <PathToConstructor> <PathToDestiny>\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
cnote << "Populating tests...";
|
||||||
|
json_spirit::mValue v;
|
||||||
|
string s = asString(dev::contents(boost::unit_test::framework::master_test_suite().argv[i + 1]));
|
||||||
|
BOOST_REQUIRE_MESSAGE(s.length() > 0, "Content of " + (string)boost::unit_test::framework::master_test_suite().argv[i + 1] + " is empty.");
|
||||||
|
json_spirit::read_string(s, v);
|
||||||
|
dev::test::doStateTests(v, true);
|
||||||
|
writeFile(boost::unit_test::framework::master_test_suite().argv[i + 2], asBytes(json_spirit::write_string(v, true)));
|
||||||
|
}
|
||||||
|
catch (Exception const& _e)
|
||||||
|
{
|
||||||
|
BOOST_ERROR("Failed state test with Exception: " << diagnostic_information(_e));
|
||||||
|
}
|
||||||
|
catch (std::exception const& _e)
|
||||||
|
{
|
||||||
|
BOOST_ERROR("Failed state test with Exception: " << _e.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(userDefinedFileState)
|
BOOST_AUTO_TEST_CASE(userDefinedFileState)
|
||||||
{
|
{
|
||||||
dev::test::userDefinedTest("--statetest", dev::test::doStateTests);
|
dev::test::userDefinedTest("--statetest", dev::test::doStateTests);
|
||||||
|
Loading…
Reference in New Issue
Block a user