Add a command line option to keep application open after running tests
This commit is contained in:
@@ -2217,6 +2217,7 @@ void parseProgramOptions(int ac, char ** av, const string& exe, variables_map& v
|
||||
("user-cfg,u", value<string>(),"User config file to load/save user settings")
|
||||
("system-cfg,s", value<string>(),"System config file to load/save system settings")
|
||||
("run-test,t", value<string>()->implicit_value(""),"Run a given test case (use 0 (zero) to run all tests). If no argument is provided then return list of all available tests.")
|
||||
("run-open,r", value<string>()->implicit_value(""),"Run a given test case (use 0 (zero) to run all tests). If no argument is provided then return list of all available tests. Keeps UI open after test(s) complete.")
|
||||
("module-path,M", value< vector<string> >()->composing(),"Additional module paths")
|
||||
("python-path,P", value< vector<string> >()->composing(),"Additional python paths")
|
||||
("single-instance", "Allow to run a single instance of the application")
|
||||
@@ -2441,8 +2442,9 @@ void processProgramOptions(const variables_map& vm, std::map<std::string,std::st
|
||||
mConfig["SystemParameter"] = vm["system-cfg"].as<string>();
|
||||
}
|
||||
|
||||
if (vm.count("run-test")) {
|
||||
string testCase = vm["run-test"].as<string>();
|
||||
if (vm.count("run-test") || vm.count("run-open")) {
|
||||
string testCase = vm.count("run-open") ? vm["run-open"].as<string>() : vm["run-test"].as<string>();
|
||||
|
||||
if ( "0" == testCase) {
|
||||
testCase = "TestApp.All";
|
||||
}
|
||||
@@ -2452,6 +2454,7 @@ void processProgramOptions(const variables_map& vm, std::map<std::string,std::st
|
||||
mConfig["TestCase"] = testCase;
|
||||
mConfig["RunMode"] = "Internal";
|
||||
mConfig["ScriptFileName"] = "FreeCADTest";
|
||||
mConfig["ExitTests"] = vm.count("run-open") == 0 ? "yes" : "no";
|
||||
}
|
||||
|
||||
if (vm.count("single-instance")) {
|
||||
|
||||
@@ -1584,7 +1584,7 @@ void MainWindow::delayedStartup()
|
||||
if (App::Application::Config()["RunMode"] == "Internal") {
|
||||
QTimer::singleShot(1000, this, []{
|
||||
try {
|
||||
Base::Interpreter().runString(
|
||||
string command =
|
||||
"import sys\n"
|
||||
"import FreeCAD\n"
|
||||
"import QtUnitGui\n\n"
|
||||
@@ -1592,8 +1592,11 @@ void MainWindow::delayedStartup()
|
||||
"QtUnitGui.addTest(testCase)\n"
|
||||
"QtUnitGui.setTest(testCase)\n"
|
||||
"result = QtUnitGui.runTest()\n"
|
||||
"sys.stdout.flush()\n"
|
||||
"sys.exit(0 if result else 1)");
|
||||
"sys.stdout.flush()\n";
|
||||
if (App::Application::Config()["ExitTests"] == "yes") {
|
||||
command += "sys.exit(0 if result else 1)";
|
||||
}
|
||||
Base::Interpreter().runString(command.c_str());
|
||||
}
|
||||
catch (const Base::SystemExitException&) {
|
||||
throw;
|
||||
|
||||
Reference in New Issue
Block a user