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-05-11 13:02:42 +02:00
|
|
|
|
|
|
|
|
#include "qttestconfiguration.h"
|
2016-10-05 12:39:23 +02:00
|
|
|
#include "qttestconstants.h"
|
2016-05-11 13:02:42 +02:00
|
|
|
#include "qttestoutputreader.h"
|
2016-10-05 12:39:23 +02:00
|
|
|
#include "qttestsettings.h"
|
2017-09-01 14:59:39 +02:00
|
|
|
#include "qttest_utils.h"
|
|
|
|
|
#include "../autotestplugin.h"
|
2020-03-26 10:11:39 +01:00
|
|
|
#include "../itestframework.h"
|
2017-09-01 14:59:39 +02:00
|
|
|
#include "../testsettings.h"
|
2016-05-11 13:02:42 +02:00
|
|
|
|
2023-01-13 07:35:56 +01:00
|
|
|
#include <utils/algorithm.h>
|
2020-06-17 06:35:31 +02:00
|
|
|
#include <utils/stringutils.h>
|
|
|
|
|
|
2016-05-11 13:02:42 +02:00
|
|
|
namespace Autotest {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2023-01-13 07:35:56 +01:00
|
|
|
static QStringList quoteIfNeeded(const QStringList &testCases, bool debugMode)
|
|
|
|
|
{
|
|
|
|
|
if (debugMode)
|
|
|
|
|
return testCases;
|
|
|
|
|
|
|
|
|
|
return Utils::transform(testCases, [](const QString &testCase){
|
|
|
|
|
return testCase.contains(' ') ? '"' + testCase + '"' : testCase;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-14 16:25:51 +01:00
|
|
|
TestOutputReader *QtTestConfiguration::createOutputReader(const QFutureInterface<TestResult> &fi,
|
2023-01-13 12:13:45 +01:00
|
|
|
Utils::QtcProcess *app) const
|
2016-05-11 13:02:42 +02:00
|
|
|
{
|
2021-03-24 12:40:03 +01:00
|
|
|
auto qtSettings = static_cast<QtTestSettings *>(framework()->testSettings());
|
|
|
|
|
const QtTestOutputReader::OutputMode mode = qtSettings && qtSettings->useXMLOutput.value()
|
2018-05-15 07:28:25 +02:00
|
|
|
? QtTestOutputReader::XML
|
|
|
|
|
: QtTestOutputReader::PlainText;
|
|
|
|
|
return new QtTestOutputReader(fi, app, buildDirectory(), projectFile(), mode, TestType::QtTest);
|
2016-05-11 13:02:42 +02:00
|
|
|
}
|
|
|
|
|
|
2017-09-01 14:59:39 +02:00
|
|
|
QStringList QtTestConfiguration::argumentsForTestRunner(QStringList *omitted) const
|
2016-05-11 13:02:42 +02:00
|
|
|
{
|
2017-06-19 15:58:21 +02:00
|
|
|
QStringList arguments;
|
2018-02-01 09:17:56 +01:00
|
|
|
if (AutotestPlugin::settings()->processArgs) {
|
2017-09-01 14:59:39 +02:00
|
|
|
arguments.append(QTestUtils::filterInterfering(
|
2021-08-10 09:19:30 +02:00
|
|
|
runnable().command.arguments().split(' ', Qt::SkipEmptyParts),
|
2017-09-01 14:59:39 +02:00
|
|
|
omitted, false));
|
|
|
|
|
}
|
2021-03-24 12:40:03 +01:00
|
|
|
auto qtSettings = static_cast<QtTestSettings *>(framework()->testSettings());
|
2020-03-12 13:58:09 +01:00
|
|
|
if (!qtSettings)
|
2016-10-05 12:39:23 +02:00
|
|
|
return arguments;
|
2021-03-24 12:40:03 +01:00
|
|
|
if (qtSettings->useXMLOutput.value())
|
2017-06-19 15:58:21 +02:00
|
|
|
arguments << "-xml";
|
2020-01-15 19:10:34 +01:00
|
|
|
if (!testCases().isEmpty())
|
2023-01-13 07:35:56 +01:00
|
|
|
arguments << quoteIfNeeded(testCases(), isDebugRunMode());
|
2016-10-05 12:39:23 +02:00
|
|
|
|
2021-03-24 12:40:03 +01:00
|
|
|
const QString &metricsOption = QtTestSettings::metricsTypeToOption(MetricsType(qtSettings->metrics.value()));
|
2016-05-11 13:02:42 +02:00
|
|
|
if (!metricsOption.isEmpty())
|
|
|
|
|
arguments << metricsOption;
|
2016-08-12 09:06:52 +02:00
|
|
|
|
2021-03-24 12:40:03 +01:00
|
|
|
if (qtSettings->verboseBench.value())
|
2017-07-03 09:08:49 +02:00
|
|
|
arguments << "-vb";
|
|
|
|
|
|
2021-03-24 12:40:03 +01:00
|
|
|
if (qtSettings->logSignalsSlots.value())
|
2017-07-03 09:08:49 +02:00
|
|
|
arguments << "-vs";
|
|
|
|
|
|
2021-03-24 12:40:03 +01:00
|
|
|
if (isDebugRunMode() && qtSettings->noCrashHandler.value())
|
2017-09-29 15:01:32 +02:00
|
|
|
arguments << "-nocrashhandler";
|
2016-08-12 09:06:52 +02:00
|
|
|
|
2020-11-27 09:47:57 +01:00
|
|
|
if (qtSettings->limitWarnings.value() && qtSettings->maxWarnings.value() != 2000)
|
|
|
|
|
arguments << "-maxwarnings" << QString::number(qtSettings->maxWarnings.value());
|
|
|
|
|
|
2016-05-11 13:02:42 +02:00
|
|
|
return arguments;
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-29 12:33:15 +02:00
|
|
|
Utils::Environment QtTestConfiguration::filteredEnvironment(const Utils::Environment &original) const
|
|
|
|
|
{
|
|
|
|
|
return QTestUtils::prepareBasicEnvironment(original);
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-11 13:02:42 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Autotest
|