From 00ca77a560021c332b3d6f76efb79d082e930da0 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Wed, 15 Apr 2015 09:30:28 +0200 Subject: [PATCH] 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 --- plugins/autotest/testrunner.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/plugins/autotest/testrunner.cpp b/plugins/autotest/testrunner.cpp index 29e5476ce35..07f90a56ad1 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 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::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::instance()); + ProjectExplorer::BuildManager *buildManager = ProjectExplorer::BuildManager::instance(); disconnect(buildManager, &ProjectExplorer::BuildManager::buildQueueFinished, this, &TestRunner::buildFinished); m_building = false;