2018-12-07 10:00:23 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** Copyright (C) 2019 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
|
|
|
|
**
|
|
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "boosttestconfiguration.h"
|
|
|
|
|
#include "boosttestconstants.h"
|
|
|
|
|
#include "boosttestoutputreader.h"
|
|
|
|
|
#include "boosttestsettings.h"
|
|
|
|
|
|
|
|
|
|
#include "../autotestplugin.h"
|
2020-03-26 10:11:39 +01:00
|
|
|
#include "../itestframework.h"
|
2018-12-07 10:00:23 +01:00
|
|
|
#include "../testsettings.h"
|
|
|
|
|
|
2020-06-17 06:35:31 +02:00
|
|
|
#include <utils/stringutils.h>
|
|
|
|
|
|
2018-12-07 10:00:23 +01:00
|
|
|
namespace Autotest {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
TestOutputReader *BoostTestConfiguration::outputReader(const QFutureInterface<TestResultPtr> &fi,
|
|
|
|
|
QProcess *app) const
|
|
|
|
|
{
|
2021-03-24 12:40:03 +01:00
|
|
|
auto settings = static_cast<BoostTestSettings *>(framework()->testSettings());
|
2018-12-07 10:00:23 +01:00
|
|
|
return new BoostTestOutputReader(fi, app, buildDirectory(), projectFile(),
|
2021-03-24 12:40:03 +01:00
|
|
|
LogLevel(settings->logLevel.value()),
|
|
|
|
|
ReportLevel(settings->reportLevel.value()));
|
2018-12-07 10:00:23 +01:00
|
|
|
}
|
|
|
|
|
|
2019-05-22 13:55:31 +02:00
|
|
|
enum class InterferingType { Options, EnvironmentVariables };
|
|
|
|
|
|
|
|
|
|
static QStringList interfering(InterferingType type)
|
2018-12-07 10:00:23 +01:00
|
|
|
{
|
2019-05-22 13:55:31 +02:00
|
|
|
const QStringList knownInterfering { "log_level", "log_format", "log_sink",
|
|
|
|
|
"report_level", "report_format", "report_sink",
|
2019-11-06 14:26:40 +01:00
|
|
|
"output_format",
|
2019-05-22 13:55:31 +02:00
|
|
|
"catch_system_errors", "no_catch_system_errors",
|
|
|
|
|
"detect_fp_exceptions", "no_detect_fp_exceptions",
|
|
|
|
|
"detect_memory_leaks", "random", "run_test",
|
|
|
|
|
"show_progress", "result_code", "no_result_code",
|
|
|
|
|
"help", "list_content", "list_labels", "version"
|
2018-12-07 10:00:23 +01:00
|
|
|
};
|
2019-05-22 13:55:31 +02:00
|
|
|
switch (type) {
|
|
|
|
|
case InterferingType::Options:
|
|
|
|
|
return Utils::transform(knownInterfering, [](const QString &item) {
|
|
|
|
|
return QString("--" + item);
|
|
|
|
|
});
|
|
|
|
|
case InterferingType::EnvironmentVariables:
|
|
|
|
|
return Utils::transform(knownInterfering, [](const QString &item) {
|
|
|
|
|
return QString("BOOST_TEST_" + item).toUpper();
|
2018-12-07 10:00:23 +01:00
|
|
|
});
|
|
|
|
|
}
|
2019-05-22 13:55:31 +02:00
|
|
|
return QStringList();
|
2018-12-07 10:00:23 +01:00
|
|
|
}
|
|
|
|
|
|
2019-05-22 13:55:31 +02:00
|
|
|
static QStringList filterInterfering(const QStringList &provided, QStringList *omitted)
|
2018-12-07 10:00:23 +01:00
|
|
|
{
|
2019-05-22 13:55:31 +02:00
|
|
|
const QStringList knownInterfering = interfering(InterferingType::Options);
|
|
|
|
|
const QString interferingSingleWithParam = "efklortcpsx?";
|
|
|
|
|
QStringList allowed;
|
|
|
|
|
bool filterNextArg = false;
|
|
|
|
|
bool ignoreRest = false;
|
2020-06-11 16:53:11 +02:00
|
|
|
for (const auto &arg : provided) {
|
2019-05-22 13:55:31 +02:00
|
|
|
bool filterArg = filterNextArg;
|
|
|
|
|
filterNextArg = false;
|
|
|
|
|
if (ignoreRest) {
|
|
|
|
|
allowed.append(arg);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
bool interferes = false;
|
|
|
|
|
if (filterArg && !arg.startsWith('-')) {
|
|
|
|
|
interferes = true;
|
|
|
|
|
} else if (arg.startsWith("--")) {
|
|
|
|
|
if (arg.size() == 2)
|
|
|
|
|
ignoreRest = true;
|
|
|
|
|
else
|
|
|
|
|
interferes = knownInterfering.contains(arg.left(arg.indexOf('=')));
|
|
|
|
|
} else if (arg.startsWith('-') && arg.size() > 1) {
|
|
|
|
|
interferes = interferingSingleWithParam.contains(arg.at(1));
|
|
|
|
|
filterNextArg = interferes;
|
|
|
|
|
}
|
|
|
|
|
if (!interferes)
|
|
|
|
|
allowed.append(arg);
|
|
|
|
|
else if (omitted)
|
|
|
|
|
omitted->append(arg);
|
2018-12-07 10:00:23 +01:00
|
|
|
}
|
2019-05-22 13:55:31 +02:00
|
|
|
return allowed;
|
|
|
|
|
}
|
2018-12-07 10:00:23 +01:00
|
|
|
|
2019-05-22 13:55:31 +02:00
|
|
|
QStringList BoostTestConfiguration::argumentsForTestRunner(QStringList *omitted) const
|
|
|
|
|
{
|
2021-03-24 12:40:03 +01:00
|
|
|
auto boostSettings = static_cast<BoostTestSettings *>(framework()->testSettings());
|
2019-05-22 13:55:31 +02:00
|
|
|
QStringList arguments;
|
2021-03-24 12:40:03 +01:00
|
|
|
arguments << "-l" << BoostTestSettings::logLevelToOption(LogLevel(boostSettings->logLevel.value()));
|
|
|
|
|
arguments << "-r" << BoostTestSettings::reportLevelToOption(ReportLevel(boostSettings->reportLevel.value()));
|
2018-12-07 10:00:23 +01:00
|
|
|
|
2021-03-24 12:40:03 +01:00
|
|
|
if (boostSettings->randomize.value())
|
|
|
|
|
arguments << QString("--random=").append(QString::number(boostSettings->seed.value()));
|
2018-12-07 10:00:23 +01:00
|
|
|
|
2021-03-24 12:40:03 +01:00
|
|
|
if (boostSettings->systemErrors.value())
|
2018-12-07 10:00:23 +01:00
|
|
|
arguments << "-s";
|
2021-03-24 12:40:03 +01:00
|
|
|
if (boostSettings->fpExceptions.value())
|
2018-12-07 10:00:23 +01:00
|
|
|
arguments << "--detect_fp_exceptions";
|
2021-03-24 12:40:03 +01:00
|
|
|
if (!boostSettings->memLeaks.value())
|
2018-12-07 10:00:23 +01:00
|
|
|
arguments << "--detect_memory_leaks=0";
|
2019-05-22 13:55:31 +02:00
|
|
|
|
|
|
|
|
// TODO improve the test case gathering and arguments building to avoid too long command lines
|
|
|
|
|
for (const QString &test : testCases())
|
|
|
|
|
arguments << "-t" << test;
|
|
|
|
|
|
|
|
|
|
if (AutotestPlugin::settings()->processArgs) {
|
2021-08-10 09:19:30 +02:00
|
|
|
arguments << filterInterfering(runnable().command.arguments().split(
|
2020-07-21 10:19:36 +02:00
|
|
|
' ', Qt::SkipEmptyParts), omitted);
|
2019-05-22 13:55:31 +02:00
|
|
|
}
|
2018-12-07 10:00:23 +01:00
|
|
|
return arguments;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Utils::Environment BoostTestConfiguration::filteredEnvironment(const Utils::Environment &original) const
|
|
|
|
|
{
|
2019-05-22 13:55:31 +02:00
|
|
|
const QStringList interferingEnv = interfering(InterferingType::EnvironmentVariables);
|
2018-12-07 10:00:23 +01:00
|
|
|
|
|
|
|
|
Utils::Environment result = original;
|
2019-11-06 14:26:40 +01:00
|
|
|
if (!result.hasKey("BOOST_TEST_COLOR_OUTPUT"))
|
|
|
|
|
result.set("BOOST_TEST_COLOR_OUTPUT", "1"); // use colored output by default
|
2019-05-22 13:55:31 +02:00
|
|
|
for (const QString &key : interferingEnv)
|
2018-12-07 10:00:23 +01:00
|
|
|
result.unset(key);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Autotest
|