forked from qt-creator/qt-creator
AutoTest: Handle durations for Catch2
Task-number: QTCREATORBUG-31242 Change-Id: I4bfffc82b3e00080998dc7e49cbef2ea8db3b319 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -76,7 +76,7 @@ QStringList CatchConfiguration::argumentsForTestRunner(QStringList *omitted) con
|
||||
QStringList arguments;
|
||||
if (testCaseCount())
|
||||
arguments << "\"" + testCases().join("\", \"") + "\"";
|
||||
arguments << "--reporter" << "xml";
|
||||
arguments << "--reporter" << "xml" << "--durations" << "yes";
|
||||
|
||||
if (testSettings().processArgs()) {
|
||||
arguments << filterInterfering(runnable().command.arguments().split(
|
||||
|
@@ -67,6 +67,12 @@ void CatchOutputReader::processOutputLine(const QByteArray &outputLineWithNewLin
|
||||
recordTestInformation(m_xmlReader.attributes());
|
||||
sendResult(ResultType::TestStart);
|
||||
} else if (m_currentTagName == CatchXml::TestCaseResultElement) {
|
||||
const QXmlStreamAttributes attributes = m_xmlReader.attributes();
|
||||
if (attributes.hasAttribute("durationInSeconds")) {
|
||||
double durationInSec = attributes.value("durationInSeconds").toDouble();
|
||||
m_duration = durationInSec * 1000.;
|
||||
m_overallDuration += m_duration;
|
||||
}
|
||||
if (m_currentTestNode == OverallNode || m_currentTestNode == GroupNode)
|
||||
continue;
|
||||
if (m_reportedResult)
|
||||
@@ -88,6 +94,7 @@ void CatchOutputReader::processOutputLine(const QByteArray &outputLineWithNewLin
|
||||
if (m_xpassCount)
|
||||
m_summary[ResultType::UnexpectedPass] = m_xpassCount;
|
||||
}
|
||||
m_executionDuration = qRound(m_overallDuration);
|
||||
if (m_currentTestNode == OverallNode || m_currentTestNode == GroupNode)
|
||||
continue;
|
||||
if (attributes.value("failures").toInt() == 0)
|
||||
@@ -142,9 +149,11 @@ void CatchOutputReader::processOutputLine(const QByteArray &outputLineWithNewLin
|
||||
|
||||
if (currentTag == QLatin1String(CatchXml::SectionElement)) {
|
||||
sendResult(ResultType::TestEnd);
|
||||
m_duration = 0;
|
||||
testOutputNodeFinished(SectionNode);
|
||||
} else if (currentTag == QLatin1String(CatchXml::TestCaseElement)) {
|
||||
sendResult(ResultType::TestEnd);
|
||||
m_duration = 0;
|
||||
testOutputNodeFinished(TestCaseNode);
|
||||
} else if (currentTag == QLatin1String(CatchXml::GroupElement)) {
|
||||
testOutputNodeFinished(GroupNode);
|
||||
@@ -262,6 +271,7 @@ void CatchOutputReader::sendResult(const ResultType result)
|
||||
m_reportedSectionResult = true;
|
||||
m_reportedResult = true;
|
||||
} else if (result == ResultType::TestEnd) {
|
||||
catchResult.setDuration(QString::number(m_duration, 'f', 3));
|
||||
catchResult.setDescription(Tr::tr("Finished executing %1 \"%2\".")
|
||||
.arg(testOutputNodeToString().toLower(), catchResult.description()));
|
||||
} else if (result == ResultType::Benchmark || result == ResultType::MessageFatal) {
|
||||
|
@@ -55,6 +55,8 @@ private:
|
||||
QXmlStreamReader m_xmlReader;
|
||||
ResultType m_currentResult = ResultType::Invalid;
|
||||
int m_xpassCount = 0;
|
||||
double m_duration = 0; // in ms
|
||||
double m_overallDuration = 0; // in ms
|
||||
bool m_mayFail = false;
|
||||
bool m_shouldFail = false;
|
||||
bool m_reportedResult = false;
|
||||
|
Reference in New Issue
Block a user