aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@qt.io>2018-09-04 11:30:13 +0200
committerChristian Stenger <christian.stenger@qt.io>2018-09-04 11:43:33 +0000
commit58c0325b9dc10760aa73f62dd3d1819a8adbc585 (patch)
tree0024fa21625ad0a2700e6a0202174f5065522a19
parentc39fd1c36a1a28a8a3c2de4ad4bb33f3d8517344 (diff)
AutoTest: Fix handling cancellation for timeout
If the timeout triggered a cancellation of a test run the testrunner missed to inform the progress manager about this. This in turn resulted in a sticky progress widget which even could pile up with further progress widgets. Fix this by explicitly informing the progress manager of the cancellation. Change-Id: Ie19a1aa998e19f911cd0dd856008552baaffeb9b Reviewed-by: David Schulz <david.schulz@qt.io>
-rw-r--r--src/plugins/autotest/testrunner.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/plugins/autotest/testrunner.cpp b/src/plugins/autotest/testrunner.cpp
index 0b774c6c7a..bde77b0bca 100644
--- a/src/plugins/autotest/testrunner.cpp
+++ b/src/plugins/autotest/testrunner.cpp
@@ -217,24 +217,24 @@ void TestRunner::scheduleNext()
void TestRunner::cancelCurrent(TestRunner::CancelReason reason)
{
m_canceled = true;
- if (reason == UserCanceled) {
- // when using the stop button we need to report, for progress bar this happens automatically
- if (m_fakeFutureInterface && !m_fakeFutureInterface->isCanceled())
- m_fakeFutureInterface->reportCanceled();
- } else if (reason == KitChanged) {
- if (m_fakeFutureInterface)
- m_fakeFutureInterface->reportCanceled();
- emit testResultReady(TestResultPtr(new FaultyTestResult(Result::MessageWarn,
- tr("Current kit has changed. Canceling test run."))));
- }
+
+ if (m_fakeFutureInterface)
+ m_fakeFutureInterface->reportCanceled();
+
+ auto reportResult = [this](Result::Type type, const QString &detail){
+ emit testResultReady(TestResultPtr(new FaultyTestResult(type, detail)));
+ };
+
+ if (reason == KitChanged)
+ reportResult(Result::MessageWarn, tr("Current kit has changed. Canceling test run."));
+ else if (reason == Timeout)
+ reportResult(Result::MessageFatal, tr("Test case canceled due to timeout.\nMaybe raise the timeout?"));
+
+ // if user or timeout cancels the current run ensure to kill the running process
if (m_currentProcess && m_currentProcess->state() != QProcess::NotRunning) {
m_currentProcess->kill();
m_currentProcess->waitForFinished();
}
- if (reason == Timeout) {
- emit testResultReady(TestResultPtr(new FaultyTestResult(Result::MessageFatal,
- tr("Test case canceled due to timeout.\nMaybe raise the timeout?"))));
- }
}
void TestRunner::onProcessFinished()