AutoTest: Allow handling of maximum warnings for QtTest

If the maximum number of warnings is reached the test will be
canceled automatically. Allow to handle this from the user side
in case it might be needed.

Fixes: QTCREATORBUG-26637
Change-Id: I239eca280cdc2ce46f6d64cd53b8f3ad0205f7f2
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2020-11-27 09:47:57 +01:00
parent 1cc50c8dcc
commit 3989245562
6 changed files with 32 additions and 2 deletions

View File

@@ -470,6 +470,11 @@
To record information about signals and slots in the test log, select the To record information about signals and slots in the test log, select the
\uicontrol {Log signals and slots} check box. \uicontrol {Log signals and slots} check box.
To explicitly limit the maximum number of warnings in the test log, select
the \uicontrol {Limit warnings} check box and specify the intended number
inside the spin box next to it. Set the number to 0 if you want no limit
at all. The default number is 2000.
\section2 Specifying Settings for Running Google Tests \section2 Specifying Settings for Running Google Tests
To specify settings for running Google tests, select \uicontrol Tools > To specify settings for running Google tests, select \uicontrol Tools >

View File

@@ -98,9 +98,9 @@ QStringList filterInterfering(const QStringList &provided, QStringList *omitted,
"-functions", "-datatags", "-nocrashhandler", "-callgrind", "-perf", "-perfcounterlist", "-functions", "-datatags", "-nocrashhandler", "-callgrind", "-perf", "-perfcounterlist",
"-tickcounter", "-eventcounter", "-help" "-tickcounter", "-eventcounter", "-help"
}; };
static const QSet<QString> knownInterferingOptionWithParameter = { "-o" }; static const QSet<QString> knownInterferingOptionWithParameter = { "-o", "-maxwarnings" };
static const QSet<QString> knownAllowedOptionsWithParameter { static const QSet<QString> knownAllowedOptionsWithParameter {
"-eventdelay", "-keydelay", "-mousedelay", "-maxwarnings", "-perfcounter", "-eventdelay", "-keydelay", "-mousedelay", "-perfcounter",
"-minimumvalue", "-minimumtotal", "-iterations", "-median" "-minimumvalue", "-minimumtotal", "-iterations", "-median"
}; };

View File

@@ -76,6 +76,9 @@ QStringList QtTestConfiguration::argumentsForTestRunner(QStringList *omitted) co
if (isDebugRunMode() && qtSettings->noCrashHandler.value()) if (isDebugRunMode() && qtSettings->noCrashHandler.value())
arguments << "-nocrashhandler"; arguments << "-nocrashhandler";
if (qtSettings->limitWarnings.value() && qtSettings->maxWarnings.value() != 2000)
arguments << "-maxwarnings" << QString::number(qtSettings->maxWarnings.value());
return arguments; return arguments;
} }

View File

@@ -79,6 +79,19 @@ QtTestSettings::QtTestSettings()
logSignalsSlots.setSettingsKey("LogSignalsSlots"); logSignalsSlots.setSettingsKey("LogSignalsSlots");
logSignalsSlots.setLabelText(tr("Log signals and slots")); logSignalsSlots.setLabelText(tr("Log signals and slots"));
logSignalsSlots.setToolTip(tr("Log every signal emission and resulting slot invocations.")); logSignalsSlots.setToolTip(tr("Log every signal emission and resulting slot invocations."));
registerAspect(&limitWarnings);
limitWarnings.setSettingsKey("LimitWarnings");
limitWarnings.setLabelText(tr("Limit warnings"));
limitWarnings.setToolTip(tr("Set the maximum number of warnings. 0 means that the number "
"is not limited."));
registerAspect(&maxWarnings);
maxWarnings.setSettingsKey("MaxWarnings");
maxWarnings.setRange(0, 10000);
maxWarnings.setDefaultValue(2000);
maxWarnings.setSpecialValueText(tr("Unlimited"));
maxWarnings.setEnabler(&limitWarnings);
} }
QString QtTestSettings::metricsTypeToOption(const MetricsType type) QString QtTestSettings::metricsTypeToOption(const MetricsType type)
@@ -115,6 +128,9 @@ QtTestSettingsPage::QtTestSettingsPage(QtTestSettings *settings, Id settingsId)
s.useXMLOutput, s.useXMLOutput,
s.verboseBench, s.verboseBench,
s.logSignalsSlots, s.logSignalsSlots,
Row {
s.limitWarnings, s.maxWarnings
},
Group { Group {
Title(QtTestSettings::tr("Benchmark Metrics")), Title(QtTestSettings::tr("Benchmark Metrics")),
s.metrics s.metrics

View File

@@ -54,6 +54,8 @@ public:
Utils::BoolAspect useXMLOutput; Utils::BoolAspect useXMLOutput;
Utils::BoolAspect verboseBench; Utils::BoolAspect verboseBench;
Utils::BoolAspect logSignalsSlots; Utils::BoolAspect logSignalsSlots;
Utils::BoolAspect limitWarnings;
Utils::IntegerAspect maxWarnings;
}; };
class QtTestSettingsPage final : public Core::IOptionsPage class QtTestSettingsPage final : public Core::IOptionsPage

View File

@@ -79,6 +79,10 @@ QStringList QuickTestConfiguration::argumentsForTestRunner(QStringList *omitted)
if (qtSettings->noCrashHandler.value()) if (qtSettings->noCrashHandler.value())
arguments << "-nocrashhandler"; arguments << "-nocrashhandler";
} }
if (qtSettings->limitWarnings.value() && qtSettings->maxWarnings.value() != 2000)
arguments << "-maxwarnings" << QString::number(qtSettings->maxWarnings.value());
return arguments; return arguments;
} }