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;
|
QStringList arguments;
|
||||||
if (testCaseCount())
|
if (testCaseCount())
|
||||||
arguments << "\"" + testCases().join("\", \"") + "\"";
|
arguments << "\"" + testCases().join("\", \"") + "\"";
|
||||||
arguments << "--reporter" << "xml";
|
arguments << "--reporter" << "xml" << "--durations" << "yes";
|
||||||
|
|
||||||
if (testSettings().processArgs()) {
|
if (testSettings().processArgs()) {
|
||||||
arguments << filterInterfering(runnable().command.arguments().split(
|
arguments << filterInterfering(runnable().command.arguments().split(
|
||||||
|
@@ -67,6 +67,12 @@ void CatchOutputReader::processOutputLine(const QByteArray &outputLineWithNewLin
|
|||||||
recordTestInformation(m_xmlReader.attributes());
|
recordTestInformation(m_xmlReader.attributes());
|
||||||
sendResult(ResultType::TestStart);
|
sendResult(ResultType::TestStart);
|
||||||
} else if (m_currentTagName == CatchXml::TestCaseResultElement) {
|
} 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)
|
if (m_currentTestNode == OverallNode || m_currentTestNode == GroupNode)
|
||||||
continue;
|
continue;
|
||||||
if (m_reportedResult)
|
if (m_reportedResult)
|
||||||
@@ -88,6 +94,7 @@ void CatchOutputReader::processOutputLine(const QByteArray &outputLineWithNewLin
|
|||||||
if (m_xpassCount)
|
if (m_xpassCount)
|
||||||
m_summary[ResultType::UnexpectedPass] = m_xpassCount;
|
m_summary[ResultType::UnexpectedPass] = m_xpassCount;
|
||||||
}
|
}
|
||||||
|
m_executionDuration = qRound(m_overallDuration);
|
||||||
if (m_currentTestNode == OverallNode || m_currentTestNode == GroupNode)
|
if (m_currentTestNode == OverallNode || m_currentTestNode == GroupNode)
|
||||||
continue;
|
continue;
|
||||||
if (attributes.value("failures").toInt() == 0)
|
if (attributes.value("failures").toInt() == 0)
|
||||||
@@ -142,9 +149,11 @@ void CatchOutputReader::processOutputLine(const QByteArray &outputLineWithNewLin
|
|||||||
|
|
||||||
if (currentTag == QLatin1String(CatchXml::SectionElement)) {
|
if (currentTag == QLatin1String(CatchXml::SectionElement)) {
|
||||||
sendResult(ResultType::TestEnd);
|
sendResult(ResultType::TestEnd);
|
||||||
|
m_duration = 0;
|
||||||
testOutputNodeFinished(SectionNode);
|
testOutputNodeFinished(SectionNode);
|
||||||
} else if (currentTag == QLatin1String(CatchXml::TestCaseElement)) {
|
} else if (currentTag == QLatin1String(CatchXml::TestCaseElement)) {
|
||||||
sendResult(ResultType::TestEnd);
|
sendResult(ResultType::TestEnd);
|
||||||
|
m_duration = 0;
|
||||||
testOutputNodeFinished(TestCaseNode);
|
testOutputNodeFinished(TestCaseNode);
|
||||||
} else if (currentTag == QLatin1String(CatchXml::GroupElement)) {
|
} else if (currentTag == QLatin1String(CatchXml::GroupElement)) {
|
||||||
testOutputNodeFinished(GroupNode);
|
testOutputNodeFinished(GroupNode);
|
||||||
@@ -262,6 +271,7 @@ void CatchOutputReader::sendResult(const ResultType result)
|
|||||||
m_reportedSectionResult = true;
|
m_reportedSectionResult = true;
|
||||||
m_reportedResult = true;
|
m_reportedResult = true;
|
||||||
} else if (result == ResultType::TestEnd) {
|
} else if (result == ResultType::TestEnd) {
|
||||||
|
catchResult.setDuration(QString::number(m_duration, 'f', 3));
|
||||||
catchResult.setDescription(Tr::tr("Finished executing %1 \"%2\".")
|
catchResult.setDescription(Tr::tr("Finished executing %1 \"%2\".")
|
||||||
.arg(testOutputNodeToString().toLower(), catchResult.description()));
|
.arg(testOutputNodeToString().toLower(), catchResult.description()));
|
||||||
} else if (result == ResultType::Benchmark || result == ResultType::MessageFatal) {
|
} else if (result == ResultType::Benchmark || result == ResultType::MessageFatal) {
|
||||||
|
@@ -55,6 +55,8 @@ private:
|
|||||||
QXmlStreamReader m_xmlReader;
|
QXmlStreamReader m_xmlReader;
|
||||||
ResultType m_currentResult = ResultType::Invalid;
|
ResultType m_currentResult = ResultType::Invalid;
|
||||||
int m_xpassCount = 0;
|
int m_xpassCount = 0;
|
||||||
|
double m_duration = 0; // in ms
|
||||||
|
double m_overallDuration = 0; // in ms
|
||||||
bool m_mayFail = false;
|
bool m_mayFail = false;
|
||||||
bool m_shouldFail = false;
|
bool m_shouldFail = false;
|
||||||
bool m_reportedResult = false;
|
bool m_reportedResult = false;
|
||||||
|
Reference in New Issue
Block a user