Commit 89be3424 authored by Don Gagne's avatar Don Gagne

Support --unittest::testname

Allows you to run a single unit test from the command line
parent 34414960
...@@ -112,8 +112,8 @@ int main(int argc, char *argv[]) ...@@ -112,8 +112,8 @@ int main(int argc, char *argv[])
bool quietWindowsAsserts = false; // Don't let asserts pop dialog boxes bool quietWindowsAsserts = false; // Don't let asserts pop dialog boxes
CmdLineOpt_t rgCmdLineOptions[] = { CmdLineOpt_t rgCmdLineOptions[] = {
{ "--unittest", &runUnitTests }, { "--unittest", &runUnitTests, QString() },
{ "--no-windows-assert-ui", &quietWindowsAsserts }, { "--no-windows-assert-ui", &quietWindowsAsserts, QString() },
// Add additional command line option flags here // Add additional command line option flags here
}; };
...@@ -140,7 +140,7 @@ int main(int argc, char *argv[]) ...@@ -140,7 +140,7 @@ int main(int argc, char *argv[])
} }
// Run the test // Run the test
int failures = AutoTest::run(argc-1, argv); int failures = AutoTest::run(argc-1, argv, rgCmdLineOptions[0].optionArg);
if (failures == 0) if (failures == 0)
{ {
qDebug() << "ALL TESTS PASSED"; qDebug() << "ALL TESTS PASSED";
......
...@@ -49,15 +49,17 @@ namespace AutoTest ...@@ -49,15 +49,17 @@ namespace AutoTest
} }
} }
inline int run(int argc, char *argv[]) inline int run(int argc, char *argv[], QString& singleTest)
{ {
int ret = 0; int ret = 0;
foreach (QObject* test, testList()) foreach (QObject* test, testList())
{ {
if (singleTest.isEmpty() || singleTest == test->objectName()) {
qgcApp()->destroySingletonsForUnitTest(); qgcApp()->destroySingletonsForUnitTest();
qgcApp()->createSingletonsForUnitTest(); qgcApp()->createSingletonsForUnitTest();
ret += QTest::qExec(test, argc, argv); ret += QTest::qExec(test, argc, argv);
} }
}
return ret; return ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment