From df830ccf08c3dbf78af3c9b2042a9c5bcce24757 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Fri, 17 Apr 2020 12:22:14 +0200 Subject: [PATCH] AutoTest: Filter interfering arguments for Catch tests Some of the possible options usable with a Catch test executable may interfere with what is expected on the AutoTest plugin side. Other options will be provided by settings that will be added in a follow-up. Change-Id: I9613c28c2e0fac8af27c5e8293921933bd570337 Reviewed-by: David Schulz --- .../autotest/catch/catchconfiguration.cpp | 65 +++++++++++++++++-- 1 file changed, 61 insertions(+), 4 deletions(-) diff --git a/src/plugins/autotest/catch/catchconfiguration.cpp b/src/plugins/autotest/catch/catchconfiguration.cpp index 4033f9a4bb7..ae112b73e93 100644 --- a/src/plugins/autotest/catch/catchconfiguration.cpp +++ b/src/plugins/autotest/catch/catchconfiguration.cpp @@ -25,6 +25,9 @@ #include "catchconfiguration.h" #include "catchoutputreader.h" +#include "../autotestplugin.h" +#include "../testsettings.h" + namespace Autotest { namespace Internal { @@ -33,15 +36,69 @@ TestOutputReader *CatchConfiguration::outputReader(const QFutureInterface singleOptions { "-l", "--list-tests", + "--list-test-names-only", + "-t", "--list-tags", + "--list-reporters", + "-s", "--success", + "-b", "--break", + "-e", "--nothrow", + "-a", "--abort", + "-#", "--filenames-as-tags", + "--benchmark-no-analysis", + "--help" + }; + static const QSet paramOptions { "-o", "--out", + "-r", "--reporter", + "-x", "--abortx", + "-w", "--warn", + "-d", "--durations", + "-f", "--input-file", + "-c", "--section", + "--wait-for-keypress", + "--benchmark-samples", + "--benchmark-resamples", + "--benchmark-confidence-interval", + "--benchmark-warmup-time", + "--use-color" + }; + + QStringList allowed; + bool filterNext = false; + for (auto arg : provided) { + bool interferes = false; + if (filterNext) { + omitted->append(arg); + filterNext = false; + continue; + } + if (singleOptions.contains(arg)) { + interferes = true; + } else if (paramOptions.contains(arg)) { + interferes = true; + filterNext = true; + } + if (!interferes) + allowed.append(arg); + else if (omitted) + omitted->append(arg); + } + return allowed; +} + QStringList CatchConfiguration::argumentsForTestRunner(QStringList *omitted) const { - Q_UNUSED(omitted) - QStringList arguments; - arguments << "--reporter" << "xml"; - if (testCaseCount()) arguments << "\"" + testCases().join("\",\"") + "\""; + arguments << "--reporter" << "xml"; + + if (AutotestPlugin::settings()->processArgs) { + arguments << filterInterfering(runnable().commandLineArguments.split( + ' ', QString::SkipEmptyParts), omitted); + } return arguments; }