aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/autotest/catch
diff options
context:
space:
mode:
authorChristian Stenger <[email protected]>2024-07-22 08:51:46 +0200
committerChristian Stenger <[email protected]>2024-08-29 07:57:24 +0000
commit46ab9f6aad52540aeb22acc606d1d2b26976571e (patch)
tree5a764be2920469a62a378b4223e0daf52ca24c57 /src/plugins/autotest/catch
parent4ba039fefae957667de8cc97e6bc4959377c74ba (diff)
AutoTest: Handle durations for Catch2
Task-number: QTCREATORBUG-31242 Change-Id: I4bfffc82b3e00080998dc7e49cbef2ea8db3b319 Reviewed-by: David Schulz <[email protected]>
Diffstat (limited to 'src/plugins/autotest/catch')
-rw-r--r--src/plugins/autotest/catch/catchconfiguration.cpp2
-rw-r--r--src/plugins/autotest/catch/catchoutputreader.cpp10
-rw-r--r--src/plugins/autotest/catch/catchoutputreader.h2
3 files changed, 13 insertions, 1 deletions
diff --git a/src/plugins/autotest/catch/catchconfiguration.cpp b/src/plugins/autotest/catch/catchconfiguration.cpp
index e1773064f77..0012ad71dc5 100644
--- a/src/plugins/autotest/catch/catchconfiguration.cpp
+++ b/src/plugins/autotest/catch/catchconfiguration.cpp
@@ -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(
diff --git a/src/plugins/autotest/catch/catchoutputreader.cpp b/src/plugins/autotest/catch/catchoutputreader.cpp
index 6c730c30455..ccd28465f6b 100644
--- a/src/plugins/autotest/catch/catchoutputreader.cpp
+++ b/src/plugins/autotest/catch/catchoutputreader.cpp
@@ -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) {
diff --git a/src/plugins/autotest/catch/catchoutputreader.h b/src/plugins/autotest/catch/catchoutputreader.h
index b46db333f80..5ff474d77f2 100644
--- a/src/plugins/autotest/catch/catchoutputreader.h
+++ b/src/plugins/autotest/catch/catchoutputreader.h
@@ -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;