aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/autotest
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@qt.io>2020-09-23 09:11:25 +0200
committerChristian Stenger <christian.stenger@qt.io>2020-10-01 08:08:06 +0000
commitd10d25b3f310a183bc987ee2e793d6f3d2b717fb (patch)
treeba225fb5387da2d229fa3166ad3641286f61187e /src/plugins/autotest
parentff06a409c2ce42f50967a540f2c9296a4d36f971 (diff)
AutoTest: Improve Boost test results handling
This improves constructing the results tree and additionally fixes matching free functions to their respective test tree items. Change-Id: I79490507ba7a1934a7be010a00cb341374bf93ad Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/autotest')
-rw-r--r--src/plugins/autotest/boost/boosttestoutputreader.cpp18
-rw-r--r--src/plugins/autotest/boost/boosttestresult.cpp25
2 files changed, 34 insertions, 9 deletions
diff --git a/src/plugins/autotest/boost/boosttestoutputreader.cpp b/src/plugins/autotest/boost/boosttestoutputreader.cpp
index a21891f4cce..d5ce4ab4953 100644
--- a/src/plugins/autotest/boost/boosttestoutputreader.cpp
+++ b/src/plugins/autotest/boost/boosttestoutputreader.cpp
@@ -157,7 +157,11 @@ void BoostTestOutputReader::handleMessageMatch(const QRegularExpressionMatch &ma
m_currentTest = match.captured(9);
m_description = tr("Executing test case %1").arg(m_currentTest);
} else if (type == "suite") {
- m_currentSuite = match.captured(9);
+ if (m_currentSuite.isEmpty())
+ m_currentSuite = match.captured(9);
+ else
+ m_currentSuite.append("/").append(match.captured(9));
+ m_currentTest.clear();
m_description = tr("Executing test suite %1").arg(m_currentSuite);
}
} else if (content.startsWith("Leaving")) {
@@ -168,8 +172,18 @@ void BoostTestOutputReader::handleMessageMatch(const QRegularExpressionMatch &ma
m_result = ResultType::TestEnd;
m_description = tr("Test execution took %1").arg(match.captured(12));
} else if (type == "suite") {
- if (m_currentSuite != match.captured(11) && m_currentSuite.isEmpty())
+ if (!m_currentSuite.isEmpty()) {
+ int index = m_currentSuite.lastIndexOf('/');
+ if (QTC_GUARD(m_currentSuite.mid(index + 1) == match.captured(11))) {
+ if (index == -1)
+ m_currentSuite.clear();
+ else
+ m_currentSuite = m_currentSuite.left(index);
+ }
+ } else if (match.capturedLength(11)) { // FIXME remove this branch?
+ QTC_CHECK(false);
m_currentSuite = match.captured(11);
+ }
m_currentTest.clear();
m_result = ResultType::TestEnd;
m_description = tr("Test suite execution took %1").arg(match.captured(12));
diff --git a/src/plugins/autotest/boost/boosttestresult.cpp b/src/plugins/autotest/boost/boosttestresult.cpp
index 470d01047c4..29f2c8269d6 100644
--- a/src/plugins/autotest/boost/boosttestresult.cpp
+++ b/src/plugins/autotest/boost/boosttestresult.cpp
@@ -62,16 +62,27 @@ bool BoostTestResult::isDirectParentOf(const TestResult *other, bool *needsInter
if (!TestResult::isDirectParentOf(other, needsIntermediate))
return false;
- const BoostTestResult *boostOther = static_cast<const BoostTestResult *>(other);
-
- if (m_testSuite != boostOther->m_testSuite)
+ if (result() != ResultType::TestStart)
return false;
- if (result() == ResultType::TestStart) {
- if (!boostOther->m_testCase.isEmpty())
- return boostOther->m_testSuite == m_testSuite && boostOther->result() != ResultType::TestStart;
+ bool weAreModule = (m_testCase.isEmpty() && m_testSuite.isEmpty());
+ bool weAreSuite = (m_testCase.isEmpty() && !m_testSuite.isEmpty());
+ bool weAreCase = (!m_testCase.isEmpty());
- return boostOther->m_testCase == m_testCase;
+ const BoostTestResult *boostOther = static_cast<const BoostTestResult *>(other);
+ bool otherIsSuite = boostOther->m_testCase.isEmpty() && !boostOther->m_testSuite.isEmpty();
+ bool otherIsCase = !boostOther->m_testCase.isEmpty();
+
+ if (otherIsSuite)
+ return weAreSuite ? boostOther->m_testSuite.startsWith(m_testSuite + '/') : weAreModule;
+
+ if (otherIsCase) {
+ if (weAreCase)
+ return boostOther->m_testCase == m_testCase && boostOther->m_testSuite == m_testSuite;
+ if (weAreSuite)
+ return boostOther->m_testSuite == m_testSuite;
+ if (weAreModule)
+ return boostOther->m_testSuite.isEmpty();
}
return false;
}