From 2c413758a6fbb828c8ad636d0976ca88d88d263a Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Wed, 17 Jul 2024 10:06:18 +0200 Subject: [PATCH] AutoTest: Fix adding finish message into results tree For QTest based tests we added the function finish message wrongly to the last data tag when using data driven tests. Not crucial, but it would become so in a follow up. For finish messages we know that these only apply to test functions or cases - never data tags. This patch ensures we only add TestEnd messages to the corresponding TestStart. Change-Id: Idceb6e563e6f8c5f426e5604d4c533508583429c Reviewed-by: David Schulz --- src/plugins/autotest/qtest/qttestoutputreader.cpp | 4 +++- src/plugins/autotest/qtest/qttestresult.cpp | 10 ++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/plugins/autotest/qtest/qttestoutputreader.cpp b/src/plugins/autotest/qtest/qttestoutputreader.cpp index b668ea442f6..682d0323f17 100644 --- a/src/plugins/autotest/qtest/qttestoutputreader.cpp +++ b/src/plugins/autotest/qtest/qttestoutputreader.cpp @@ -279,7 +279,6 @@ void QtTestOutputReader::processXMLOutput(const QByteArray &outputLine) if (currentTag == QStringLiteral("TestFunction")) { sendFinishMessage(true); // TODO: bump progress? - m_dataTag.clear(); m_formerTestCase = m_testCase; m_testCase.clear(); } else if (currentTag == QStringLiteral("TestCase")) { @@ -503,6 +502,9 @@ void QtTestOutputReader::sendStartMessage(bool isFunction) void QtTestOutputReader::sendFinishMessage(bool isFunction) { + m_dataTag.clear(); + if (!isFunction) + m_testCase.clear(); TestResult result = createDefaultResult(); result.setResult(ResultType::TestEnd); if (!m_duration.isEmpty()) { diff --git a/src/plugins/autotest/qtest/qttestresult.cpp b/src/plugins/autotest/qtest/qttestresult.cpp index 581a334efc6..9cefca17b8c 100644 --- a/src/plugins/autotest/qtest/qttestresult.cpp +++ b/src/plugins/autotest/qtest/qttestresult.cpp @@ -164,11 +164,17 @@ static ResultHooks::DirectParentHook directParentHook(const QString &functionNam const QtTestData otherData = other.extraData().value(); if (result.result() == ResultType::TestStart) { + if (other.result() == ResultType::TestEnd) { + if (!dataTag.isEmpty()) + return false; + return functionName.isEmpty() ? otherData.m_function.isEmpty() + : functionName == otherData.m_function; + } + if (otherData.isDataTag()) { if (otherData.m_function == functionName) { if (dataTag.isEmpty()) { - // avoid adding function's TestCaseEnd to the data tag - *needsIntermediate = other.result() != ResultType::TestEnd; + *needsIntermediate = true; return true; } return otherData.m_dataTag == dataTag;