forked from qt-creator/qt-creator
AutoTest: Fix handling of GTEST_SKIP
Fixes: QTCREATORBUG-23736 Change-Id: I3d52f3caf6b28e07d7d8d072fb33c782d33575c6 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -68,9 +68,8 @@ void GTestOutputReader::processOutputLine(const QByteArray &outputLine)
|
|||||||
static const QRegularExpression newTestSetStarts("^\\[ RUN \\] (.*)$");
|
static const QRegularExpression newTestSetStarts("^\\[ RUN \\] (.*)$");
|
||||||
static const QRegularExpression testSetSuccess("^\\[ OK \\] (.*) \\((.*)\\)$");
|
static const QRegularExpression testSetSuccess("^\\[ OK \\] (.*) \\((.*)\\)$");
|
||||||
static const QRegularExpression testSetFail("^\\[ FAILED \\] (.*) \\((\\d+ ms)\\)$");
|
static const QRegularExpression testSetFail("^\\[ FAILED \\] (.*) \\((\\d+ ms)\\)$");
|
||||||
|
static const QRegularExpression testSetSkipped("^\\[ SKIPPED \\] (.*) \\((\\d+ ms)\\)$");
|
||||||
static const QRegularExpression disabledTests("^ YOU HAVE (\\d+) DISABLED TESTS?$");
|
static const QRegularExpression disabledTests("^ YOU HAVE (\\d+) DISABLED TESTS?$");
|
||||||
static const QRegularExpression failureLocation("^(.*):(\\d+): Failure$");
|
|
||||||
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 )\\] "
|
static const QRegularExpression logging("^\\[( FATAL | ERROR |WARNING| INFO )\\] "
|
||||||
@@ -126,6 +125,7 @@ void GTestOutputReader::processOutputLine(const QByteArray &outputLine)
|
|||||||
}
|
}
|
||||||
reportResult(testResult);
|
reportResult(testResult);
|
||||||
} else if (ExactMatch match = newTestSetStarts.match(line)) {
|
} else if (ExactMatch match = newTestSetStarts.match(line)) {
|
||||||
|
m_testSetStarted = true;
|
||||||
setCurrentTestCase(match.captured(1));
|
setCurrentTestCase(match.captured(1));
|
||||||
TestResultPtr testResult = TestResultPtr(new GTestResult(QString(), m_projectFile,
|
TestResultPtr testResult = TestResultPtr(new GTestResult(QString(), m_projectFile,
|
||||||
QString()));
|
QString()));
|
||||||
@@ -134,6 +134,7 @@ void GTestOutputReader::processOutputLine(const QByteArray &outputLine)
|
|||||||
reportResult(testResult);
|
reportResult(testResult);
|
||||||
m_description.clear();
|
m_description.clear();
|
||||||
} else if (ExactMatch match = testSetSuccess.match(line)) {
|
} else if (ExactMatch match = testSetSuccess.match(line)) {
|
||||||
|
m_testSetStarted = false;
|
||||||
TestResultPtr testResult = createDefaultResult();
|
TestResultPtr testResult = createDefaultResult();
|
||||||
testResult->setResult(ResultType::Pass);
|
testResult->setResult(ResultType::Pass);
|
||||||
testResult->setDescription(m_description);
|
testResult->setDescription(m_description);
|
||||||
@@ -145,40 +146,29 @@ void GTestOutputReader::processOutputLine(const QByteArray &outputLine)
|
|||||||
reportResult(testResult);
|
reportResult(testResult);
|
||||||
m_futureInterface.setProgressValue(m_futureInterface.progressValue() + 1);
|
m_futureInterface.setProgressValue(m_futureInterface.progressValue() + 1);
|
||||||
} else if (ExactMatch match = testSetFail.match(line)) {
|
} else if (ExactMatch match = testSetFail.match(line)) {
|
||||||
|
m_testSetStarted = false;
|
||||||
TestResultPtr testResult = createDefaultResult();
|
TestResultPtr testResult = createDefaultResult();
|
||||||
testResult->setResult(ResultType::Fail);
|
testResult->setResult(ResultType::Fail);
|
||||||
m_description.chop(1);
|
m_description.chop(1);
|
||||||
QStringList resultDescription;
|
handleDescriptionAndReportResult(testResult);
|
||||||
|
|
||||||
for (const QString &output : m_description.split('\n')) {
|
|
||||||
QRegularExpressionMatch innerMatch = failureLocation.match(output);
|
|
||||||
if (!innerMatch.hasMatch()) {
|
|
||||||
innerMatch = errorLocation.match(output);
|
|
||||||
if (!innerMatch.hasMatch()) {
|
|
||||||
resultDescription << output;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
testResult->setDescription(resultDescription.join('\n'));
|
|
||||||
reportResult(testResult);
|
|
||||||
resultDescription.clear();
|
|
||||||
|
|
||||||
testResult = createDefaultResult();
|
|
||||||
testResult->setResult(ResultType::MessageLocation);
|
|
||||||
testResult->setLine(innerMatch.captured(2).toInt());
|
|
||||||
QString file = constructSourceFilePath(m_buildDir, innerMatch.captured(1));
|
|
||||||
if (!file.isEmpty())
|
|
||||||
testResult->setFileName(file);
|
|
||||||
resultDescription << output;
|
|
||||||
}
|
|
||||||
testResult->setDescription(resultDescription.join('\n'));
|
|
||||||
reportResult(testResult);
|
|
||||||
m_description.clear();
|
|
||||||
testResult = createDefaultResult();
|
testResult = createDefaultResult();
|
||||||
testResult->setResult(ResultType::MessageInternal);
|
testResult->setResult(ResultType::MessageInternal);
|
||||||
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 = testSetSkipped.match(line)) {
|
||||||
|
if (!m_testSetStarted) // ignore SKIPPED at summary
|
||||||
|
return;
|
||||||
|
m_testSetStarted = false;
|
||||||
|
TestResultPtr testResult = createDefaultResult();
|
||||||
|
testResult->setResult(ResultType::Skip);
|
||||||
|
m_description.chop(1);
|
||||||
|
m_description.prepend(match.captured(1) + '\n');
|
||||||
|
handleDescriptionAndReportResult(testResult);
|
||||||
|
testResult = createDefaultResult();
|
||||||
|
testResult->setResult(ResultType::MessageInternal);
|
||||||
|
testResult->setDescription(tr("Execution took %1.").arg(match.captured(2)));
|
||||||
|
reportResult(testResult);
|
||||||
} else if (ExactMatch match = logging.match(line)) {
|
} else if (ExactMatch match = logging.match(line)) {
|
||||||
const QString severity = match.captured(1).trimmed();
|
const QString severity = match.captured(1).trimmed();
|
||||||
ResultType type = ResultType::Invalid;
|
ResultType type = ResultType::Invalid;
|
||||||
@@ -232,5 +222,38 @@ void GTestOutputReader::setCurrentTestSuite(const QString &testSuite)
|
|||||||
m_currentTestSuite = testSuite;
|
m_currentTestSuite = testSuite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GTestOutputReader::handleDescriptionAndReportResult(TestResultPtr testResult)
|
||||||
|
{
|
||||||
|
static const QRegularExpression failureLocation("^(.*):(\\d+): Failure$");
|
||||||
|
static const QRegularExpression skipOrErrorLocation("^(.*)\\((\\d+)\\): (Skipped|error:.*)$");
|
||||||
|
|
||||||
|
QStringList resultDescription;
|
||||||
|
|
||||||
|
for (const QString &output : m_description.split('\n')) {
|
||||||
|
QRegularExpressionMatch innerMatch = failureLocation.match(output);
|
||||||
|
if (!innerMatch.hasMatch()) {
|
||||||
|
innerMatch = skipOrErrorLocation.match(output);
|
||||||
|
if (!innerMatch.hasMatch()) {
|
||||||
|
resultDescription << output;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
testResult->setDescription(resultDescription.join('\n'));
|
||||||
|
reportResult(testResult);
|
||||||
|
resultDescription.clear();
|
||||||
|
|
||||||
|
testResult = createDefaultResult();
|
||||||
|
testResult->setResult(ResultType::MessageLocation);
|
||||||
|
testResult->setLine(innerMatch.captured(2).toInt());
|
||||||
|
QString file = constructSourceFilePath(m_buildDir, innerMatch.captured(1));
|
||||||
|
if (!file.isEmpty())
|
||||||
|
testResult->setFileName(file);
|
||||||
|
resultDescription << output;
|
||||||
|
}
|
||||||
|
testResult->setDescription(resultDescription.join('\n'));
|
||||||
|
reportResult(testResult);
|
||||||
|
m_description.clear();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Autotest
|
} // namespace Autotest
|
||||||
|
@@ -50,12 +50,14 @@ protected:
|
|||||||
private:
|
private:
|
||||||
void setCurrentTestCase(const QString &testCase);
|
void setCurrentTestCase(const QString &testCase);
|
||||||
void setCurrentTestSuite(const QString &testSuite);
|
void setCurrentTestSuite(const QString &testSuite);
|
||||||
|
void handleDescriptionAndReportResult(TestResultPtr testResult);
|
||||||
|
|
||||||
QString m_projectFile;
|
QString m_projectFile;
|
||||||
QString m_currentTestSuite;
|
QString m_currentTestSuite;
|
||||||
QString m_currentTestCase;
|
QString m_currentTestCase;
|
||||||
QString m_description;
|
QString m_description;
|
||||||
int m_iteration = 1;
|
int m_iteration = 1;
|
||||||
|
bool m_testSetStarted = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
Reference in New Issue
Block a user