Add -setup, a command line argument.

This commit is contained in:
Francis ANDRE
2018-05-19 15:04:59 +02:00
parent 8951b90bbe
commit 904b0061eb
4 changed files with 32 additions and 1 deletions

View File

@@ -110,7 +110,10 @@ void TestCase::run(TestResult *result)
{
result->startTest(this);
setUp();
if (_setup.size() > 0)
setUp(_setup);
else
setUp();
try
{
runTest();

View File

@@ -48,6 +48,7 @@ bool TestRunner::run(const std::vector<std::string>& args)
bool all = false;
bool wait = false;
bool printed = false;
std::vector<std::string> setup;
for (int i = 1; i < args.size(); i++)
{
@@ -71,6 +72,13 @@ bool TestRunner::run(const std::vector<std::string>& args)
printed = true;
continue;
}
else if (arg == "-setup")
{
if (i + 1 < args.size())
setup.push_back(args[++i]);
continue;
}
if (!all)
{
@@ -89,6 +97,8 @@ bool TestRunner::run(const std::vector<std::string>& args)
}
if (testToRun)
{
if (setup.size() > 0)
testToRun->addSetup(setup);
if (!run(testToRun)) success = false;
}
numberOfTests++;