From f44112ed22d6c0d7a096ce968f3081c230c8e51d Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Fri, 12 Jan 2024 21:01:08 +0100 Subject: [PATCH] AutoTest: Use LoopRepeat for test runner Change-Id: I2b7eb32732aa1f12b23a719d0c4cce14dd0d7114 Reviewed-by: Reviewed-by: Christian Stenger --- src/plugins/autotest/testrunner.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/plugins/autotest/testrunner.cpp b/src/plugins/autotest/testrunner.cpp index c437510bec7..94618ef8c12 100644 --- a/src/plugins/autotest/testrunner.cpp +++ b/src/plugins/autotest/testrunner.cpp @@ -347,13 +347,13 @@ void TestRunner::runTestsHelper() std::unique_ptr m_outputReader; }; - QList tasks{finishAllAndSuccess}; - - for (ITestConfiguration *config : m_selectedTests) { - QTC_ASSERT(config, continue); + const QList selectedTests = m_selectedTests; + const LoopRepeat repeater(selectedTests.size()); const Storage storage; - const auto onSetup = [this, config] { + const auto onSetup = [this, selectedTests, repeater] { + ITestConfiguration *config = selectedTests.at(repeater.iteration()); + QTC_ASSERT(config, return SetupResult::StopWithError); if (!config->project()) return SetupResult::StopWithSuccess; if (config->testExecutable().isEmpty()) { @@ -363,7 +363,8 @@ void TestRunner::runTestsHelper() } return SetupResult::Continue; }; - const auto onProcessSetup = [this, config, storage](Process &process) { + const auto onProcessSetup = [this, selectedTests, repeater, storage](Process &process) { + ITestConfiguration *config = selectedTests.at(repeater.iteration()); TestStorage *testStorage = storage.activeStorage(); QTC_ASSERT(testStorage, return); testStorage->m_outputReader.reset(config->createOutputReader(&process)); @@ -410,7 +411,8 @@ void TestRunner::runTestsHelper() qCInfo(runnerLog) << "Working directory:" << process.workingDirectory(); qCDebug(runnerLog) << "Environment:" << process.environment().toStringList(); }; - const auto onProcessDone = [this, config, storage](const Process &process) { + const auto onProcessDone = [this, selectedTests, repeater, storage](const Process &process) { + ITestConfiguration *config = selectedTests.at(repeater.iteration()); TestStorage *testStorage = storage.activeStorage(); QTC_ASSERT(testStorage, return); if (process.result() == ProcessResult::StartFailed) { @@ -444,16 +446,19 @@ void TestRunner::runTestsHelper() testStorage->m_outputReader->resetCommandlineColor(); } }; - const Group group { + + const Group root { + finishAllAndSuccess, + repeater, + Group { finishAllAndSuccess, storage, onGroupSetup(onSetup), ProcessTask(onProcessSetup, onProcessDone) - }; - tasks.append(group); - } + } + }; - m_taskTree.reset(new TaskTree(tasks)); + m_taskTree.reset(new TaskTree(root)); connect(m_taskTree.get(), &TaskTree::done, this, &TestRunner::onFinished); auto progress = new TaskProgress(m_taskTree.get());