testeth: fix --singletest option

This commit is contained in:
Paweł Bylica 2015-05-08 11:00:17 +02:00
parent 2fdea4d563
commit e608be8299
2 changed files with 46 additions and 52 deletions

View File

@ -549,22 +549,16 @@ 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)
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]; cnote << "Missing user test specification\nUsage: testeth --singletest <filename> <testname>\n";
if (arg == testTypeFlag)
{
if (boost::unit_test::framework::master_test_suite().argc <= i + 2)
{
cnote << "Missing filename\nUsage: testeth " << testTypeFlag << " <filename> <testname>\n";
return; 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]; auto& filename = Options::get().singleTestFile;
auto& testname = Options::get().singleTestName;
int currentVerbosity = g_logVerbosity; int currentVerbosity = g_logVerbosity;
g_logVerbosity = 12; g_logVerbosity = 12;
try try
@ -599,8 +593,6 @@ void userDefinedTest(string testTypeFlag, std::function<void(json_spirit::mValue
g_logVerbosity = currentVerbosity; g_logVerbosity = currentVerbosity;
} }
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) void executeTests(const string& _name, const string& _testPathAppendix, const boost::filesystem::path _pathToFiller, std::function<void(json_spirit::mValue&, bool)> doTests)
@ -739,10 +731,11 @@ Options::Options()
inputLimits = true; inputLimits = true;
bigData = true; bigData = true;
} }
else if (arg == "--singletest" && i + 1 < argc) else if (arg == "--singletest" && i + 2 < argc)
{ {
singleTest = true; singleTest = true;
singleTestName = argv[i + 1]; singleTestFile = argv[i + 1];
singleTestName = argv[i + 2];
} }
} }
} }

View File

@ -157,7 +157,7 @@ void checkLog(eth::LogEntries _resultLogs, eth::LogEntries _expectedLogs);
void checkCallCreates(eth::Transactions _resultCallCreates, eth::Transactions _expectedCallCreates); void checkCallCreates(eth::Transactions _resultCallCreates, eth::Transactions _expectedCallCreates);
void executeTests(const std::string& _name, const std::string& _testPathAppendix, const boost::filesystem::path _pathToFiller, std::function<void(json_spirit::mValue&, bool)> doTests); void executeTests(const std::string& _name, const std::string& _testPathAppendix, const boost::filesystem::path _pathToFiller, std::function<void(json_spirit::mValue&, bool)> doTests);
void userDefinedTest(std::string testTypeFlag, std::function<void(json_spirit::mValue&, bool)> doTests); void userDefinedTest(std::function<void(json_spirit::mValue&, bool)> doTests);
RLPStream createRLPStreamFromTransactionFields(json_spirit::mObject& _tObj); RLPStream createRLPStreamFromTransactionFields(json_spirit::mObject& _tObj);
eth::LastHashes lastHashes(u256 _currentBlockNumber); eth::LastHashes lastHashes(u256 _currentBlockNumber);
json_spirit::mObject fillJsonWithState(eth::State _state); json_spirit::mObject fillJsonWithState(eth::State _state);
@ -188,6 +188,7 @@ public:
/// Test selection /// Test selection
/// @{ /// @{
bool singleTest = false; bool singleTest = false;
std::string singleTestFile;
std::string singleTestName; std::string singleTestName;
bool performance = false; bool performance = false;
bool quadratic = false; bool quadratic = false;