summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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()