forked from qt-creator/qt-creator
AutoTest: Handle gtest internal logging
One may use gtest internal logging inside the tests. Handle its output correctly if needed. Fixes: QTCREATORBUG-23354 Change-Id: If7b56b7eddf266600dcd815a145cf3b29f8581b3 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -73,6 +73,8 @@ void GTestOutputReader::processOutputLine(const QByteArray &outputLine)
|
|||||||
static const QRegularExpression errorLocation("^(.*)\\((\\d+)\\): error:.*$");
|
static const QRegularExpression errorLocation("^(.*)\\((\\d+)\\): error:.*$");
|
||||||
static const QRegularExpression iterations("^Repeating all tests "
|
static const QRegularExpression iterations("^Repeating all tests "
|
||||||
"\\(iteration (\\d+)\\) \\. \\. \\.$");
|
"\\(iteration (\\d+)\\) \\. \\. \\.$");
|
||||||
|
static const QRegularExpression logging("^\\[( FATAL | ERROR |WARNING| INFO )\\] "
|
||||||
|
"(.*):(\\d+):: (.*)$");
|
||||||
|
|
||||||
const QString line = removeCommandlineColors(QString::fromLatin1(outputLine));
|
const QString line = removeCommandlineColors(QString::fromLatin1(outputLine));
|
||||||
if (line.trimmed().isEmpty())
|
if (line.trimmed().isEmpty())
|
||||||
@@ -177,9 +179,33 @@ void GTestOutputReader::processOutputLine(const QByteArray &outputLine)
|
|||||||
testResult->setDescription(tr("Execution took %1.").arg(match.captured(2)));
|
testResult->setDescription(tr("Execution took %1.").arg(match.captured(2)));
|
||||||
reportResult(testResult);
|
reportResult(testResult);
|
||||||
m_futureInterface.setProgressValue(m_futureInterface.progressValue() + 1);
|
m_futureInterface.setProgressValue(m_futureInterface.progressValue() + 1);
|
||||||
|
} else if (ExactMatch match = logging.match(line)) {
|
||||||
|
const QString severity = match.captured(1).trimmed();
|
||||||
|
ResultType type = ResultType::Invalid;
|
||||||
|
switch (severity.at(0).toLatin1()) {
|
||||||
|
case 'I': type = ResultType::MessageInfo; break; // INFO
|
||||||
|
case 'W': type = ResultType::MessageWarn; break; // WARNING
|
||||||
|
case 'E': type = ResultType::MessageError; break; // ERROR
|
||||||
|
case 'F': type = ResultType::MessageFatal; break; // FATAL
|
||||||
|
}
|
||||||
|
TestResultPtr testResult = createDefaultResult();
|
||||||
|
testResult->setResult(type);
|
||||||
|
testResult->setLine(match.captured(3).toInt());
|
||||||
|
const QString file = constructSourceFilePath(m_buildDir, match.captured(2));
|
||||||
|
if (!file.isEmpty())
|
||||||
|
testResult->setFileName(file);
|
||||||
|
testResult->setDescription(match.captured(4));
|
||||||
|
reportResult(testResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GTestOutputReader::processStdError(const QByteArray &outputLine)
|
||||||
|
{
|
||||||
|
// we need to process the output, GTest may uses both out streams
|
||||||
|
processOutputLine(outputLine);
|
||||||
|
emit newOutputLineAvailable(outputLine, OutputChannel::StdErr);
|
||||||
|
}
|
||||||
|
|
||||||
TestResultPtr GTestOutputReader::createDefaultResult() const
|
TestResultPtr GTestOutputReader::createDefaultResult() const
|
||||||
{
|
{
|
||||||
GTestResult *result = new GTestResult(id(), m_projectFile, m_currentTestSuite);
|
GTestResult *result = new GTestResult(id(), m_projectFile, m_currentTestSuite);
|
||||||
|
@@ -44,6 +44,7 @@ public:
|
|||||||
const QString &projectFile);
|
const QString &projectFile);
|
||||||
protected:
|
protected:
|
||||||
void processOutputLine(const QByteArray &outputLine) override;
|
void processOutputLine(const QByteArray &outputLine) override;
|
||||||
|
void processStdError(const QByteArray &outputLine) override;
|
||||||
TestResultPtr createDefaultResult() const override;
|
TestResultPtr createDefaultResult() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Reference in New Issue
Block a user