2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2016-01-22 10:37:55 +01:00
|
|
|
|
2015-01-16 13:44:24 +01:00
|
|
|
#include "testrunner.h"
|
2014-10-07 15:51:02 +02:00
|
|
|
|
2014-11-04 12:35:00 +01:00
|
|
|
#include "autotestconstants.h"
|
2014-12-04 14:05:19 +01:00
|
|
|
#include "autotestplugin.h"
|
2022-07-13 18:31:56 +02:00
|
|
|
#include "autotesttr.h"
|
2020-10-09 13:07:55 +02:00
|
|
|
#include "testoutputreader.h"
|
2019-08-08 10:58:15 +02:00
|
|
|
#include "testprojectsettings.h"
|
2014-10-07 15:51:02 +02:00
|
|
|
#include "testresultspane.h"
|
2016-06-15 12:29:24 +02:00
|
|
|
#include "testrunconfiguration.h"
|
2017-09-09 16:46:43 +02:00
|
|
|
#include "testtreeitem.h"
|
2019-08-08 09:57:42 +02:00
|
|
|
#include "testtreemodel.h"
|
2014-10-07 15:51:02 +02:00
|
|
|
|
2017-09-13 14:27:20 +02:00
|
|
|
#include <coreplugin/icore.h>
|
TestRunner: Reuse TaskTree
Get rid of QFutureInterface argument from
ITestConfiguration::createOutputReader() and from
TestOutputReader c'tor.
The fine-grained progress reporting was broken anyway:
1. The assumption was that testCaseCount was meant to be
the total number of test functions executed. It didn't
include the initTestCase() and cleanupTestCase(),
while those were reported on runtime apparently
(and exceeding the max progress by 2).
2. In case of tst_qtcprocess, when the whole test was run,
the testCaseCount reported 41, while the real
number of functions was 26 (+2 = 28 for init/cleanup).
3. While the max progress was set to testCaseCount initially,
the corresponding FutureProgress rendered the progress
always in 0-100 range, what didn't match the reality.
Instead, rely on TaskTree progress, which resolution
is per test as a whole. So, when executing a series
of tests this should scale fine. In addition, the
progress advances fluently according to the expected
run time - with 10 seconds hardcoded.
The original code locations, where progress was bumped,
are left with a TODO comment for any possible future tweaks.
Like in case of result reporting, fine-grained progress
reporting may be implemented by providing additional signal,
so there is no need for QFutureInterface inside
TestOutputReader.
Change-Id: Idc11d55e3a49dac8d1788948b9a82f68199203c6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-17 00:45:50 +01:00
|
|
|
#include <coreplugin/progressmanager/taskprogress.h>
|
2014-11-04 12:35:00 +01:00
|
|
|
|
2019-10-16 10:28:21 +02:00
|
|
|
#include <debugger/debuggerkitinformation.h>
|
|
|
|
|
#include <debugger/debuggerruncontrol.h>
|
|
|
|
|
|
2019-08-13 15:25:45 +02:00
|
|
|
#include <projectexplorer/buildconfiguration.h>
|
2014-10-07 15:51:02 +02:00
|
|
|
#include <projectexplorer/buildmanager.h>
|
2020-03-17 09:23:55 +01:00
|
|
|
#include <projectexplorer/buildsystem.h>
|
2014-10-07 15:51:02 +02:00
|
|
|
#include <projectexplorer/project.h>
|
|
|
|
|
#include <projectexplorer/projectexplorer.h>
|
|
|
|
|
#include <projectexplorer/projectexplorersettings.h>
|
2023-02-14 15:47:22 +01:00
|
|
|
#include <projectexplorer/projectmanager.h>
|
2017-09-13 14:27:20 +02:00
|
|
|
#include <projectexplorer/runconfiguration.h>
|
2016-06-15 12:29:24 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2014-10-07 15:51:02 +02:00
|
|
|
|
2019-10-16 10:28:21 +02:00
|
|
|
#include <utils/algorithm.h>
|
2018-02-28 10:50:38 +01:00
|
|
|
#include <utils/hostosinfo.h>
|
2022-08-26 23:18:00 +02:00
|
|
|
#include <utils/layoutbuilder.h>
|
2017-04-06 15:42:09 +02:00
|
|
|
#include <utils/outputformat.h>
|
2023-05-03 17:05:35 +02:00
|
|
|
#include <utils/process.h>
|
2014-11-04 12:35:00 +01:00
|
|
|
|
2018-08-08 12:40:03 +02:00
|
|
|
#include <QCheckBox>
|
2017-09-13 14:27:20 +02:00
|
|
|
#include <QComboBox>
|
|
|
|
|
#include <QDialogButtonBox>
|
|
|
|
|
#include <QFormLayout>
|
|
|
|
|
#include <QLabel>
|
2019-10-16 10:28:21 +02:00
|
|
|
#include <QLoggingCategory>
|
2020-03-17 09:23:55 +01:00
|
|
|
#include <QPointer>
|
2017-09-13 14:27:20 +02:00
|
|
|
#include <QPushButton>
|
2014-10-07 15:51:02 +02:00
|
|
|
|
TestRunner: Reuse TaskTree
Get rid of QFutureInterface argument from
ITestConfiguration::createOutputReader() and from
TestOutputReader c'tor.
The fine-grained progress reporting was broken anyway:
1. The assumption was that testCaseCount was meant to be
the total number of test functions executed. It didn't
include the initTestCase() and cleanupTestCase(),
while those were reported on runtime apparently
(and exceeding the max progress by 2).
2. In case of tst_qtcprocess, when the whole test was run,
the testCaseCount reported 41, while the real
number of functions was 26 (+2 = 28 for init/cleanup).
3. While the max progress was set to testCaseCount initially,
the corresponding FutureProgress rendered the progress
always in 0-100 range, what didn't match the reality.
Instead, rely on TaskTree progress, which resolution
is per test as a whole. So, when executing a series
of tests this should scale fine. In addition, the
progress advances fluently according to the expected
run time - with 10 seconds hardcoded.
The original code locations, where progress was bumped,
are left with a TODO comment for any possible future tweaks.
Like in case of result reporting, fine-grained progress
reporting may be implemented by providing additional signal,
so there is no need for QFutureInterface inside
TestOutputReader.
Change-Id: Idc11d55e3a49dac8d1788948b9a82f68199203c6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-17 00:45:50 +01:00
|
|
|
using namespace Core;
|
2019-08-13 15:25:45 +02:00
|
|
|
using namespace ProjectExplorer;
|
2023-05-10 19:54:52 +02:00
|
|
|
using namespace Tasking;
|
2019-06-20 17:19:12 +02:00
|
|
|
using namespace Utils;
|
|
|
|
|
|
2014-10-07 15:51:02 +02:00
|
|
|
namespace Autotest {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2019-10-16 10:28:21 +02:00
|
|
|
static Q_LOGGING_CATEGORY(runnerLog, "qtc.autotest.testrunner", QtWarningMsg)
|
|
|
|
|
|
2017-02-13 10:05:06 +01:00
|
|
|
static TestRunner *s_instance = nullptr;
|
2014-12-01 16:12:05 +01:00
|
|
|
|
2015-01-16 13:44:24 +01:00
|
|
|
TestRunner *TestRunner::instance()
|
|
|
|
|
{
|
2017-02-13 10:05:06 +01:00
|
|
|
return s_instance;
|
2015-01-16 13:44:24 +01:00
|
|
|
}
|
|
|
|
|
|
2020-03-26 09:21:25 +01:00
|
|
|
TestRunner::TestRunner()
|
2015-01-16 13:44:24 +01:00
|
|
|
{
|
2020-03-26 09:21:25 +01:00
|
|
|
s_instance = this;
|
|
|
|
|
|
2022-06-10 10:18:34 +02:00
|
|
|
m_cancelTimer.setSingleShot(true);
|
2022-12-07 14:45:43 +01:00
|
|
|
connect(&m_cancelTimer, &QTimer::timeout, this, [this] { cancelCurrent(Timeout); });
|
TestRunner: Reuse TaskTree
Get rid of QFutureInterface argument from
ITestConfiguration::createOutputReader() and from
TestOutputReader c'tor.
The fine-grained progress reporting was broken anyway:
1. The assumption was that testCaseCount was meant to be
the total number of test functions executed. It didn't
include the initTestCase() and cleanupTestCase(),
while those were reported on runtime apparently
(and exceeding the max progress by 2).
2. In case of tst_qtcprocess, when the whole test was run,
the testCaseCount reported 41, while the real
number of functions was 26 (+2 = 28 for init/cleanup).
3. While the max progress was set to testCaseCount initially,
the corresponding FutureProgress rendered the progress
always in 0-100 range, what didn't match the reality.
Instead, rely on TaskTree progress, which resolution
is per test as a whole. So, when executing a series
of tests this should scale fine. In addition, the
progress advances fluently according to the expected
run time - with 10 seconds hardcoded.
The original code locations, where progress was bumped,
are left with a TODO comment for any possible future tweaks.
Like in case of result reporting, fine-grained progress
reporting may be implemented by providing additional signal,
so there is no need for QFutureInterface inside
TestOutputReader.
Change-Id: Idc11d55e3a49dac8d1788948b9a82f68199203c6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-17 00:45:50 +01:00
|
|
|
connect(this, &TestRunner::requestStopTestRun, this, [this] { cancelCurrent(UserCanceled); });
|
2019-08-19 14:46:20 +02:00
|
|
|
connect(BuildManager::instance(), &BuildManager::buildQueueFinished,
|
2019-08-08 09:57:42 +02:00
|
|
|
this, &TestRunner::onBuildQueueFinished);
|
2015-01-16 13:44:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TestRunner::~TestRunner()
|
|
|
|
|
{
|
|
|
|
|
qDeleteAll(m_selectedTests);
|
|
|
|
|
m_selectedTests.clear();
|
2017-02-13 10:05:06 +01:00
|
|
|
s_instance = nullptr;
|
2015-01-16 13:44:24 +01:00
|
|
|
}
|
|
|
|
|
|
2020-10-13 11:37:37 +02:00
|
|
|
void TestRunner::runTest(TestRunMode mode, const ITestTreeItem *item)
|
2017-09-09 16:46:43 +02:00
|
|
|
{
|
TestRunner: Reuse TaskTree
Get rid of QFutureInterface argument from
ITestConfiguration::createOutputReader() and from
TestOutputReader c'tor.
The fine-grained progress reporting was broken anyway:
1. The assumption was that testCaseCount was meant to be
the total number of test functions executed. It didn't
include the initTestCase() and cleanupTestCase(),
while those were reported on runtime apparently
(and exceeding the max progress by 2).
2. In case of tst_qtcprocess, when the whole test was run,
the testCaseCount reported 41, while the real
number of functions was 26 (+2 = 28 for init/cleanup).
3. While the max progress was set to testCaseCount initially,
the corresponding FutureProgress rendered the progress
always in 0-100 range, what didn't match the reality.
Instead, rely on TaskTree progress, which resolution
is per test as a whole. So, when executing a series
of tests this should scale fine. In addition, the
progress advances fluently according to the expected
run time - with 10 seconds hardcoded.
The original code locations, where progress was bumped,
are left with a TODO comment for any possible future tweaks.
Like in case of result reporting, fine-grained progress
reporting may be implemented by providing additional signal,
so there is no need for QFutureInterface inside
TestOutputReader.
Change-Id: Idc11d55e3a49dac8d1788948b9a82f68199203c6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-17 00:45:50 +01:00
|
|
|
QTC_ASSERT(!isTestRunning(), return);
|
2020-10-13 11:37:37 +02:00
|
|
|
ITestConfiguration *configuration = item->asConfiguration(mode);
|
2017-09-09 16:46:43 +02:00
|
|
|
|
2023-01-13 12:30:42 +01:00
|
|
|
if (configuration)
|
|
|
|
|
runTests(mode, {configuration});
|
2017-09-09 16:46:43 +02:00
|
|
|
}
|
|
|
|
|
|
2023-05-03 16:00:22 +02:00
|
|
|
static QString processInformation(const Process *proc)
|
2017-04-03 09:17:58 +02:00
|
|
|
{
|
2023-01-13 12:58:08 +01:00
|
|
|
QTC_ASSERT(proc, return {});
|
2023-01-13 13:27:25 +01:00
|
|
|
const CommandLine command = proc->commandLine();
|
2022-06-10 10:18:34 +02:00
|
|
|
QString information("\nCommand line: " + command.executable().toUserOutput() + ' ' + command.arguments());
|
2017-04-03 09:17:58 +02:00
|
|
|
QStringList important = { "PATH" };
|
2023-01-13 13:27:25 +01:00
|
|
|
if (HostOsInfo::isLinuxHost())
|
2017-04-03 09:17:58 +02:00
|
|
|
important.append("LD_LIBRARY_PATH");
|
2023-01-13 13:27:25 +01:00
|
|
|
else if (HostOsInfo::isMacHost())
|
2017-04-03 09:17:58 +02:00
|
|
|
important.append({ "DYLD_LIBRARY_PATH", "DYLD_FRAMEWORK_PATH" });
|
2023-01-13 13:27:25 +01:00
|
|
|
const Environment &environment = proc->environment();
|
2017-04-03 09:17:58 +02:00
|
|
|
for (const QString &var : important)
|
|
|
|
|
information.append('\n' + var + ": " + environment.value(var));
|
|
|
|
|
return information;
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-13 11:37:37 +02:00
|
|
|
static QString rcInfo(const ITestConfiguration * const config)
|
2017-04-03 09:17:58 +02:00
|
|
|
{
|
2021-01-25 16:19:38 +01:00
|
|
|
if (config->testBase()->type() == ITestBase::Tool)
|
2020-10-19 14:42:25 +02:00
|
|
|
return {};
|
2020-10-13 11:37:37 +02:00
|
|
|
const TestConfiguration *current = static_cast<const TestConfiguration *>(config);
|
2018-10-22 16:18:02 +02:00
|
|
|
QString info;
|
2020-10-13 11:37:37 +02:00
|
|
|
if (current->isDeduced())
|
2022-07-13 18:31:56 +02:00
|
|
|
info = Tr::tr("\nRun configuration: deduced from \"%1\"");
|
2018-10-22 16:18:02 +02:00
|
|
|
else
|
2022-07-13 18:31:56 +02:00
|
|
|
info = Tr::tr("\nRun configuration: \"%1\"");
|
2020-10-13 11:37:37 +02:00
|
|
|
return info.arg(current->runConfigDisplayName());
|
2017-04-03 09:17:58 +02:00
|
|
|
}
|
|
|
|
|
|
2017-09-01 14:59:39 +02:00
|
|
|
static QString constructOmittedDetailsString(const QStringList &omitted)
|
|
|
|
|
{
|
2022-07-13 18:31:56 +02:00
|
|
|
return Tr::tr("Omitted the following arguments specified on the run "
|
|
|
|
|
"configuration page for \"%1\":") + '\n' + omitted.join('\n');
|
2017-09-01 14:59:39 +02:00
|
|
|
}
|
|
|
|
|
|
2023-01-13 13:27:25 +01:00
|
|
|
static QString constructOmittedVariablesDetailsString(const EnvironmentItems &diff)
|
2018-08-29 12:33:15 +02:00
|
|
|
{
|
2023-01-13 13:27:25 +01:00
|
|
|
auto removedVars = Utils::transform<QStringList>(diff, [](const EnvironmentItem &it) {
|
2018-08-29 12:33:15 +02:00
|
|
|
return it.name;
|
|
|
|
|
});
|
2022-07-13 18:31:56 +02:00
|
|
|
return Tr::tr("Omitted the following environment variables for \"%1\":")
|
2018-08-29 12:33:15 +02:00
|
|
|
+ '\n' + removedVars.join('\n');
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-17 12:16:56 +02:00
|
|
|
void TestRunner::cancelCurrent(TestRunner::CancelReason reason)
|
|
|
|
|
{
|
2018-09-04 11:30:13 +02:00
|
|
|
if (reason == KitChanged)
|
2022-07-13 18:31:56 +02:00
|
|
|
reportResult(ResultType::MessageWarn, Tr::tr("Current kit has changed. Canceling test run."));
|
2018-09-04 11:30:13 +02:00
|
|
|
else if (reason == Timeout)
|
2022-07-13 18:31:56 +02:00
|
|
|
reportResult(ResultType::MessageFatal, Tr::tr("Test case canceled due to timeout.\nMaybe raise the timeout?"));
|
TestRunner: Reuse TaskTree
Get rid of QFutureInterface argument from
ITestConfiguration::createOutputReader() and from
TestOutputReader c'tor.
The fine-grained progress reporting was broken anyway:
1. The assumption was that testCaseCount was meant to be
the total number of test functions executed. It didn't
include the initTestCase() and cleanupTestCase(),
while those were reported on runtime apparently
(and exceeding the max progress by 2).
2. In case of tst_qtcprocess, when the whole test was run,
the testCaseCount reported 41, while the real
number of functions was 26 (+2 = 28 for init/cleanup).
3. While the max progress was set to testCaseCount initially,
the corresponding FutureProgress rendered the progress
always in 0-100 range, what didn't match the reality.
Instead, rely on TaskTree progress, which resolution
is per test as a whole. So, when executing a series
of tests this should scale fine. In addition, the
progress advances fluently according to the expected
run time - with 10 seconds hardcoded.
The original code locations, where progress was bumped,
are left with a TODO comment for any possible future tweaks.
Like in case of result reporting, fine-grained progress
reporting may be implemented by providing additional signal,
so there is no need for QFutureInterface inside
TestOutputReader.
Change-Id: Idc11d55e3a49dac8d1788948b9a82f68199203c6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-17 00:45:50 +01:00
|
|
|
else if (reason == UserCanceled)
|
|
|
|
|
reportResult(ResultType::MessageFatal, Tr::tr("Test run canceled by user."));
|
|
|
|
|
m_taskTree.reset();
|
|
|
|
|
onFinished();
|
2014-11-04 12:35:00 +01:00
|
|
|
}
|
|
|
|
|
|
2023-01-13 12:30:42 +01:00
|
|
|
void TestRunner::runTests(TestRunMode mode, const QList<ITestConfiguration *> &selectedTests)
|
2014-11-04 12:35:00 +01:00
|
|
|
{
|
TestRunner: Reuse TaskTree
Get rid of QFutureInterface argument from
ITestConfiguration::createOutputReader() and from
TestOutputReader c'tor.
The fine-grained progress reporting was broken anyway:
1. The assumption was that testCaseCount was meant to be
the total number of test functions executed. It didn't
include the initTestCase() and cleanupTestCase(),
while those were reported on runtime apparently
(and exceeding the max progress by 2).
2. In case of tst_qtcprocess, when the whole test was run,
the testCaseCount reported 41, while the real
number of functions was 26 (+2 = 28 for init/cleanup).
3. While the max progress was set to testCaseCount initially,
the corresponding FutureProgress rendered the progress
always in 0-100 range, what didn't match the reality.
Instead, rely on TaskTree progress, which resolution
is per test as a whole. So, when executing a series
of tests this should scale fine. In addition, the
progress advances fluently according to the expected
run time - with 10 seconds hardcoded.
The original code locations, where progress was bumped,
are left with a TODO comment for any possible future tweaks.
Like in case of result reporting, fine-grained progress
reporting may be implemented by providing additional signal,
so there is no need for QFutureInterface inside
TestOutputReader.
Change-Id: Idc11d55e3a49dac8d1788948b9a82f68199203c6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-17 00:45:50 +01:00
|
|
|
QTC_ASSERT(!isTestRunning(), return);
|
2023-01-13 12:30:42 +01:00
|
|
|
qDeleteAll(m_selectedTests);
|
2023-01-13 12:58:08 +01:00
|
|
|
m_selectedTests = selectedTests;
|
2023-01-13 12:30:42 +01:00
|
|
|
|
2020-03-17 09:23:55 +01:00
|
|
|
m_skipTargetsCheck = false;
|
2016-06-15 12:29:24 +02:00
|
|
|
m_runMode = mode;
|
2023-01-13 14:02:32 +01:00
|
|
|
const ProjectExplorerSettings projectExplorerSettings
|
|
|
|
|
= ProjectExplorerPlugin::projectExplorerSettings();
|
2019-12-04 17:23:02 +01:00
|
|
|
if (mode != TestRunMode::RunAfterBuild
|
2023-01-13 14:02:32 +01:00
|
|
|
&& projectExplorerSettings.buildBeforeDeploy != BuildBeforeRunMode::Off
|
2019-08-19 10:55:32 +02:00
|
|
|
&& !projectExplorerSettings.saveBeforeBuild) {
|
2019-08-19 14:46:20 +02:00
|
|
|
if (!ProjectExplorerPlugin::saveModifiedFiles())
|
2016-01-20 09:38:26 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-15 09:30:28 +02:00
|
|
|
emit testRunStarted();
|
|
|
|
|
|
2014-11-04 13:42:38 +01:00
|
|
|
// clear old log and output pane
|
|
|
|
|
TestResultsPane::instance()->clearContents();
|
2020-09-11 14:30:15 +02:00
|
|
|
TestTreeModel::instance()->clearFailedMarks();
|
2014-11-04 13:42:38 +01:00
|
|
|
|
2023-01-13 12:58:08 +01:00
|
|
|
if (m_selectedTests.isEmpty()) {
|
2022-07-13 18:31:56 +02:00
|
|
|
reportResult(ResultType::MessageWarn, Tr::tr("No tests selected. Canceling test run."));
|
2015-04-15 09:30:28 +02:00
|
|
|
onFinished();
|
2014-11-04 12:35:00 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-13 12:58:08 +01:00
|
|
|
Project *project = m_selectedTests.first()->project();
|
2014-11-13 12:31:58 +01:00
|
|
|
if (!project) {
|
2019-02-06 14:11:19 +01:00
|
|
|
reportResult(ResultType::MessageWarn,
|
2022-07-13 18:31:56 +02:00
|
|
|
Tr::tr("Project is null. Canceling test run.\n"
|
|
|
|
|
"Only desktop kits are supported. Make sure the "
|
|
|
|
|
"currently active kit is a desktop kit."));
|
2015-04-15 09:30:28 +02:00
|
|
|
onFinished();
|
2014-11-04 12:35:00 +01:00
|
|
|
return;
|
2014-11-13 12:31:58 +01:00
|
|
|
}
|
2014-11-04 12:35:00 +01:00
|
|
|
|
2019-08-19 14:46:20 +02:00
|
|
|
m_targetConnect = connect(project, &Project::activeTargetChanged,
|
2022-12-07 14:45:43 +01:00
|
|
|
this, [this] { cancelCurrent(KitChanged); });
|
2018-06-21 10:36:50 +02:00
|
|
|
|
2023-01-13 14:02:32 +01:00
|
|
|
if (projectExplorerSettings.buildBeforeDeploy == BuildBeforeRunMode::Off
|
2019-12-04 17:23:02 +01:00
|
|
|
|| mode == TestRunMode::DebugWithoutDeploy
|
2019-08-08 09:57:42 +02:00
|
|
|
|| mode == TestRunMode::RunWithoutDeploy || mode == TestRunMode::RunAfterBuild) {
|
2016-06-15 12:29:24 +02:00
|
|
|
runOrDebugTests();
|
2019-08-13 15:25:45 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Target *target = project->activeTarget();
|
|
|
|
|
if (target && BuildConfigurationFactory::find(target)) {
|
2016-11-04 09:47:15 +01:00
|
|
|
buildProject(project);
|
2015-06-29 09:22:58 +02:00
|
|
|
} else {
|
2019-02-06 14:11:19 +01:00
|
|
|
reportResult(ResultType::MessageFatal,
|
2022-07-13 18:31:56 +02:00
|
|
|
Tr::tr("Project is not configured. Canceling test run."));
|
2016-11-04 09:47:15 +01:00
|
|
|
onFinished();
|
2014-11-04 12:35:00 +01:00
|
|
|
}
|
2015-06-29 09:22:58 +02:00
|
|
|
}
|
|
|
|
|
|
2018-08-08 12:34:19 +02:00
|
|
|
static QString firstNonEmptyTestCaseTarget(const TestConfiguration *config)
|
2017-09-13 14:27:20 +02:00
|
|
|
{
|
2018-08-08 12:34:19 +02:00
|
|
|
return Utils::findOrDefault(config->internalTargets(), [](const QString &internalTarget) {
|
|
|
|
|
return !internalTarget.isEmpty();
|
|
|
|
|
});
|
2017-09-13 14:27:20 +02:00
|
|
|
}
|
|
|
|
|
|
2019-08-19 14:46:20 +02:00
|
|
|
static RunConfiguration *getRunConfiguration(const QString &buildTargetKey)
|
2017-09-13 14:27:20 +02:00
|
|
|
{
|
2023-02-14 15:47:22 +01:00
|
|
|
const Project *project = ProjectManager::startupProject();
|
2017-11-09 08:38:07 +01:00
|
|
|
if (!project)
|
|
|
|
|
return nullptr;
|
|
|
|
|
const Target *target = project->activeTarget();
|
|
|
|
|
if (!target)
|
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
|
|
RunConfiguration *runConfig = nullptr;
|
|
|
|
|
const QList<RunConfiguration *> runConfigurations
|
2022-12-07 14:45:43 +01:00
|
|
|
= Utils::filtered(target->runConfigurations(), [](const RunConfiguration *rc) {
|
2021-08-10 09:19:30 +02:00
|
|
|
return !rc->runnable().command.isEmpty();
|
2017-11-09 08:38:07 +01:00
|
|
|
});
|
2018-08-08 12:40:03 +02:00
|
|
|
|
|
|
|
|
const ChoicePair oldChoice = AutotestPlugin::cachedChoiceFor(buildTargetKey);
|
|
|
|
|
if (!oldChoice.executable.isEmpty()) {
|
|
|
|
|
runConfig = Utils::findOrDefault(runConfigurations,
|
2022-12-07 14:45:43 +01:00
|
|
|
[&oldChoice](const RunConfiguration *rc) {
|
2018-08-08 12:40:03 +02:00
|
|
|
return oldChoice.matches(rc);
|
|
|
|
|
});
|
|
|
|
|
if (runConfig)
|
|
|
|
|
return runConfig;
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-09 08:38:07 +01:00
|
|
|
if (runConfigurations.size() == 1)
|
|
|
|
|
return runConfigurations.first();
|
|
|
|
|
|
TestRunner: Reuse TaskTree
Get rid of QFutureInterface argument from
ITestConfiguration::createOutputReader() and from
TestOutputReader c'tor.
The fine-grained progress reporting was broken anyway:
1. The assumption was that testCaseCount was meant to be
the total number of test functions executed. It didn't
include the initTestCase() and cleanupTestCase(),
while those were reported on runtime apparently
(and exceeding the max progress by 2).
2. In case of tst_qtcprocess, when the whole test was run,
the testCaseCount reported 41, while the real
number of functions was 26 (+2 = 28 for init/cleanup).
3. While the max progress was set to testCaseCount initially,
the corresponding FutureProgress rendered the progress
always in 0-100 range, what didn't match the reality.
Instead, rely on TaskTree progress, which resolution
is per test as a whole. So, when executing a series
of tests this should scale fine. In addition, the
progress advances fluently according to the expected
run time - with 10 seconds hardcoded.
The original code locations, where progress was bumped,
are left with a TODO comment for any possible future tweaks.
Like in case of result reporting, fine-grained progress
reporting may be implemented by providing additional signal,
so there is no need for QFutureInterface inside
TestOutputReader.
Change-Id: Idc11d55e3a49dac8d1788948b9a82f68199203c6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-17 00:45:50 +01:00
|
|
|
RunConfigurationSelectionDialog dialog(buildTargetKey, ICore::dialogParent());
|
2017-09-13 14:27:20 +02:00
|
|
|
if (dialog.exec() == QDialog::Accepted) {
|
|
|
|
|
const QString dName = dialog.displayName();
|
|
|
|
|
if (dName.isEmpty())
|
2017-11-09 08:38:07 +01:00
|
|
|
return nullptr;
|
2017-09-13 14:27:20 +02:00
|
|
|
// run configuration has been selected - fill config based on this one..
|
2022-09-22 17:23:20 +02:00
|
|
|
const FilePath exe = FilePath::fromString(dialog.executable());
|
2022-12-07 14:45:43 +01:00
|
|
|
runConfig = Utils::findOr(runConfigurations, nullptr, [&dName, &exe](const RunConfiguration *rc) {
|
2017-11-09 08:38:07 +01:00
|
|
|
if (rc->displayName() != dName)
|
|
|
|
|
return false;
|
2022-09-22 17:23:20 +02:00
|
|
|
return rc->runnable().command.executable() == exe;
|
2017-11-09 08:38:07 +01:00
|
|
|
});
|
2018-08-08 12:40:03 +02:00
|
|
|
if (runConfig && dialog.rememberChoice())
|
|
|
|
|
AutotestPlugin::cacheRunConfigChoice(buildTargetKey, ChoicePair(dName, exe));
|
2017-09-13 14:27:20 +02:00
|
|
|
}
|
2017-11-09 08:38:07 +01:00
|
|
|
return runConfig;
|
2017-09-13 14:27:20 +02:00
|
|
|
}
|
|
|
|
|
|
2018-05-17 08:34:03 +02:00
|
|
|
int TestRunner::precheckTestConfigurations()
|
|
|
|
|
{
|
2023-05-12 11:00:00 +02:00
|
|
|
const bool omitWarnings = TestSettings::instance()->omitRunConfigWarn();
|
2018-05-17 08:34:03 +02:00
|
|
|
int testCaseCount = 0;
|
2022-10-07 14:46:06 +02:00
|
|
|
for (ITestConfiguration *itc : std::as_const(m_selectedTests)) {
|
2021-01-25 16:19:38 +01:00
|
|
|
if (itc->testBase()->type() == ITestBase::Tool) {
|
2020-10-19 14:42:25 +02:00
|
|
|
if (itc->project()) {
|
|
|
|
|
testCaseCount += itc->testCaseCount();
|
|
|
|
|
} else {
|
|
|
|
|
reportResult(ResultType::MessageWarn,
|
2022-07-13 18:31:56 +02:00
|
|
|
Tr::tr("Project is null for \"%1\". Removing from test run.\n"
|
|
|
|
|
"Check the test environment.").arg(itc->displayName()));
|
2020-10-19 14:42:25 +02:00
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2020-10-13 11:37:37 +02:00
|
|
|
TestConfiguration *config = static_cast<TestConfiguration *>(itc);
|
2018-05-17 08:34:03 +02:00
|
|
|
config->completeTestInformation(TestRunMode::Run);
|
|
|
|
|
if (config->project()) {
|
|
|
|
|
testCaseCount += config->testCaseCount();
|
2018-09-21 09:10:54 +02:00
|
|
|
if (!omitWarnings && config->isDeduced()) {
|
2022-07-13 18:31:56 +02:00
|
|
|
QString message = Tr::tr(
|
2018-09-21 09:10:54 +02:00
|
|
|
"Project's run configuration was deduced for \"%1\".\n"
|
2018-05-17 08:34:03 +02:00
|
|
|
"This might cause trouble during execution.\n"
|
2018-09-21 09:10:54 +02:00
|
|
|
"(deduced from \"%2\")");
|
2020-10-13 11:37:37 +02:00
|
|
|
message = message.arg(config->displayName(), config->runConfigDisplayName());
|
2019-02-06 14:11:19 +01:00
|
|
|
reportResult(ResultType::MessageWarn, message);
|
2018-05-17 08:34:03 +02:00
|
|
|
}
|
|
|
|
|
} else {
|
2019-02-06 14:11:19 +01:00
|
|
|
reportResult(ResultType::MessageWarn,
|
2022-07-13 18:31:56 +02:00
|
|
|
Tr::tr("Project is null for \"%1\". Removing from test run.\n"
|
|
|
|
|
"Check the test environment.").arg(config->displayName()));
|
2018-05-17 08:34:03 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return testCaseCount;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-17 09:23:55 +01:00
|
|
|
void TestRunner::onBuildSystemUpdated()
|
|
|
|
|
{
|
2023-02-14 15:47:22 +01:00
|
|
|
Target *target = ProjectManager::startupTarget();
|
2020-03-17 09:23:55 +01:00
|
|
|
if (QTC_GUARD(target))
|
|
|
|
|
disconnect(target, &Target::buildSystemUpdated, this, &TestRunner::onBuildSystemUpdated);
|
2020-03-18 09:51:41 +01:00
|
|
|
if (!m_skipTargetsCheck) {
|
|
|
|
|
m_skipTargetsCheck = true;
|
|
|
|
|
runOrDebugTests();
|
|
|
|
|
}
|
2020-03-17 09:23:55 +01:00
|
|
|
}
|
|
|
|
|
|
2023-01-13 12:30:42 +01:00
|
|
|
void TestRunner::runTestsHelper()
|
2015-06-29 09:22:58 +02:00
|
|
|
{
|
2020-10-13 11:37:37 +02:00
|
|
|
QList<ITestConfiguration *> toBeRemoved;
|
2018-06-21 10:36:50 +02:00
|
|
|
bool projectChanged = false;
|
2022-10-07 14:46:06 +02:00
|
|
|
for (ITestConfiguration *itc : std::as_const(m_selectedTests)) {
|
2021-01-25 16:19:38 +01:00
|
|
|
if (itc->testBase()->type() == ITestBase::Tool) {
|
2023-02-14 15:47:22 +01:00
|
|
|
if (itc->project() != ProjectManager::startupProject()) {
|
2020-10-19 14:42:25 +02:00
|
|
|
projectChanged = true;
|
|
|
|
|
toBeRemoved.append(itc);
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2020-10-13 11:37:37 +02:00
|
|
|
TestConfiguration *config = static_cast<TestConfiguration *>(itc);
|
2017-09-13 14:27:20 +02:00
|
|
|
config->completeTestInformation(TestRunMode::Run);
|
2018-06-21 10:36:50 +02:00
|
|
|
if (!config->project()) {
|
|
|
|
|
projectChanged = true;
|
|
|
|
|
toBeRemoved.append(config);
|
|
|
|
|
} else if (!config->hasExecutable()) {
|
2018-08-08 12:34:19 +02:00
|
|
|
if (auto rc = getRunConfiguration(firstNonEmptyTestCaseTarget(config)))
|
2017-11-09 08:38:07 +01:00
|
|
|
config->setOriginalRunConfiguration(rc);
|
|
|
|
|
else
|
2017-09-28 13:46:22 +02:00
|
|
|
toBeRemoved.append(config);
|
2017-11-09 08:38:07 +01:00
|
|
|
}
|
2017-09-13 14:27:20 +02:00
|
|
|
}
|
2020-10-13 11:37:37 +02:00
|
|
|
for (ITestConfiguration *config : toBeRemoved)
|
2017-09-28 13:46:22 +02:00
|
|
|
m_selectedTests.removeOne(config);
|
|
|
|
|
qDeleteAll(toBeRemoved);
|
|
|
|
|
toBeRemoved.clear();
|
|
|
|
|
if (m_selectedTests.isEmpty()) {
|
2022-07-13 18:31:56 +02:00
|
|
|
QString mssg = projectChanged ? Tr::tr("Startup project has changed. Canceling test run.")
|
|
|
|
|
: Tr::tr("No test cases left for execution. Canceling test run.");
|
2018-06-21 10:36:50 +02:00
|
|
|
|
2019-02-06 14:11:19 +01:00
|
|
|
reportResult(ResultType::MessageWarn, mssg);
|
2017-09-28 13:46:22 +02:00
|
|
|
onFinished();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
TestRunner: Reuse TaskTree
Get rid of QFutureInterface argument from
ITestConfiguration::createOutputReader() and from
TestOutputReader c'tor.
The fine-grained progress reporting was broken anyway:
1. The assumption was that testCaseCount was meant to be
the total number of test functions executed. It didn't
include the initTestCase() and cleanupTestCase(),
while those were reported on runtime apparently
(and exceeding the max progress by 2).
2. In case of tst_qtcprocess, when the whole test was run,
the testCaseCount reported 41, while the real
number of functions was 26 (+2 = 28 for init/cleanup).
3. While the max progress was set to testCaseCount initially,
the corresponding FutureProgress rendered the progress
always in 0-100 range, what didn't match the reality.
Instead, rely on TaskTree progress, which resolution
is per test as a whole. So, when executing a series
of tests this should scale fine. In addition, the
progress advances fluently according to the expected
run time - with 10 seconds hardcoded.
The original code locations, where progress was bumped,
are left with a TODO comment for any possible future tweaks.
Like in case of result reporting, fine-grained progress
reporting may be implemented by providing additional signal,
so there is no need for QFutureInterface inside
TestOutputReader.
Change-Id: Idc11d55e3a49dac8d1788948b9a82f68199203c6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-17 00:45:50 +01:00
|
|
|
const int testCaseCount = precheckTestConfigurations();
|
|
|
|
|
Q_UNUSED(testCaseCount) // TODO: may be useful for fine-grained progress reporting, when fixed
|
|
|
|
|
|
|
|
|
|
struct TestStorage {
|
|
|
|
|
std::unique_ptr<TestOutputReader> m_outputReader;
|
|
|
|
|
};
|
|
|
|
|
|
2023-05-29 20:16:19 +02:00
|
|
|
QList<GroupItem> tasks{finishAllAndDone};
|
TestRunner: Reuse TaskTree
Get rid of QFutureInterface argument from
ITestConfiguration::createOutputReader() and from
TestOutputReader c'tor.
The fine-grained progress reporting was broken anyway:
1. The assumption was that testCaseCount was meant to be
the total number of test functions executed. It didn't
include the initTestCase() and cleanupTestCase(),
while those were reported on runtime apparently
(and exceeding the max progress by 2).
2. In case of tst_qtcprocess, when the whole test was run,
the testCaseCount reported 41, while the real
number of functions was 26 (+2 = 28 for init/cleanup).
3. While the max progress was set to testCaseCount initially,
the corresponding FutureProgress rendered the progress
always in 0-100 range, what didn't match the reality.
Instead, rely on TaskTree progress, which resolution
is per test as a whole. So, when executing a series
of tests this should scale fine. In addition, the
progress advances fluently according to the expected
run time - with 10 seconds hardcoded.
The original code locations, where progress was bumped,
are left with a TODO comment for any possible future tweaks.
Like in case of result reporting, fine-grained progress
reporting may be implemented by providing additional signal,
so there is no need for QFutureInterface inside
TestOutputReader.
Change-Id: Idc11d55e3a49dac8d1788948b9a82f68199203c6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-17 00:45:50 +01:00
|
|
|
|
|
|
|
|
for (ITestConfiguration *config : m_selectedTests) {
|
|
|
|
|
QTC_ASSERT(config, continue);
|
|
|
|
|
const TreeStorage<TestStorage> storage;
|
|
|
|
|
|
2023-05-02 09:28:52 +02:00
|
|
|
const auto onSetup = [this, config] {
|
TestRunner: Reuse TaskTree
Get rid of QFutureInterface argument from
ITestConfiguration::createOutputReader() and from
TestOutputReader c'tor.
The fine-grained progress reporting was broken anyway:
1. The assumption was that testCaseCount was meant to be
the total number of test functions executed. It didn't
include the initTestCase() and cleanupTestCase(),
while those were reported on runtime apparently
(and exceeding the max progress by 2).
2. In case of tst_qtcprocess, when the whole test was run,
the testCaseCount reported 41, while the real
number of functions was 26 (+2 = 28 for init/cleanup).
3. While the max progress was set to testCaseCount initially,
the corresponding FutureProgress rendered the progress
always in 0-100 range, what didn't match the reality.
Instead, rely on TaskTree progress, which resolution
is per test as a whole. So, when executing a series
of tests this should scale fine. In addition, the
progress advances fluently according to the expected
run time - with 10 seconds hardcoded.
The original code locations, where progress was bumped,
are left with a TODO comment for any possible future tweaks.
Like in case of result reporting, fine-grained progress
reporting may be implemented by providing additional signal,
so there is no need for QFutureInterface inside
TestOutputReader.
Change-Id: Idc11d55e3a49dac8d1788948b9a82f68199203c6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-17 00:45:50 +01:00
|
|
|
if (!config->project())
|
2023-06-16 21:33:59 +02:00
|
|
|
return SetupResult::StopWithDone;
|
TestRunner: Reuse TaskTree
Get rid of QFutureInterface argument from
ITestConfiguration::createOutputReader() and from
TestOutputReader c'tor.
The fine-grained progress reporting was broken anyway:
1. The assumption was that testCaseCount was meant to be
the total number of test functions executed. It didn't
include the initTestCase() and cleanupTestCase(),
while those were reported on runtime apparently
(and exceeding the max progress by 2).
2. In case of tst_qtcprocess, when the whole test was run,
the testCaseCount reported 41, while the real
number of functions was 26 (+2 = 28 for init/cleanup).
3. While the max progress was set to testCaseCount initially,
the corresponding FutureProgress rendered the progress
always in 0-100 range, what didn't match the reality.
Instead, rely on TaskTree progress, which resolution
is per test as a whole. So, when executing a series
of tests this should scale fine. In addition, the
progress advances fluently according to the expected
run time - with 10 seconds hardcoded.
The original code locations, where progress was bumped,
are left with a TODO comment for any possible future tweaks.
Like in case of result reporting, fine-grained progress
reporting may be implemented by providing additional signal,
so there is no need for QFutureInterface inside
TestOutputReader.
Change-Id: Idc11d55e3a49dac8d1788948b9a82f68199203c6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-17 00:45:50 +01:00
|
|
|
if (config->testExecutable().isEmpty()) {
|
|
|
|
|
reportResult(ResultType::MessageFatal,
|
|
|
|
|
Tr::tr("Executable path is empty. (%1)").arg(config->displayName()));
|
2023-06-16 21:33:59 +02:00
|
|
|
return SetupResult::StopWithDone;
|
TestRunner: Reuse TaskTree
Get rid of QFutureInterface argument from
ITestConfiguration::createOutputReader() and from
TestOutputReader c'tor.
The fine-grained progress reporting was broken anyway:
1. The assumption was that testCaseCount was meant to be
the total number of test functions executed. It didn't
include the initTestCase() and cleanupTestCase(),
while those were reported on runtime apparently
(and exceeding the max progress by 2).
2. In case of tst_qtcprocess, when the whole test was run,
the testCaseCount reported 41, while the real
number of functions was 26 (+2 = 28 for init/cleanup).
3. While the max progress was set to testCaseCount initially,
the corresponding FutureProgress rendered the progress
always in 0-100 range, what didn't match the reality.
Instead, rely on TaskTree progress, which resolution
is per test as a whole. So, when executing a series
of tests this should scale fine. In addition, the
progress advances fluently according to the expected
run time - with 10 seconds hardcoded.
The original code locations, where progress was bumped,
are left with a TODO comment for any possible future tweaks.
Like in case of result reporting, fine-grained progress
reporting may be implemented by providing additional signal,
so there is no need for QFutureInterface inside
TestOutputReader.
Change-Id: Idc11d55e3a49dac8d1788948b9a82f68199203c6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-17 00:45:50 +01:00
|
|
|
}
|
2023-06-16 21:33:59 +02:00
|
|
|
return SetupResult::Continue;
|
TestRunner: Reuse TaskTree
Get rid of QFutureInterface argument from
ITestConfiguration::createOutputReader() and from
TestOutputReader c'tor.
The fine-grained progress reporting was broken anyway:
1. The assumption was that testCaseCount was meant to be
the total number of test functions executed. It didn't
include the initTestCase() and cleanupTestCase(),
while those were reported on runtime apparently
(and exceeding the max progress by 2).
2. In case of tst_qtcprocess, when the whole test was run,
the testCaseCount reported 41, while the real
number of functions was 26 (+2 = 28 for init/cleanup).
3. While the max progress was set to testCaseCount initially,
the corresponding FutureProgress rendered the progress
always in 0-100 range, what didn't match the reality.
Instead, rely on TaskTree progress, which resolution
is per test as a whole. So, when executing a series
of tests this should scale fine. In addition, the
progress advances fluently according to the expected
run time - with 10 seconds hardcoded.
The original code locations, where progress was bumped,
are left with a TODO comment for any possible future tweaks.
Like in case of result reporting, fine-grained progress
reporting may be implemented by providing additional signal,
so there is no need for QFutureInterface inside
TestOutputReader.
Change-Id: Idc11d55e3a49dac8d1788948b9a82f68199203c6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-17 00:45:50 +01:00
|
|
|
};
|
2023-05-02 09:28:52 +02:00
|
|
|
const auto onProcessSetup = [this, config, storage](Process &process) {
|
TestRunner: Reuse TaskTree
Get rid of QFutureInterface argument from
ITestConfiguration::createOutputReader() and from
TestOutputReader c'tor.
The fine-grained progress reporting was broken anyway:
1. The assumption was that testCaseCount was meant to be
the total number of test functions executed. It didn't
include the initTestCase() and cleanupTestCase(),
while those were reported on runtime apparently
(and exceeding the max progress by 2).
2. In case of tst_qtcprocess, when the whole test was run,
the testCaseCount reported 41, while the real
number of functions was 26 (+2 = 28 for init/cleanup).
3. While the max progress was set to testCaseCount initially,
the corresponding FutureProgress rendered the progress
always in 0-100 range, what didn't match the reality.
Instead, rely on TaskTree progress, which resolution
is per test as a whole. So, when executing a series
of tests this should scale fine. In addition, the
progress advances fluently according to the expected
run time - with 10 seconds hardcoded.
The original code locations, where progress was bumped,
are left with a TODO comment for any possible future tweaks.
Like in case of result reporting, fine-grained progress
reporting may be implemented by providing additional signal,
so there is no need for QFutureInterface inside
TestOutputReader.
Change-Id: Idc11d55e3a49dac8d1788948b9a82f68199203c6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-17 00:45:50 +01:00
|
|
|
TestStorage *testStorage = storage.activeStorage();
|
|
|
|
|
QTC_ASSERT(testStorage, return);
|
|
|
|
|
testStorage->m_outputReader.reset(config->createOutputReader(&process));
|
|
|
|
|
QTC_ASSERT(testStorage->m_outputReader, return);
|
|
|
|
|
connect(testStorage->m_outputReader.get(), &TestOutputReader::newResult,
|
|
|
|
|
this, &TestRunner::testResultReady);
|
|
|
|
|
connect(testStorage->m_outputReader.get(), &TestOutputReader::newOutputLineAvailable,
|
|
|
|
|
TestResultsPane::instance(), &TestResultsPane::addOutputLine);
|
|
|
|
|
|
|
|
|
|
CommandLine command{config->testExecutable(), {}};
|
|
|
|
|
if (config->testBase()->type() == ITestBase::Framework) {
|
|
|
|
|
TestConfiguration *current = static_cast<TestConfiguration *>(config);
|
|
|
|
|
QStringList omitted;
|
|
|
|
|
command.addArgs(current->argumentsForTestRunner(&omitted).join(' '), CommandLine::Raw);
|
|
|
|
|
if (!omitted.isEmpty()) {
|
|
|
|
|
const QString &details = constructOmittedDetailsString(omitted);
|
|
|
|
|
reportResult(ResultType::MessageWarn, details.arg(current->displayName()));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
TestToolConfiguration *current = static_cast<TestToolConfiguration *>(config);
|
|
|
|
|
command.setArguments(current->commandLine().arguments());
|
|
|
|
|
}
|
|
|
|
|
process.setCommand(command);
|
|
|
|
|
|
|
|
|
|
process.setWorkingDirectory(config->workingDirectory());
|
|
|
|
|
const Environment &original = config->environment();
|
|
|
|
|
Environment environment = config->filteredEnvironment(original);
|
|
|
|
|
const EnvironmentItems removedVariables = Utils::filtered(
|
|
|
|
|
original.diff(environment), [](const EnvironmentItem &it) {
|
|
|
|
|
return it.operation == EnvironmentItem::Unset;
|
|
|
|
|
});
|
|
|
|
|
if (!removedVariables.isEmpty()) {
|
|
|
|
|
const QString &details = constructOmittedVariablesDetailsString(removedVariables)
|
|
|
|
|
.arg(config->displayName());
|
|
|
|
|
reportResult(ResultType::MessageWarn, details);
|
|
|
|
|
}
|
|
|
|
|
process.setEnvironment(environment);
|
|
|
|
|
|
2023-05-12 11:00:00 +02:00
|
|
|
m_cancelTimer.setInterval(TestSettings::instance()->timeout());
|
TestRunner: Reuse TaskTree
Get rid of QFutureInterface argument from
ITestConfiguration::createOutputReader() and from
TestOutputReader c'tor.
The fine-grained progress reporting was broken anyway:
1. The assumption was that testCaseCount was meant to be
the total number of test functions executed. It didn't
include the initTestCase() and cleanupTestCase(),
while those were reported on runtime apparently
(and exceeding the max progress by 2).
2. In case of tst_qtcprocess, when the whole test was run,
the testCaseCount reported 41, while the real
number of functions was 26 (+2 = 28 for init/cleanup).
3. While the max progress was set to testCaseCount initially,
the corresponding FutureProgress rendered the progress
always in 0-100 range, what didn't match the reality.
Instead, rely on TaskTree progress, which resolution
is per test as a whole. So, when executing a series
of tests this should scale fine. In addition, the
progress advances fluently according to the expected
run time - with 10 seconds hardcoded.
The original code locations, where progress was bumped,
are left with a TODO comment for any possible future tweaks.
Like in case of result reporting, fine-grained progress
reporting may be implemented by providing additional signal,
so there is no need for QFutureInterface inside
TestOutputReader.
Change-Id: Idc11d55e3a49dac8d1788948b9a82f68199203c6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-17 00:45:50 +01:00
|
|
|
m_cancelTimer.start();
|
|
|
|
|
|
|
|
|
|
qCInfo(runnerLog) << "Command:" << process.commandLine().executable();
|
|
|
|
|
qCInfo(runnerLog) << "Arguments:" << process.commandLine().arguments();
|
|
|
|
|
qCInfo(runnerLog) << "Working directory:" << process.workingDirectory();
|
|
|
|
|
qCDebug(runnerLog) << "Environment:" << process.environment().toStringList();
|
|
|
|
|
};
|
2023-05-02 09:28:52 +02:00
|
|
|
const auto onProcessDone = [this, config, storage](const Process &process) {
|
TestRunner: Reuse TaskTree
Get rid of QFutureInterface argument from
ITestConfiguration::createOutputReader() and from
TestOutputReader c'tor.
The fine-grained progress reporting was broken anyway:
1. The assumption was that testCaseCount was meant to be
the total number of test functions executed. It didn't
include the initTestCase() and cleanupTestCase(),
while those were reported on runtime apparently
(and exceeding the max progress by 2).
2. In case of tst_qtcprocess, when the whole test was run,
the testCaseCount reported 41, while the real
number of functions was 26 (+2 = 28 for init/cleanup).
3. While the max progress was set to testCaseCount initially,
the corresponding FutureProgress rendered the progress
always in 0-100 range, what didn't match the reality.
Instead, rely on TaskTree progress, which resolution
is per test as a whole. So, when executing a series
of tests this should scale fine. In addition, the
progress advances fluently according to the expected
run time - with 10 seconds hardcoded.
The original code locations, where progress was bumped,
are left with a TODO comment for any possible future tweaks.
Like in case of result reporting, fine-grained progress
reporting may be implemented by providing additional signal,
so there is no need for QFutureInterface inside
TestOutputReader.
Change-Id: Idc11d55e3a49dac8d1788948b9a82f68199203c6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-17 00:45:50 +01:00
|
|
|
TestStorage *testStorage = storage.activeStorage();
|
|
|
|
|
QTC_ASSERT(testStorage, return);
|
|
|
|
|
if (process.result() == ProcessResult::StartFailed) {
|
|
|
|
|
reportResult(ResultType::MessageFatal,
|
|
|
|
|
Tr::tr("Failed to start test for project \"%1\".").arg(config->displayName())
|
|
|
|
|
+ processInformation(&process) + rcInfo(config));
|
|
|
|
|
}
|
2018-05-17 08:34:03 +02:00
|
|
|
|
2023-06-20 08:58:49 +02:00
|
|
|
if (testStorage->m_outputReader)
|
|
|
|
|
testStorage->m_outputReader->onDone(process.exitCode());
|
|
|
|
|
|
TestRunner: Reuse TaskTree
Get rid of QFutureInterface argument from
ITestConfiguration::createOutputReader() and from
TestOutputReader c'tor.
The fine-grained progress reporting was broken anyway:
1. The assumption was that testCaseCount was meant to be
the total number of test functions executed. It didn't
include the initTestCase() and cleanupTestCase(),
while those were reported on runtime apparently
(and exceeding the max progress by 2).
2. In case of tst_qtcprocess, when the whole test was run,
the testCaseCount reported 41, while the real
number of functions was 26 (+2 = 28 for init/cleanup).
3. While the max progress was set to testCaseCount initially,
the corresponding FutureProgress rendered the progress
always in 0-100 range, what didn't match the reality.
Instead, rely on TaskTree progress, which resolution
is per test as a whole. So, when executing a series
of tests this should scale fine. In addition, the
progress advances fluently according to the expected
run time - with 10 seconds hardcoded.
The original code locations, where progress was bumped,
are left with a TODO comment for any possible future tweaks.
Like in case of result reporting, fine-grained progress
reporting may be implemented by providing additional signal,
so there is no need for QFutureInterface inside
TestOutputReader.
Change-Id: Idc11d55e3a49dac8d1788948b9a82f68199203c6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-17 00:45:50 +01:00
|
|
|
if (process.exitStatus() == QProcess::CrashExit) {
|
|
|
|
|
if (testStorage->m_outputReader)
|
|
|
|
|
testStorage->m_outputReader->reportCrash();
|
|
|
|
|
reportResult(ResultType::MessageFatal,
|
|
|
|
|
Tr::tr("Test for project \"%1\" crashed.").arg(config->displayName())
|
|
|
|
|
+ processInformation(&process) + rcInfo(config));
|
|
|
|
|
} else if (testStorage->m_outputReader && !testStorage->m_outputReader->hadValidOutput()) {
|
|
|
|
|
reportResult(ResultType::MessageFatal,
|
|
|
|
|
Tr::tr("Test for project \"%1\" did not produce any expected output.")
|
|
|
|
|
.arg(config->displayName()) + processInformation(&process)
|
|
|
|
|
+ rcInfo(config));
|
|
|
|
|
}
|
|
|
|
|
if (testStorage->m_outputReader) {
|
|
|
|
|
const int disabled = testStorage->m_outputReader->disabledTests();
|
|
|
|
|
if (disabled > 0)
|
|
|
|
|
emit hadDisabledTests(disabled);
|
|
|
|
|
if (testStorage->m_outputReader->hasSummary())
|
|
|
|
|
emit reportSummary(testStorage->m_outputReader->id(), testStorage->m_outputReader->summary());
|
|
|
|
|
|
|
|
|
|
testStorage->m_outputReader->resetCommandlineColor();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
const Group group {
|
2023-05-28 17:20:55 +02:00
|
|
|
finishAllAndDone,
|
TestRunner: Reuse TaskTree
Get rid of QFutureInterface argument from
ITestConfiguration::createOutputReader() and from
TestOutputReader c'tor.
The fine-grained progress reporting was broken anyway:
1. The assumption was that testCaseCount was meant to be
the total number of test functions executed. It didn't
include the initTestCase() and cleanupTestCase(),
while those were reported on runtime apparently
(and exceeding the max progress by 2).
2. In case of tst_qtcprocess, when the whole test was run,
the testCaseCount reported 41, while the real
number of functions was 26 (+2 = 28 for init/cleanup).
3. While the max progress was set to testCaseCount initially,
the corresponding FutureProgress rendered the progress
always in 0-100 range, what didn't match the reality.
Instead, rely on TaskTree progress, which resolution
is per test as a whole. So, when executing a series
of tests this should scale fine. In addition, the
progress advances fluently according to the expected
run time - with 10 seconds hardcoded.
The original code locations, where progress was bumped,
are left with a TODO comment for any possible future tweaks.
Like in case of result reporting, fine-grained progress
reporting may be implemented by providing additional signal,
so there is no need for QFutureInterface inside
TestOutputReader.
Change-Id: Idc11d55e3a49dac8d1788948b9a82f68199203c6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-17 00:45:50 +01:00
|
|
|
Storage(storage),
|
2023-05-02 12:31:16 +02:00
|
|
|
onGroupSetup(onSetup),
|
2023-05-02 09:28:52 +02:00
|
|
|
ProcessTask(onProcessSetup, onProcessDone, onProcessDone)
|
TestRunner: Reuse TaskTree
Get rid of QFutureInterface argument from
ITestConfiguration::createOutputReader() and from
TestOutputReader c'tor.
The fine-grained progress reporting was broken anyway:
1. The assumption was that testCaseCount was meant to be
the total number of test functions executed. It didn't
include the initTestCase() and cleanupTestCase(),
while those were reported on runtime apparently
(and exceeding the max progress by 2).
2. In case of tst_qtcprocess, when the whole test was run,
the testCaseCount reported 41, while the real
number of functions was 26 (+2 = 28 for init/cleanup).
3. While the max progress was set to testCaseCount initially,
the corresponding FutureProgress rendered the progress
always in 0-100 range, what didn't match the reality.
Instead, rely on TaskTree progress, which resolution
is per test as a whole. So, when executing a series
of tests this should scale fine. In addition, the
progress advances fluently according to the expected
run time - with 10 seconds hardcoded.
The original code locations, where progress was bumped,
are left with a TODO comment for any possible future tweaks.
Like in case of result reporting, fine-grained progress
reporting may be implemented by providing additional signal,
so there is no need for QFutureInterface inside
TestOutputReader.
Change-Id: Idc11d55e3a49dac8d1788948b9a82f68199203c6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-17 00:45:50 +01:00
|
|
|
};
|
|
|
|
|
tasks.append(group);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_taskTree.reset(new TaskTree(tasks));
|
|
|
|
|
connect(m_taskTree.get(), &TaskTree::done, this, &TestRunner::onFinished);
|
|
|
|
|
connect(m_taskTree.get(), &TaskTree::errorOccurred, this, &TestRunner::onFinished);
|
|
|
|
|
|
|
|
|
|
auto progress = new TaskProgress(m_taskTree.get());
|
2023-06-09 13:33:02 +02:00
|
|
|
progress->setDisplayName(Tr::tr("Running Tests"));
|
TestRunner: Reuse TaskTree
Get rid of QFutureInterface argument from
ITestConfiguration::createOutputReader() and from
TestOutputReader c'tor.
The fine-grained progress reporting was broken anyway:
1. The assumption was that testCaseCount was meant to be
the total number of test functions executed. It didn't
include the initTestCase() and cleanupTestCase(),
while those were reported on runtime apparently
(and exceeding the max progress by 2).
2. In case of tst_qtcprocess, when the whole test was run,
the testCaseCount reported 41, while the real
number of functions was 26 (+2 = 28 for init/cleanup).
3. While the max progress was set to testCaseCount initially,
the corresponding FutureProgress rendered the progress
always in 0-100 range, what didn't match the reality.
Instead, rely on TaskTree progress, which resolution
is per test as a whole. So, when executing a series
of tests this should scale fine. In addition, the
progress advances fluently according to the expected
run time - with 10 seconds hardcoded.
The original code locations, where progress was bumped,
are left with a TODO comment for any possible future tweaks.
Like in case of result reporting, fine-grained progress
reporting may be implemented by providing additional signal,
so there is no need for QFutureInterface inside
TestOutputReader.
Change-Id: Idc11d55e3a49dac8d1788948b9a82f68199203c6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-17 00:45:50 +01:00
|
|
|
progress->setAutoStopOnCancel(false);
|
|
|
|
|
progress->setHalfLifeTimePerTask(10000); // 10 seconds
|
|
|
|
|
connect(progress, &TaskProgress::canceled, this, [this, progress] {
|
|
|
|
|
// progress was a child of task tree which is going to be deleted directly. Unwind properly.
|
|
|
|
|
progress->setParent(nullptr);
|
|
|
|
|
progress->deleteLater();
|
|
|
|
|
cancelCurrent(UserCanceled);
|
|
|
|
|
});
|
2018-05-17 12:16:56 +02:00
|
|
|
|
2023-05-12 11:00:00 +02:00
|
|
|
if (TestSettings::instance()->popupOnStart())
|
2019-03-13 11:05:22 +01:00
|
|
|
AutotestPlugin::popupResultsPane();
|
TestRunner: Reuse TaskTree
Get rid of QFutureInterface argument from
ITestConfiguration::createOutputReader() and from
TestOutputReader c'tor.
The fine-grained progress reporting was broken anyway:
1. The assumption was that testCaseCount was meant to be
the total number of test functions executed. It didn't
include the initTestCase() and cleanupTestCase(),
while those were reported on runtime apparently
(and exceeding the max progress by 2).
2. In case of tst_qtcprocess, when the whole test was run,
the testCaseCount reported 41, while the real
number of functions was 26 (+2 = 28 for init/cleanup).
3. While the max progress was set to testCaseCount initially,
the corresponding FutureProgress rendered the progress
always in 0-100 range, what didn't match the reality.
Instead, rely on TaskTree progress, which resolution
is per test as a whole. So, when executing a series
of tests this should scale fine. In addition, the
progress advances fluently according to the expected
run time - with 10 seconds hardcoded.
The original code locations, where progress was bumped,
are left with a TODO comment for any possible future tweaks.
Like in case of result reporting, fine-grained progress
reporting may be implemented by providing additional signal,
so there is no need for QFutureInterface inside
TestOutputReader.
Change-Id: Idc11d55e3a49dac8d1788948b9a82f68199203c6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-17 00:45:50 +01:00
|
|
|
|
|
|
|
|
m_taskTree->start();
|
2014-11-04 12:35:00 +01:00
|
|
|
}
|
|
|
|
|
|
2023-01-13 13:27:25 +01:00
|
|
|
static void processOutput(TestOutputReader *outputreader, const QString &msg, OutputFormat format)
|
2016-07-21 16:02:42 +02:00
|
|
|
{
|
2018-11-06 16:00:48 +01:00
|
|
|
QByteArray message = msg.toUtf8();
|
2017-04-06 15:42:09 +02:00
|
|
|
switch (format) {
|
2023-01-13 13:27:25 +01:00
|
|
|
case OutputFormat::StdErrFormat:
|
|
|
|
|
case OutputFormat::StdOutFormat:
|
|
|
|
|
case OutputFormat::DebugFormat: {
|
2018-11-06 16:00:48 +01:00
|
|
|
static const QByteArray gdbSpecialOut = "Qt: gdb: -nograb added to command-line options.\n"
|
|
|
|
|
"\t Use the -dograb option to enforce grabbing.";
|
2019-11-11 08:03:16 +01:00
|
|
|
if (message.startsWith(gdbSpecialOut))
|
|
|
|
|
message = message.mid(gdbSpecialOut.length() + 1);
|
|
|
|
|
message.chop(1); // all messages have an additional \n at the end
|
2018-11-06 16:00:48 +01:00
|
|
|
|
2020-06-11 16:53:11 +02:00
|
|
|
for (const auto &line : message.split('\n')) {
|
2023-01-13 13:27:25 +01:00
|
|
|
if (format == OutputFormat::StdOutFormat)
|
2019-11-11 08:03:16 +01:00
|
|
|
outputreader->processStdOutput(line);
|
|
|
|
|
else
|
|
|
|
|
outputreader->processStdError(line);
|
2018-11-06 16:00:48 +01:00
|
|
|
}
|
2016-07-21 16:02:42 +02:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
2017-04-06 15:42:09 +02:00
|
|
|
break; // channels we're not caring about
|
2016-07-21 16:02:42 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-15 12:29:24 +02:00
|
|
|
void TestRunner::debugTests()
|
|
|
|
|
{
|
|
|
|
|
// TODO improve to support more than one test configuration
|
2023-01-13 12:58:08 +01:00
|
|
|
QTC_ASSERT(m_selectedTests.size() == 1, onFinished(); return);
|
2016-06-15 12:29:24 +02:00
|
|
|
|
2020-10-13 11:37:37 +02:00
|
|
|
ITestConfiguration *itc = m_selectedTests.first();
|
2023-01-13 12:58:08 +01:00
|
|
|
QTC_ASSERT(itc->testBase()->type() == ITestBase::Framework, onFinished(); return);
|
2020-10-19 14:42:25 +02:00
|
|
|
|
2020-10-13 11:37:37 +02:00
|
|
|
TestConfiguration *config = static_cast<TestConfiguration *>(itc);
|
2017-09-05 13:57:22 +02:00
|
|
|
config->completeTestInformation(TestRunMode::Debug);
|
2018-06-21 10:36:50 +02:00
|
|
|
if (!config->project()) {
|
2019-02-06 14:11:19 +01:00
|
|
|
reportResult(ResultType::MessageWarn,
|
2022-07-13 18:31:56 +02:00
|
|
|
Tr::tr("Startup project has changed. Canceling test run."));
|
2018-06-21 10:36:50 +02:00
|
|
|
onFinished();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2017-09-13 14:27:20 +02:00
|
|
|
if (!config->hasExecutable()) {
|
2018-08-08 12:34:19 +02:00
|
|
|
if (auto *rc = getRunConfiguration(firstNonEmptyTestCaseTarget(config)))
|
2017-11-09 08:38:07 +01:00
|
|
|
config->completeTestInformation(rc, TestRunMode::Debug);
|
2017-09-13 14:27:20 +02:00
|
|
|
}
|
|
|
|
|
|
2016-06-15 12:29:24 +02:00
|
|
|
if (!config->runConfiguration()) {
|
2022-07-13 18:31:56 +02:00
|
|
|
reportResult(ResultType::MessageFatal, Tr::tr("Failed to get run configuration."));
|
2016-06-15 12:29:24 +02:00
|
|
|
onFinished();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-13 13:27:25 +01:00
|
|
|
const FilePath &commandFilePath = config->executableFilePath();
|
2016-06-15 12:29:24 +02:00
|
|
|
if (commandFilePath.isEmpty()) {
|
2022-07-13 18:31:56 +02:00
|
|
|
reportResult(ResultType::MessageFatal, Tr::tr("Could not find command \"%1\". (%2)")
|
2021-05-26 15:50:03 +02:00
|
|
|
.arg(config->executableFilePath().toString(), config->displayName()));
|
2016-06-15 12:29:24 +02:00
|
|
|
onFinished();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-19 14:46:20 +02:00
|
|
|
auto runControl = new RunControl(ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
2022-04-13 17:57:11 +02:00
|
|
|
runControl->copyDataFromRunConfiguration(config->runConfiguration());
|
2016-06-15 12:29:24 +02:00
|
|
|
|
2017-09-01 14:59:39 +02:00
|
|
|
QStringList omitted;
|
2019-08-19 14:46:20 +02:00
|
|
|
Runnable inferior = config->runnable();
|
2021-08-10 09:19:30 +02:00
|
|
|
inferior.command.setExecutable(commandFilePath);
|
2018-02-28 10:50:38 +01:00
|
|
|
|
|
|
|
|
const QStringList args = config->argumentsForTestRunner(&omitted);
|
2023-01-13 13:27:25 +01:00
|
|
|
inferior.command.setArguments(ProcessArgs::joinArgs(args));
|
2017-09-01 14:59:39 +02:00
|
|
|
if (!omitted.isEmpty()) {
|
|
|
|
|
const QString &details = constructOmittedDetailsString(omitted);
|
2019-02-06 14:11:19 +01:00
|
|
|
reportResult(ResultType::MessageWarn, details.arg(config->displayName()));
|
2017-09-01 14:59:39 +02:00
|
|
|
}
|
2023-01-13 13:27:25 +01:00
|
|
|
Environment original(inferior.environment);
|
2018-08-29 12:33:15 +02:00
|
|
|
inferior.environment = config->filteredEnvironment(original);
|
2023-01-13 13:27:25 +01:00
|
|
|
const EnvironmentItems removedVariables = Utils::filtered(
|
|
|
|
|
original.diff(inferior.environment), [](const EnvironmentItem &it) {
|
|
|
|
|
return it.operation == EnvironmentItem::Unset;
|
2019-05-07 16:51:22 +02:00
|
|
|
});
|
2018-08-29 12:33:15 +02:00
|
|
|
if (!removedVariables.isEmpty()) {
|
|
|
|
|
const QString &details = constructOmittedVariablesDetailsString(removedVariables)
|
|
|
|
|
.arg(config->displayName());
|
2019-02-06 14:11:19 +01:00
|
|
|
reportResult(ResultType::MessageWarn, details);
|
2018-08-29 12:33:15 +02:00
|
|
|
}
|
2017-08-24 16:04:25 +02:00
|
|
|
auto debugger = new Debugger::DebuggerRunTool(runControl);
|
|
|
|
|
debugger->setInferior(inferior);
|
|
|
|
|
debugger->setRunControlName(config->displayName());
|
2017-05-26 17:40:30 +02:00
|
|
|
|
2016-07-21 16:02:42 +02:00
|
|
|
bool useOutputProcessor = true;
|
2019-08-19 14:46:20 +02:00
|
|
|
if (Target *targ = config->project()->activeTarget()) {
|
2019-02-06 12:50:51 +01:00
|
|
|
if (Debugger::DebuggerKitAspect::engineType(targ->kit()) == Debugger::CdbEngineType) {
|
2019-02-06 14:11:19 +01:00
|
|
|
reportResult(ResultType::MessageWarn,
|
2022-07-13 18:31:56 +02:00
|
|
|
Tr::tr("Unable to display test results when using CDB."));
|
2016-07-21 16:02:42 +02:00
|
|
|
useOutputProcessor = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (useOutputProcessor) {
|
TestRunner: Reuse TaskTree
Get rid of QFutureInterface argument from
ITestConfiguration::createOutputReader() and from
TestOutputReader c'tor.
The fine-grained progress reporting was broken anyway:
1. The assumption was that testCaseCount was meant to be
the total number of test functions executed. It didn't
include the initTestCase() and cleanupTestCase(),
while those were reported on runtime apparently
(and exceeding the max progress by 2).
2. In case of tst_qtcprocess, when the whole test was run,
the testCaseCount reported 41, while the real
number of functions was 26 (+2 = 28 for init/cleanup).
3. While the max progress was set to testCaseCount initially,
the corresponding FutureProgress rendered the progress
always in 0-100 range, what didn't match the reality.
Instead, rely on TaskTree progress, which resolution
is per test as a whole. So, when executing a series
of tests this should scale fine. In addition, the
progress advances fluently according to the expected
run time - with 10 seconds hardcoded.
The original code locations, where progress was bumped,
are left with a TODO comment for any possible future tweaks.
Like in case of result reporting, fine-grained progress
reporting may be implemented by providing additional signal,
so there is no need for QFutureInterface inside
TestOutputReader.
Change-Id: Idc11d55e3a49dac8d1788948b9a82f68199203c6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-17 00:45:50 +01:00
|
|
|
TestOutputReader *outputreader = config->createOutputReader(nullptr);
|
2023-01-16 15:47:36 +01:00
|
|
|
connect(outputreader, &TestOutputReader::newResult, this, &TestRunner::testResultReady);
|
2021-08-10 09:19:30 +02:00
|
|
|
outputreader->setId(inferior.command.executable().toString());
|
2019-11-11 08:03:16 +01:00
|
|
|
connect(outputreader, &TestOutputReader::newOutputLineAvailable,
|
|
|
|
|
TestResultsPane::instance(), &TestResultsPane::addOutputLine);
|
2019-08-19 14:46:20 +02:00
|
|
|
connect(runControl, &RunControl::appendMessage,
|
2023-01-13 13:27:25 +01:00
|
|
|
this, [outputreader](const QString &msg, OutputFormat format) {
|
2017-04-06 15:42:09 +02:00
|
|
|
processOutput(outputreader, msg, format);
|
|
|
|
|
});
|
TestRunner: Reuse TaskTree
Get rid of QFutureInterface argument from
ITestConfiguration::createOutputReader() and from
TestOutputReader c'tor.
The fine-grained progress reporting was broken anyway:
1. The assumption was that testCaseCount was meant to be
the total number of test functions executed. It didn't
include the initTestCase() and cleanupTestCase(),
while those were reported on runtime apparently
(and exceeding the max progress by 2).
2. In case of tst_qtcprocess, when the whole test was run,
the testCaseCount reported 41, while the real
number of functions was 26 (+2 = 28 for init/cleanup).
3. While the max progress was set to testCaseCount initially,
the corresponding FutureProgress rendered the progress
always in 0-100 range, what didn't match the reality.
Instead, rely on TaskTree progress, which resolution
is per test as a whole. So, when executing a series
of tests this should scale fine. In addition, the
progress advances fluently according to the expected
run time - with 10 seconds hardcoded.
The original code locations, where progress was bumped,
are left with a TODO comment for any possible future tweaks.
Like in case of result reporting, fine-grained progress
reporting may be implemented by providing additional signal,
so there is no need for QFutureInterface inside
TestOutputReader.
Change-Id: Idc11d55e3a49dac8d1788948b9a82f68199203c6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-17 00:45:50 +01:00
|
|
|
connect(runControl, &RunControl::stopped, outputreader, &QObject::deleteLater);
|
2016-07-21 16:02:42 +02:00
|
|
|
}
|
|
|
|
|
|
2018-08-02 15:56:26 +02:00
|
|
|
m_stopDebugConnect = connect(this, &TestRunner::requestStopTestRun,
|
2019-08-19 14:46:20 +02:00
|
|
|
runControl, &RunControl::initiateStop);
|
2018-08-02 15:56:26 +02:00
|
|
|
|
2019-08-19 14:46:20 +02:00
|
|
|
connect(runControl, &RunControl::stopped, this, &TestRunner::onFinished);
|
|
|
|
|
ProjectExplorerPlugin::startRunControl(runControl);
|
2023-05-12 11:00:00 +02:00
|
|
|
if (useOutputProcessor && TestSettings::instance()->popupOnStart())
|
2019-03-13 11:05:22 +01:00
|
|
|
AutotestPlugin::popupResultsPane();
|
2016-06-15 12:29:24 +02:00
|
|
|
}
|
|
|
|
|
|
2020-03-17 09:23:55 +01:00
|
|
|
static bool executablesEmpty()
|
|
|
|
|
{
|
2023-02-14 15:47:22 +01:00
|
|
|
Target *target = ProjectManager::startupTarget();
|
2020-03-17 09:23:55 +01:00
|
|
|
const QList<RunConfiguration *> configs = target->runConfigurations();
|
|
|
|
|
QTC_ASSERT(!configs.isEmpty(), return false);
|
|
|
|
|
if (auto execAspect = configs.first()->aspect<ExecutableAspect>())
|
|
|
|
|
return execAspect->executable().isEmpty();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-15 12:29:24 +02:00
|
|
|
void TestRunner::runOrDebugTests()
|
|
|
|
|
{
|
2020-03-17 09:23:55 +01:00
|
|
|
if (!m_skipTargetsCheck) {
|
|
|
|
|
if (executablesEmpty()) {
|
|
|
|
|
m_skipTargetsCheck = true;
|
2023-02-14 15:47:22 +01:00
|
|
|
Target *target = ProjectManager::startupTarget();
|
2022-12-07 14:45:43 +01:00
|
|
|
QTimer::singleShot(5000, this, [this, target = QPointer<Target>(target)] {
|
2020-03-17 09:23:55 +01:00
|
|
|
if (target) {
|
|
|
|
|
disconnect(target, &Target::buildSystemUpdated,
|
|
|
|
|
this, &TestRunner::onBuildSystemUpdated);
|
|
|
|
|
}
|
|
|
|
|
runOrDebugTests();
|
|
|
|
|
});
|
|
|
|
|
connect(target, &Target::buildSystemUpdated, this, &TestRunner::onBuildSystemUpdated);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-15 12:29:24 +02:00
|
|
|
switch (m_runMode) {
|
2017-09-05 13:57:22 +02:00
|
|
|
case TestRunMode::Run:
|
|
|
|
|
case TestRunMode::RunWithoutDeploy:
|
2019-08-08 09:57:42 +02:00
|
|
|
case TestRunMode::RunAfterBuild:
|
2023-01-13 12:30:42 +01:00
|
|
|
runTestsHelper();
|
2018-07-11 15:44:51 +02:00
|
|
|
return;
|
2017-09-05 13:57:22 +02:00
|
|
|
case TestRunMode::Debug:
|
|
|
|
|
case TestRunMode::DebugWithoutDeploy:
|
2016-06-15 12:29:24 +02:00
|
|
|
debugTests();
|
2018-07-11 15:44:51 +02:00
|
|
|
return;
|
2019-08-08 09:57:42 +02:00
|
|
|
default:
|
|
|
|
|
break;
|
2016-06-15 12:29:24 +02:00
|
|
|
}
|
2019-08-08 09:57:42 +02:00
|
|
|
QTC_ASSERT(false, qDebug() << "Unexpected run mode" << int(m_runMode)); // unexpected run mode
|
2018-07-11 15:44:51 +02:00
|
|
|
onFinished();
|
2016-06-15 12:29:24 +02:00
|
|
|
}
|
|
|
|
|
|
2019-08-19 14:46:20 +02:00
|
|
|
void TestRunner::buildProject(Project *project)
|
2014-11-04 12:35:00 +01:00
|
|
|
{
|
2019-08-19 14:46:20 +02:00
|
|
|
BuildManager *buildManager = BuildManager::instance();
|
2015-06-29 09:22:58 +02:00
|
|
|
m_buildConnect = connect(this, &TestRunner::requestStopTestRun,
|
2019-08-19 14:46:20 +02:00
|
|
|
buildManager, &BuildManager::cancel);
|
TestRunner: Reuse TaskTree
Get rid of QFutureInterface argument from
ITestConfiguration::createOutputReader() and from
TestOutputReader c'tor.
The fine-grained progress reporting was broken anyway:
1. The assumption was that testCaseCount was meant to be
the total number of test functions executed. It didn't
include the initTestCase() and cleanupTestCase(),
while those were reported on runtime apparently
(and exceeding the max progress by 2).
2. In case of tst_qtcprocess, when the whole test was run,
the testCaseCount reported 41, while the real
number of functions was 26 (+2 = 28 for init/cleanup).
3. While the max progress was set to testCaseCount initially,
the corresponding FutureProgress rendered the progress
always in 0-100 range, what didn't match the reality.
Instead, rely on TaskTree progress, which resolution
is per test as a whole. So, when executing a series
of tests this should scale fine. In addition, the
progress advances fluently according to the expected
run time - with 10 seconds hardcoded.
The original code locations, where progress was bumped,
are left with a TODO comment for any possible future tweaks.
Like in case of result reporting, fine-grained progress
reporting may be implemented by providing additional signal,
so there is no need for QFutureInterface inside
TestOutputReader.
Change-Id: Idc11d55e3a49dac8d1788948b9a82f68199203c6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-17 00:45:50 +01:00
|
|
|
connect(buildManager, &BuildManager::buildQueueFinished, this, &TestRunner::buildFinished);
|
2020-11-18 22:42:51 +01:00
|
|
|
BuildManager::buildProjectWithDependencies(project);
|
|
|
|
|
if (!BuildManager::isBuilding())
|
2016-11-04 09:47:15 +01:00
|
|
|
buildFinished(false);
|
2014-11-04 12:35:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestRunner::buildFinished(bool success)
|
|
|
|
|
{
|
2015-06-29 09:22:58 +02:00
|
|
|
disconnect(m_buildConnect);
|
2019-08-19 14:46:20 +02:00
|
|
|
BuildManager *buildManager = BuildManager::instance();
|
TestRunner: Reuse TaskTree
Get rid of QFutureInterface argument from
ITestConfiguration::createOutputReader() and from
TestOutputReader c'tor.
The fine-grained progress reporting was broken anyway:
1. The assumption was that testCaseCount was meant to be
the total number of test functions executed. It didn't
include the initTestCase() and cleanupTestCase(),
while those were reported on runtime apparently
(and exceeding the max progress by 2).
2. In case of tst_qtcprocess, when the whole test was run,
the testCaseCount reported 41, while the real
number of functions was 26 (+2 = 28 for init/cleanup).
3. While the max progress was set to testCaseCount initially,
the corresponding FutureProgress rendered the progress
always in 0-100 range, what didn't match the reality.
Instead, rely on TaskTree progress, which resolution
is per test as a whole. So, when executing a series
of tests this should scale fine. In addition, the
progress advances fluently according to the expected
run time - with 10 seconds hardcoded.
The original code locations, where progress was bumped,
are left with a TODO comment for any possible future tweaks.
Like in case of result reporting, fine-grained progress
reporting may be implemented by providing additional signal,
so there is no need for QFutureInterface inside
TestOutputReader.
Change-Id: Idc11d55e3a49dac8d1788948b9a82f68199203c6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-17 00:45:50 +01:00
|
|
|
disconnect(buildManager, &BuildManager::buildQueueFinished, this, &TestRunner::buildFinished);
|
2015-06-29 09:22:58 +02:00
|
|
|
|
|
|
|
|
if (success) {
|
TestRunner: Reuse TaskTree
Get rid of QFutureInterface argument from
ITestConfiguration::createOutputReader() and from
TestOutputReader c'tor.
The fine-grained progress reporting was broken anyway:
1. The assumption was that testCaseCount was meant to be
the total number of test functions executed. It didn't
include the initTestCase() and cleanupTestCase(),
while those were reported on runtime apparently
(and exceeding the max progress by 2).
2. In case of tst_qtcprocess, when the whole test was run,
the testCaseCount reported 41, while the real
number of functions was 26 (+2 = 28 for init/cleanup).
3. While the max progress was set to testCaseCount initially,
the corresponding FutureProgress rendered the progress
always in 0-100 range, what didn't match the reality.
Instead, rely on TaskTree progress, which resolution
is per test as a whole. So, when executing a series
of tests this should scale fine. In addition, the
progress advances fluently according to the expected
run time - with 10 seconds hardcoded.
The original code locations, where progress was bumped,
are left with a TODO comment for any possible future tweaks.
Like in case of result reporting, fine-grained progress
reporting may be implemented by providing additional signal,
so there is no need for QFutureInterface inside
TestOutputReader.
Change-Id: Idc11d55e3a49dac8d1788948b9a82f68199203c6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-17 00:45:50 +01:00
|
|
|
runOrDebugTests();
|
|
|
|
|
return;
|
2015-06-29 09:22:58 +02:00
|
|
|
}
|
TestRunner: Reuse TaskTree
Get rid of QFutureInterface argument from
ITestConfiguration::createOutputReader() and from
TestOutputReader c'tor.
The fine-grained progress reporting was broken anyway:
1. The assumption was that testCaseCount was meant to be
the total number of test functions executed. It didn't
include the initTestCase() and cleanupTestCase(),
while those were reported on runtime apparently
(and exceeding the max progress by 2).
2. In case of tst_qtcprocess, when the whole test was run,
the testCaseCount reported 41, while the real
number of functions was 26 (+2 = 28 for init/cleanup).
3. While the max progress was set to testCaseCount initially,
the corresponding FutureProgress rendered the progress
always in 0-100 range, what didn't match the reality.
Instead, rely on TaskTree progress, which resolution
is per test as a whole. So, when executing a series
of tests this should scale fine. In addition, the
progress advances fluently according to the expected
run time - with 10 seconds hardcoded.
The original code locations, where progress was bumped,
are left with a TODO comment for any possible future tweaks.
Like in case of result reporting, fine-grained progress
reporting may be implemented by providing additional signal,
so there is no need for QFutureInterface inside
TestOutputReader.
Change-Id: Idc11d55e3a49dac8d1788948b9a82f68199203c6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-17 00:45:50 +01:00
|
|
|
reportResult(ResultType::MessageFatal, Tr::tr("Build failed. Canceling test run."));
|
|
|
|
|
onFinished();
|
2014-11-04 12:35:00 +01:00
|
|
|
}
|
|
|
|
|
|
2019-09-13 10:50:32 +02:00
|
|
|
static RunAfterBuildMode runAfterBuild()
|
2019-08-08 10:58:15 +02:00
|
|
|
{
|
2023-02-14 15:47:22 +01:00
|
|
|
Project *project = ProjectManager::startupProject();
|
2019-08-08 10:58:15 +02:00
|
|
|
if (!project)
|
2019-09-13 10:50:32 +02:00
|
|
|
return RunAfterBuildMode::None;
|
2019-08-08 10:58:15 +02:00
|
|
|
|
|
|
|
|
if (!project->namedSettings(Constants::SK_USE_GLOBAL).isValid())
|
2023-05-12 11:00:00 +02:00
|
|
|
return TestSettings::instance()->runAfterBuildMode();
|
2019-08-08 10:58:15 +02:00
|
|
|
|
|
|
|
|
TestProjectSettings *projectSettings = AutotestPlugin::projectSettings(project);
|
2023-05-12 11:00:00 +02:00
|
|
|
return projectSettings->useGlobalSettings() ? TestSettings::instance()->runAfterBuildMode()
|
2019-08-08 10:58:15 +02:00
|
|
|
: projectSettings->runAfterBuild();
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-08 09:57:42 +02:00
|
|
|
void TestRunner::onBuildQueueFinished(bool success)
|
|
|
|
|
{
|
TestRunner: Reuse TaskTree
Get rid of QFutureInterface argument from
ITestConfiguration::createOutputReader() and from
TestOutputReader c'tor.
The fine-grained progress reporting was broken anyway:
1. The assumption was that testCaseCount was meant to be
the total number of test functions executed. It didn't
include the initTestCase() and cleanupTestCase(),
while those were reported on runtime apparently
(and exceeding the max progress by 2).
2. In case of tst_qtcprocess, when the whole test was run,
the testCaseCount reported 41, while the real
number of functions was 26 (+2 = 28 for init/cleanup).
3. While the max progress was set to testCaseCount initially,
the corresponding FutureProgress rendered the progress
always in 0-100 range, what didn't match the reality.
Instead, rely on TaskTree progress, which resolution
is per test as a whole. So, when executing a series
of tests this should scale fine. In addition, the
progress advances fluently according to the expected
run time - with 10 seconds hardcoded.
The original code locations, where progress was bumped,
are left with a TODO comment for any possible future tweaks.
Like in case of result reporting, fine-grained progress
reporting may be implemented by providing additional signal,
so there is no need for QFutureInterface inside
TestOutputReader.
Change-Id: Idc11d55e3a49dac8d1788948b9a82f68199203c6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-17 00:45:50 +01:00
|
|
|
if (isTestRunning() || !m_selectedTests.isEmpty()) // paranoia!
|
2019-08-08 09:57:42 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!success || m_runMode != TestRunMode::None)
|
|
|
|
|
return;
|
|
|
|
|
|
2019-09-13 10:50:32 +02:00
|
|
|
RunAfterBuildMode mode = runAfterBuild();
|
|
|
|
|
if (mode == RunAfterBuildMode::None)
|
2019-08-08 09:57:42 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
auto testTreeModel = TestTreeModel::instance();
|
|
|
|
|
if (!testTreeModel->hasTests())
|
|
|
|
|
return;
|
|
|
|
|
|
2023-01-13 12:30:42 +01:00
|
|
|
const QList<ITestConfiguration *> tests = mode == RunAfterBuildMode::All
|
|
|
|
|
? testTreeModel->getAllTestCases() : testTreeModel->getSelectedTests();
|
|
|
|
|
runTests(TestRunMode::RunAfterBuild, tests);
|
2019-08-08 09:57:42 +02:00
|
|
|
}
|
|
|
|
|
|
2014-11-06 10:48:17 +01:00
|
|
|
void TestRunner::onFinished()
|
|
|
|
|
{
|
TestRunner: Reuse TaskTree
Get rid of QFutureInterface argument from
ITestConfiguration::createOutputReader() and from
TestOutputReader c'tor.
The fine-grained progress reporting was broken anyway:
1. The assumption was that testCaseCount was meant to be
the total number of test functions executed. It didn't
include the initTestCase() and cleanupTestCase(),
while those were reported on runtime apparently
(and exceeding the max progress by 2).
2. In case of tst_qtcprocess, when the whole test was run,
the testCaseCount reported 41, while the real
number of functions was 26 (+2 = 28 for init/cleanup).
3. While the max progress was set to testCaseCount initially,
the corresponding FutureProgress rendered the progress
always in 0-100 range, what didn't match the reality.
Instead, rely on TaskTree progress, which resolution
is per test as a whole. So, when executing a series
of tests this should scale fine. In addition, the
progress advances fluently according to the expected
run time - with 10 seconds hardcoded.
The original code locations, where progress was bumped,
are left with a TODO comment for any possible future tweaks.
Like in case of result reporting, fine-grained progress
reporting may be implemented by providing additional signal,
so there is no need for QFutureInterface inside
TestOutputReader.
Change-Id: Idc11d55e3a49dac8d1788948b9a82f68199203c6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-17 00:45:50 +01:00
|
|
|
if (m_taskTree)
|
|
|
|
|
m_taskTree.release()->deleteLater();
|
2018-08-02 15:56:26 +02:00
|
|
|
disconnect(m_stopDebugConnect);
|
2018-06-21 10:36:50 +02:00
|
|
|
disconnect(m_targetConnect);
|
TestRunner: Reuse TaskTree
Get rid of QFutureInterface argument from
ITestConfiguration::createOutputReader() and from
TestOutputReader c'tor.
The fine-grained progress reporting was broken anyway:
1. The assumption was that testCaseCount was meant to be
the total number of test functions executed. It didn't
include the initTestCase() and cleanupTestCase(),
while those were reported on runtime apparently
(and exceeding the max progress by 2).
2. In case of tst_qtcprocess, when the whole test was run,
the testCaseCount reported 41, while the real
number of functions was 26 (+2 = 28 for init/cleanup).
3. While the max progress was set to testCaseCount initially,
the corresponding FutureProgress rendered the progress
always in 0-100 range, what didn't match the reality.
Instead, rely on TaskTree progress, which resolution
is per test as a whole. So, when executing a series
of tests this should scale fine. In addition, the
progress advances fluently according to the expected
run time - with 10 seconds hardcoded.
The original code locations, where progress was bumped,
are left with a TODO comment for any possible future tweaks.
Like in case of result reporting, fine-grained progress
reporting may be implemented by providing additional signal,
so there is no need for QFutureInterface inside
TestOutputReader.
Change-Id: Idc11d55e3a49dac8d1788948b9a82f68199203c6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-17 00:45:50 +01:00
|
|
|
qDeleteAll(m_selectedTests);
|
|
|
|
|
m_selectedTests.clear();
|
|
|
|
|
m_cancelTimer.stop();
|
2019-08-08 09:57:42 +02:00
|
|
|
m_runMode = TestRunMode::None;
|
2014-11-06 10:48:17 +01:00
|
|
|
emit testRunFinished();
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-06 14:11:19 +01:00
|
|
|
void TestRunner::reportResult(ResultType type, const QString &description)
|
|
|
|
|
{
|
2023-02-15 16:25:16 +01:00
|
|
|
TestResult result({}, {});
|
2023-01-14 16:25:51 +01:00
|
|
|
result.setResult(type);
|
|
|
|
|
result.setDescription(description);
|
2019-02-06 14:11:19 +01:00
|
|
|
emit testResultReady(result);
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-13 14:27:20 +02:00
|
|
|
/*************************************************************************************************/
|
|
|
|
|
|
2018-08-08 12:34:19 +02:00
|
|
|
RunConfigurationSelectionDialog::RunConfigurationSelectionDialog(const QString &buildTargetKey,
|
2017-09-13 14:27:20 +02:00
|
|
|
QWidget *parent)
|
|
|
|
|
: QDialog(parent)
|
|
|
|
|
{
|
2022-07-13 18:31:56 +02:00
|
|
|
setWindowTitle(Tr::tr("Select Run Configuration"));
|
2017-09-13 14:27:20 +02:00
|
|
|
|
2022-07-13 18:31:56 +02:00
|
|
|
QString details = Tr::tr("Could not determine which run configuration to choose for running tests");
|
2018-08-08 12:34:19 +02:00
|
|
|
if (!buildTargetKey.isEmpty())
|
|
|
|
|
details.append(QString(" (%1)").arg(buildTargetKey));
|
2017-11-09 10:06:53 +01:00
|
|
|
m_details = new QLabel(details, this);
|
2017-09-13 14:27:20 +02:00
|
|
|
m_rcCombo = new QComboBox(this);
|
2022-07-13 18:31:56 +02:00
|
|
|
m_rememberCB = new QCheckBox(Tr::tr("Remember choice. Cached choices can be reset by switching "
|
|
|
|
|
"projects or using the option to clear the cache."), this);
|
2017-09-13 14:27:20 +02:00
|
|
|
m_executable = new QLabel(this);
|
|
|
|
|
m_arguments = new QLabel(this);
|
|
|
|
|
m_workingDir = new QLabel(this);
|
|
|
|
|
m_buttonBox = new QDialogButtonBox(this);
|
|
|
|
|
m_buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
|
|
|
|
|
m_buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
|
|
|
|
|
|
|
|
|
|
auto formLayout = new QFormLayout;
|
|
|
|
|
formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
|
|
|
|
|
formLayout->addRow(m_details);
|
2022-07-13 18:31:56 +02:00
|
|
|
formLayout->addRow(Tr::tr("Run Configuration:"), m_rcCombo);
|
2018-08-08 12:40:03 +02:00
|
|
|
formLayout->addRow(m_rememberCB);
|
2022-08-26 23:18:00 +02:00
|
|
|
formLayout->addRow(Layouting::createHr(this));
|
2022-07-13 18:31:56 +02:00
|
|
|
formLayout->addRow(Tr::tr("Executable:"), m_executable);
|
|
|
|
|
formLayout->addRow(Tr::tr("Arguments:"), m_arguments);
|
|
|
|
|
formLayout->addRow(Tr::tr("Working Directory:"), m_workingDir);
|
2017-09-13 14:27:20 +02:00
|
|
|
// TODO Device support
|
|
|
|
|
auto vboxLayout = new QVBoxLayout(this);
|
|
|
|
|
vboxLayout->addLayout(formLayout);
|
|
|
|
|
vboxLayout->addStretch();
|
2022-08-26 23:18:00 +02:00
|
|
|
vboxLayout->addWidget(Layouting::createHr(this));
|
2017-09-13 14:27:20 +02:00
|
|
|
vboxLayout->addWidget(m_buttonBox);
|
|
|
|
|
|
|
|
|
|
connect(m_rcCombo, &QComboBox::currentTextChanged,
|
|
|
|
|
this, &RunConfigurationSelectionDialog::updateLabels);
|
|
|
|
|
connect(m_buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
|
|
|
|
connect(m_buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
|
|
|
|
|
|
|
|
|
populate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString RunConfigurationSelectionDialog::displayName() const
|
|
|
|
|
{
|
|
|
|
|
return m_rcCombo ? m_rcCombo->currentText() : QString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString RunConfigurationSelectionDialog::executable() const
|
|
|
|
|
{
|
|
|
|
|
return m_executable ? m_executable->text() : QString();
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-08 12:40:03 +02:00
|
|
|
bool RunConfigurationSelectionDialog::rememberChoice() const
|
|
|
|
|
{
|
|
|
|
|
return m_rememberCB ? m_rememberCB->isChecked() : false;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-13 14:27:20 +02:00
|
|
|
void RunConfigurationSelectionDialog::populate()
|
|
|
|
|
{
|
2023-01-13 12:58:08 +01:00
|
|
|
m_rcCombo->addItem({}, QStringList{{}, {}, {}}); // empty default
|
2017-09-13 14:27:20 +02:00
|
|
|
|
2023-02-14 15:47:22 +01:00
|
|
|
if (auto project = ProjectManager::startupProject()) {
|
2017-09-13 14:27:20 +02:00
|
|
|
if (auto target = project->activeTarget()) {
|
2019-08-19 14:46:20 +02:00
|
|
|
for (RunConfiguration *rc : target->runConfigurations()) {
|
2018-05-16 15:42:03 +02:00
|
|
|
auto runnable = rc->runnable();
|
2021-08-10 09:19:30 +02:00
|
|
|
const QStringList rcDetails = { runnable.command.executable().toString(),
|
|
|
|
|
runnable.command.arguments(),
|
2021-08-02 18:02:10 +02:00
|
|
|
runnable.workingDirectory.toString() };
|
2018-05-16 15:42:03 +02:00
|
|
|
m_rcCombo->addItem(rc->displayName(), rcDetails);
|
2017-09-13 14:27:20 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunConfigurationSelectionDialog::updateLabels()
|
|
|
|
|
{
|
|
|
|
|
int i = m_rcCombo->currentIndex();
|
|
|
|
|
const QStringList values = m_rcCombo->itemData(i).toStringList();
|
|
|
|
|
QTC_ASSERT(values.size() == 3, return);
|
|
|
|
|
m_executable->setText(values.at(0));
|
|
|
|
|
m_arguments->setText(values.at(1));
|
|
|
|
|
m_workingDir->setText(values.at(2));
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-07 15:51:02 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Autotest
|