summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@theqtcompany.com>2015-04-15 09:30:28 +0200
committerChristian Stenger <christian.stenger@theqtcompany.com>2015-04-16 16:22:31 +0300
commit00ca77a560021c332b3d6f76efb79d082e930da0 (patch)
treea63fabc57ff7e2c02d717f6eac8e3ca1c68b406d
parentb88bfbb55a8e50c9ddaef9f7e803658009c0df6f (diff)
downloadqt-creator-00ca77a560021c332b3d6f76efb79d082e930da0.tar.gz
Do not allow triggering multiple test runs at once
This was possible as triggering further test runs could happen while the current test run was still building the project. Additionally it's now possible to stop the build process (if any) by hitting the Stop button of the test results pane as this is part of the test run. Change-Id: I38940b5b8f4ba9e373785921c04cbceaeb2e5acf Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
-rw-r--r--plugins/autotest/testrunner.cpp23
1 files changed, 16 insertions, 7 deletions
diff --git a/plugins/autotest/testrunner.cpp b/plugins/autotest/testrunner.cpp
index 29e5476ce3..07f90a56ad 100644
--- a/plugins/autotest/testrunner.cpp
+++ b/plugins/autotest/testrunner.cpp
@@ -191,6 +191,9 @@ void TestRunner::runTests()
const QString metricsOption = TestSettings::metricsTypeToOption(settings->metrics);
const bool displayRunConfigWarnings = !settings->omitRunConfigWarn;
+ m_executingTests = true;
+ emit testRunStarted();
+
// clear old log and output pane
TestResultsPane::instance()->clearContents();
@@ -218,6 +221,7 @@ void TestRunner::runTests()
if (m_selectedTests.empty()) {
TestResultsPane::instance()->addTestResult(FaultyTestResult(Result::MESSAGE_WARN,
tr("No tests selected. Canceling test run.")));
+ onFinished();
return;
}
@@ -227,6 +231,7 @@ void TestRunner::runTests()
tr("Project is null. Canceling test run.\n"
"Only desktop kits are supported. Make sure the "
"currently active kit is a desktop kit.")));
+ onFinished();
return;
}
@@ -236,27 +241,33 @@ void TestRunner::runTests()
if (!project->hasActiveBuildSettings()) {
TestResultsPane::instance()->addTestResult(FaultyTestResult(Result::MESSAGE_FATAL,
tr("Project is not configured. Canceling test run.")));
+ onFinished();
return;
}
+
+ auto connection = connect(this, &TestRunner::requestStopTestRun, [&] () {
+ ProjectExplorer::BuildManager::instance()->cancel();
+ m_building = false;
+ m_buildSucceeded = false;
+ });
buildProject(project);
while (m_building) {
qApp->processEvents();
}
+ disconnect(connection);
if (!m_buildSucceeded) {
TestResultsPane::instance()->addTestResult(FaultyTestResult(Result::MESSAGE_FATAL,
tr("Build failed. Canceling test run.")));
+ onFinished();
return;
}
}
- m_executingTests = true;
connect(this, &TestRunner::testResultCreated,
TestResultsPane::instance(), &TestResultsPane::addTestResult,
Qt::QueuedConnection);
- emit testRunStarted();
-
QFuture<void> future = QtConcurrent::run(&performTestRun, m_selectedTests, timeout, metricsOption, this);
Core::FutureProgress *progress = Core::ProgressManager::addTask(future, tr("Running Tests"),
Autotest::Constants::TASK_INDEX);
@@ -268,8 +279,7 @@ void TestRunner::buildProject(ProjectExplorer::Project *project)
{
m_building = true;
m_buildSucceeded = false;
- ProjectExplorer::BuildManager *buildManager = static_cast<ProjectExplorer::BuildManager *>(
- ProjectExplorer::BuildManager::instance());
+ ProjectExplorer::BuildManager *buildManager = ProjectExplorer::BuildManager::instance();
connect(buildManager, &ProjectExplorer::BuildManager::buildQueueFinished,
this, &TestRunner::buildFinished);
ProjectExplorer::ProjectExplorerPlugin::buildProject(project);
@@ -277,8 +287,7 @@ void TestRunner::buildProject(ProjectExplorer::Project *project)
void TestRunner::buildFinished(bool success)
{
- ProjectExplorer::BuildManager *buildManager = static_cast<ProjectExplorer::BuildManager *>(
- ProjectExplorer::BuildManager::instance());
+ ProjectExplorer::BuildManager *buildManager = ProjectExplorer::BuildManager::instance();
disconnect(buildManager, &ProjectExplorer::BuildManager::buildQueueFinished,
this, &TestRunner::buildFinished);
m_building = false;