Works, but does not yet wait for completion of Python process.

This commit is contained in:
NissimHadar 2018-07-29 00:27:15 -07:00
parent e0d14dd702
commit e191c65290

View file

@ -247,14 +247,14 @@ void TestRailInterface::processDirectoryPython(const QString& directory,
// Each node and leaf have an ID and a parent ID. // Each node and leaf have an ID and a parent ID.
// Therefore, the tree is built top-down, using a stack to store the IDs of each node // Therefore, the tree is built top-down, using a stack to store the IDs of each node
// //
void TestRailInterface::createAddSectionsPythonScript(const QString& testDirectory, void TestRailInterface::createAddTestCasesPythonScript(const QString& testDirectory,
const QString& outputDirectory, const QString& outputDirectory,
const QString& userGitHub, const QString& userGitHub,
const QString& branchGitHub) { const QString& branchGitHub) {
QFile file(outputDirectory + "/addTestCases.py"); QFile file(outputDirectory + "/addTestCases.py");
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__), QMessageBox::critical(0, "Internal error: " + QString(__FILE__) + ":" + QString::number(__LINE__),
"Could not create 'addSections.py'"); "Could not create 'addTestCases.py'");
exit(-1); exit(-1);
} }
@ -282,15 +282,11 @@ void TestRailInterface::createAddSectionsPythonScript(const QString& testDirecto
file.close(); file.close();
if (QMessageBox::Yes == QMessageBox(QMessageBox::Information, "Python script has been created", "Do you want to run the script and update TestRail?", QMessageBox::Yes | QMessageBox::No).exec()) { if (QMessageBox::Yes == QMessageBox(QMessageBox::Information, "Python script has been created", "Do you want to run the script and update TestRail?", QMessageBox::Yes | QMessageBox::No).exec()) {
QString command("python"); QString command("C:\\Python37\\python");
QStringList parameters = QStringList() << outputDirectory + "/addTestCases.py"; QStringList parameters = QStringList() << outputDirectory + "/addTestCases.py";
QProcess* process = new QProcess(); QProcess* process = new QProcess();
process->startDetached(command, parameters); if (process->startDetached(command, parameters)) {
if (process->waitForStarted(3000)) {
QMessageBox::information(0, "Python process started", "TestRail is being updated"); QMessageBox::information(0, "Python process started", "TestRail is being updated");
process->waitForFinished();
process->close();
} else { } else {
QMessageBox::critical(0, "Failure", "Could not start process to update TestRail"); QMessageBox::critical(0, "Failure", "Could not start process to update TestRail");
return; return;
@ -306,7 +302,7 @@ void TestRailInterface::createTestSuitePython(const QString& testDirectory,
createTestRailDotPyScript(outputDirectory); createTestRailDotPyScript(outputDirectory);
createStackDotPyScript(outputDirectory); createStackDotPyScript(outputDirectory);
requestDataFromUser(); requestDataFromUser();
createAddSectionsPythonScript(testDirectory, outputDirectory, userGitHub, branchGitHub); createAddTestCasesPythonScript(testDirectory, outputDirectory, userGitHub, branchGitHub);
} }
void TestRailInterface::createTestSuiteXML(const QString& testDirectory, void TestRailInterface::createTestSuiteXML(const QString& testDirectory,