From e9f39c40d98213877317a42d30b78cba102e2017 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Fri, 14 Dec 2018 10:58:18 +0100 Subject: winrtrunner: Do not accept fully wildcarded logging rules from environment When an auto test fails in CI, it does another run using QT_LOGGING_RULES=*=true. For winrt builds this rule would enable extended logging for winrtrunner and the output would be flooded with winrtrunner specific information. Instead of confusing the users, we disregard the logging rules in winrtrunner if they do not specifically enable the application's logging so that CI runs will only show information that might be interesting to the user. Change-Id: If51a666315a2e33b83d6a7613a65ab4a152eddc4 Reviewed-by: Andre de la Rocha Reviewed-by: Joerg Bornemann --- src/winrtrunner/main.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/winrtrunner/main.cpp b/src/winrtrunner/main.cpp index 72dd763c8..bf4e8fabf 100644 --- a/src/winrtrunner/main.cpp +++ b/src/winrtrunner/main.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -52,6 +53,23 @@ QT_USE_NAMESPACE int main(int argc, char *argv[]) { + // If logging rules are set via env variable, we pass these to the application we are running. + // winrtrunner behaves different from other applications in the regard that its logging rules + // have to be enabled explicitly. Setting "*=true" will not enable extended logging. Reason is + // CI setting "*=true" if an auto test fails and additional winrtrunner output might just + // confuse users. + const QByteArray loggingRules = qgetenv("QT_LOGGING_RULES"); + const QList rules = loggingRules.split(';'); + QRegExp runnerExp(QLatin1String("^qt\\.winrtrunner.*\\s*=\\s*true\\s*$")); + bool runnerRuleFound = false; + for (const QByteArray &rule : rules) { + if (runnerExp.indexIn(QLatin1String(rule)) != -1) { + runnerRuleFound = true; + break; + } + } + if (!runnerRuleFound) + qunsetenv("QT_LOGGING_RULES"); QCoreApplication a(argc, argv); QCommandLineParser parser; parser.setApplicationDescription(QLatin1String("winrtrunner installs, runs, and collects test " @@ -282,8 +300,6 @@ int main(int argc, char *argv[]) return ignoreErrors ? 0 : 3; } - // If logging rules are set via env variable, we pass these to the application we are running - const QByteArray loggingRules = qgetenv("QT_LOGGING_RULES"); if (!loggingRules.isNull() && !runner.setLoggingRules(loggingRules)) { qCDebug(lcWinRtRunner) << "Could not set logging rules, exiting with code 3."; return ignoreErrors ? 0 : 3; -- cgit v1.2.3