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

@@ -93,6 +93,26 @@ void TestOutputReader::createAndReportResult(const QString &message, ResultType
reportResult(result);
}
void TestOutputReader::resetCommandlineColor()
{
emit newOutputLineAvailable("\u001B[m", OutputChannel::StdOut);
emit newOutputLineAvailable("\u001B[m", OutputChannel::StdErr);
}
QString TestOutputReader::removeCommandlineColors(const QString &original)
{
static const QRegularExpression pattern("\u001B\\[.*?m");
QString result = original;
while (!result.isEmpty()) {
QRegularExpressionMatch match = pattern.match(result);
if (match.hasMatch())
result.remove(match.capturedStart(), match.captured().length());
else
break;
}
return result;
}
void TestOutputReader::reportResult(const TestResultPtr &result)
{
m_futureInterface.reportResult(result);