forked from qt-creator/qt-creator
Avoid possible race condition
Change-Id: I12988ad9583740b2c72d8e40e68414a7cba08364 Reviewed-by: Niels Weber <niels.weber@theqtcompany.com> Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
@@ -180,8 +180,13 @@ static void performTestRun(QFutureInterface<TestResult *> &futureInterface,
|
|||||||
bool ok = testProcess.waitForStarted();
|
bool ok = testProcess.waitForStarted();
|
||||||
QTime executionTimer;
|
QTime executionTimer;
|
||||||
executionTimer.start();
|
executionTimer.start();
|
||||||
|
bool canceledByTimeout = false;
|
||||||
if (ok) {
|
if (ok) {
|
||||||
while (testProcess.state() == QProcess::Running && executionTimer.elapsed() < timeout) {
|
while (testProcess.state() == QProcess::Running) {
|
||||||
|
if (executionTimer.elapsed() >= timeout) {
|
||||||
|
canceledByTimeout = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (futureInterface.isCanceled()) {
|
if (futureInterface.isCanceled()) {
|
||||||
testProcess.kill();
|
testProcess.kill();
|
||||||
testProcess.waitForFinished();
|
testProcess.waitForFinished();
|
||||||
@@ -191,13 +196,13 @@ static void performTestRun(QFutureInterface<TestResult *> &futureInterface,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (executionTimer.elapsed() >= timeout) {
|
if (canceledByTimeout) {
|
||||||
if (testProcess.state() != QProcess::NotRunning) {
|
if (testProcess.state() != QProcess::NotRunning) {
|
||||||
testProcess.kill();
|
testProcess.kill();
|
||||||
testProcess.waitForFinished();
|
testProcess.waitForFinished();
|
||||||
futureInterface.reportResult(new FaultyTestResult(Result::MessageFatal, QObject::tr(
|
|
||||||
"Test case canceled due to timeout. \nMaybe raise the timeout?")));
|
|
||||||
}
|
}
|
||||||
|
futureInterface.reportResult(new FaultyTestResult(Result::MessageFatal, QObject::tr(
|
||||||
|
"Test case canceled due to timeout. \nMaybe raise the timeout?")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
futureInterface.setProgressValue(testCaseCount);
|
futureInterface.setProgressValue(testCaseCount);
|
||||||
|
Reference in New Issue
Block a user