AutoTest: Allow colored commandline output

Some test frameworks allow to print their output colorful
to further indicate meanings of messages or test results.
Provide a highlighter for the textual output of the results
and enable this functionality for GTest and Boost UTF.
Keep at least a small backdoor for overwriting this by
the user.

Fixes: QTCREATORBUG-22297
Change-Id: Iddd2b734416de807635d90c6519553081f7372f2
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2019-11-06 14:26:40 +01:00
parent e58f376068
commit 333b8f9812
15 changed files with 269 additions and 8 deletions

View File

@@ -57,7 +57,7 @@ static QStringList interfering(InterferingType type)
{
const QStringList knownInterfering { "log_level", "log_format", "log_sink",
"report_level", "report_format", "report_sink",
"output_format", "color_output", "no_color_output",
"output_format",
"catch_system_errors", "no_catch_system_errors",
"detect_fp_exceptions", "no_detect_fp_exceptions",
"detect_memory_leaks", "random", "run_test",
@@ -117,7 +117,6 @@ QStringList BoostTestConfiguration::argumentsForTestRunner(QStringList *omitted)
QStringList arguments;
arguments << "-l" << BoostTestSettings::logLevelToOption(boostSettings->logLevel);
arguments << "-r" << BoostTestSettings::reportLevelToOption(boostSettings->reportLevel);
arguments << "--no_color_output"; // ensure that colored output is not used as default
if (boostSettings->randomize)
arguments << QString("--random=").append(QString::number(boostSettings->seed));
@@ -145,6 +144,8 @@ Utils::Environment BoostTestConfiguration::filteredEnvironment(const Utils::Envi
const QStringList interferingEnv = interfering(InterferingType::EnvironmentVariables);
Utils::Environment result = original;
if (!result.hasKey("BOOST_TEST_COLOR_OUTPUT"))
result.set("BOOST_TEST_COLOR_OUTPUT", "1"); // use colored output by default
for (const QString &key : interferingEnv)
result.unset(key);
return result;