aboutsummaryrefslogtreecommitdiffstats
path: root/TestHelper.cpp
diff options
context:
space:
mode:
authorPaweł Bylica <pawel.bylica@imapp.pl>2015-05-20 23:34:09 +0800
committerPaweł Bylica <pawel.bylica@imapp.pl>2015-05-20 23:34:09 +0800
commitb85345cc913a4c3713705925438d5069331aa6f4 (patch)
tree8f0cfbe73fecf9f95d2a131c0d4fce7c88c0a5da /TestHelper.cpp
parentd5841327a2f0d8a990082bf4c16597e2b1f85926 (diff)
parentb0d5cbf6983030c4e4fb48c45e1602880069b063 (diff)
downloaddexon-solidity-b85345cc913a4c3713705925438d5069331aa6f4.tar
dexon-solidity-b85345cc913a4c3713705925438d5069331aa6f4.tar.gz
dexon-solidity-b85345cc913a4c3713705925438d5069331aa6f4.tar.bz2
dexon-solidity-b85345cc913a4c3713705925438d5069331aa6f4.tar.lz
dexon-solidity-b85345cc913a4c3713705925438d5069331aa6f4.tar.xz
dexon-solidity-b85345cc913a4c3713705925438d5069331aa6f4.tar.zst
dexon-solidity-b85345cc913a4c3713705925438d5069331aa6f4.zip
Merge remote-tracking branch 'upstream/develop' into feature/vm_gas_counter_refactor
Conflicts: libethereum/ExtVM.cpp libevm/SmartVM.h libevm/VM.cpp libevm/VM.h libevm/VMFace.h
Diffstat (limited to 'TestHelper.cpp')
-rw-r--r--TestHelper.cpp105
1 files changed, 58 insertions, 47 deletions
diff --git a/TestHelper.cpp b/TestHelper.cpp
index dede4703..aada8304 100644
--- a/TestHelper.cpp
+++ b/TestHelper.cpp
@@ -549,58 +549,53 @@ void checkCallCreates(eth::Transactions _resultCallCreates, eth::Transactions _e
}
}
-void userDefinedTest(string testTypeFlag, std::function<void(json_spirit::mValue&, bool)> doTests)
+void userDefinedTest(std::function<void(json_spirit::mValue&, bool)> doTests)
{
- Options::get(); // parse command line options, e.g. to enable JIT
+ if (!Options::get().singleTest)
+ return;
- for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i)
+ if (Options::get().singleTestFile.empty() || Options::get().singleTestName.empty())
{
- string arg = boost::unit_test::framework::master_test_suite().argv[i];
- if (arg == testTypeFlag)
- {
- if (boost::unit_test::framework::master_test_suite().argc <= i + 2)
- {
- cnote << "Missing filename\nUsage: testeth " << testTypeFlag << " <filename> <testname>\n";
- return;
- }
- string filename = boost::unit_test::framework::master_test_suite().argv[i + 1];
- string testname = boost::unit_test::framework::master_test_suite().argv[i + 2];
- int currentVerbosity = g_logVerbosity;
- g_logVerbosity = 12;
- try
- {
- cnote << "Testing user defined test: " << filename;
- json_spirit::mValue v;
- string s = asString(contents(filename));
- BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of " + filename + " is empty. ");
- json_spirit::read_string(s, v);
- json_spirit::mObject oSingleTest;
-
- json_spirit::mObject::const_iterator pos = v.get_obj().find(testname);
- if (pos == v.get_obj().end())
- {
- cnote << "Could not find test: " << testname << " in " << filename << "\n";
- return;
- }
- else
- oSingleTest[pos->first] = pos->second;
+ cnote << "Missing user test specification\nUsage: testeth --singletest <filename> <testname>\n";
+ return;
+ }
- json_spirit::mValue v_singleTest(oSingleTest);
- doTests(v_singleTest, false);
- }
- catch (Exception const& _e)
- {
- BOOST_ERROR("Failed Test with Exception: " << diagnostic_information(_e));
- g_logVerbosity = currentVerbosity;
- }
- catch (std::exception const& _e)
- {
- BOOST_ERROR("Failed Test with Exception: " << _e.what());
- g_logVerbosity = currentVerbosity;
- }
- g_logVerbosity = currentVerbosity;
+ auto& filename = Options::get().singleTestFile;
+ auto& testname = Options::get().singleTestName;
+ int currentVerbosity = g_logVerbosity;
+ g_logVerbosity = 12;
+ try
+ {
+ cnote << "Testing user defined test: " << filename;
+ json_spirit::mValue v;
+ string s = asString(contents(filename));
+ BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of " + filename + " is empty. ");
+ json_spirit::read_string(s, v);
+ json_spirit::mObject oSingleTest;
+
+ json_spirit::mObject::const_iterator pos = v.get_obj().find(testname);
+ if (pos == v.get_obj().end())
+ {
+ cnote << "Could not find test: " << testname << " in " << filename << "\n";
+ return;
}
+ else
+ oSingleTest[pos->first] = pos->second;
+
+ json_spirit::mValue v_singleTest(oSingleTest);
+ doTests(v_singleTest, false);
+ }
+ catch (Exception const& _e)
+ {
+ BOOST_ERROR("Failed Test with Exception: " << diagnostic_information(_e));
+ g_logVerbosity = currentVerbosity;
}
+ catch (std::exception const& _e)
+ {
+ BOOST_ERROR("Failed Test with Exception: " << _e.what());
+ g_logVerbosity = currentVerbosity;
+ }
+ g_logVerbosity = currentVerbosity;
}
void executeTests(const string& _name, const string& _testPathAppendix, const boost::filesystem::path _pathToFiller, std::function<void(json_spirit::mValue&, bool)> doTests)
@@ -731,6 +726,8 @@ Options::Options()
bigData = true;
else if (arg == "--checkstate")
checkState = true;
+ else if (arg == "--wallet")
+ wallet = true;
else if (arg == "--all")
{
performance = true;
@@ -738,11 +735,25 @@ Options::Options()
memory = true;
inputLimits = true;
bigData = true;
+ wallet= true;
}
else if (arg == "--singletest" && i + 1 < argc)
{
singleTest = true;
- singleTestName = argv[i + 1];
+ auto name1 = std::string{argv[i + 1]};
+ if (i + 1 < argc) // two params
+ {
+ auto name2 = std::string{argv[i + 2]};
+ if (name2[0] == '-') // not param, another option
+ singleTestName = std::move(name1);
+ else
+ {
+ singleTestFile = std::move(name1);
+ singleTestName = std::move(name2);
+ }
+ }
+ else
+ singleTestName = std::move(name1);
}
}
}