diff --git a/src/plugins/autotest/boost/boosttestresult.cpp b/src/plugins/autotest/boost/boosttestresult.cpp index 373493cc09a..80cca80cc4b 100644 --- a/src/plugins/autotest/boost/boosttestresult.cpp +++ b/src/plugins/autotest/boost/boosttestresult.cpp @@ -130,10 +130,10 @@ static ResultHooks::DirectParentHook directParentHook(const QString &testCaseNam BoostTestResult::BoostTestResult(const QString &id, const QString &name, const FilePath &projectFile, const QString &testCaseName, const QString &testSuiteName) - : TestResult(id, name, {outputStringHook(testCaseName), + : TestResult(id, name, {QVariant::fromValue(BoostTestData{testCaseName, testSuiteName}), + outputStringHook(testCaseName), findTestItemHook(projectFile, testCaseName, testSuiteName), - directParentHook(testCaseName, testSuiteName), - QVariant::fromValue(BoostTestData{testCaseName, testSuiteName})}) + directParentHook(testCaseName, testSuiteName)}) {} } // namespace Internal diff --git a/src/plugins/autotest/catch/catchresult.cpp b/src/plugins/autotest/catch/catchresult.cpp index 265700ca658..9c616944b49 100644 --- a/src/plugins/autotest/catch/catchresult.cpp +++ b/src/plugins/autotest/catch/catchresult.cpp @@ -68,8 +68,8 @@ static ResultHooks::DirectParentHook directParentHook(int depth) } CatchResult::CatchResult(const QString &id, const QString &name, int depth) - : TestResult(id, name, {{}, findTestItemHook(), directParentHook(depth), - QVariant::fromValue(CatchData{depth})}) + : TestResult(id, name, {QVariant::fromValue(CatchData{depth}), + {}, findTestItemHook(), directParentHook(depth)}) {} } // namespace Internal diff --git a/src/plugins/autotest/ctest/ctestoutputreader.cpp b/src/plugins/autotest/ctest/ctestoutputreader.cpp index 066b5e5680c..8373a1ab59c 100644 --- a/src/plugins/autotest/ctest/ctestoutputreader.cpp +++ b/src/plugins/autotest/ctest/ctestoutputreader.cpp @@ -48,7 +48,7 @@ class CTestResult : public TestResult { public: CTestResult(const QString &id, const QString &project, const QString &testCaseName) - : TestResult(id, project, {{}, findTestItemHook(testCaseName), directParentHook(), {}}) + : TestResult(id, project, {{}, {}, findTestItemHook(testCaseName), directParentHook()}) {} }; diff --git a/src/plugins/autotest/gtest/gtestresult.cpp b/src/plugins/autotest/gtest/gtestresult.cpp index 902c28132e5..b89c06bd8e3 100644 --- a/src/plugins/autotest/gtest/gtestresult.cpp +++ b/src/plugins/autotest/gtest/gtestresult.cpp @@ -125,10 +125,10 @@ static ResultHooks::DirectParentHook directParentHook(const QString &testCaseNam GTestResult::GTestResult(const QString &id, const QString &name, const FilePath &projectFile, const QString &testCaseName, int iteration) - : TestResult(id, name, {outputStringHook(testCaseName), + : TestResult(id, name, {QVariant::fromValue(GTestData{testCaseName, iteration}), + outputStringHook(testCaseName), findTestItemHook(projectFile, testCaseName), - directParentHook(testCaseName, iteration), - QVariant::fromValue(GTestData{testCaseName, iteration})}) + directParentHook(testCaseName, iteration)}) {} } // namespace Internal diff --git a/src/plugins/autotest/qtest/qttestresult.cpp b/src/plugins/autotest/qtest/qttestresult.cpp index 945acc05499..ee56d4541b3 100644 --- a/src/plugins/autotest/qtest/qttestresult.cpp +++ b/src/plugins/autotest/qtest/qttestresult.cpp @@ -183,32 +183,38 @@ static ResultHooks::DirectParentHook directParentHook(const QString &functionNam }; } +static ResultHooks::IntermediateHook intermediateHook(const FilePath &projectFile, + const QString &functionName, + const QString &dataTag) +{ + return [=](const TestResult &result, const TestResult &other) -> bool { + if (!other.extraData().canConvert()) + return false; + const QtTestData otherData = other.extraData().value(); + return dataTag == otherData.m_dataTag && functionName == otherData.m_function + && result.name() == other.name() && result.id() == other.id() + && projectFile == otherData.m_projectFile; + }; +} + QtTestResult::QtTestResult(const QString &id, const QString &name, const FilePath &projectFile, TestType type, const QString &functionName, const QString &dataTag) - : TestResult(id, name, {outputStringHook(functionName, dataTag), + : TestResult(id, name, {QVariant::fromValue(QtTestData{projectFile, type, functionName, dataTag}), + outputStringHook(functionName, dataTag), findTestItemHook(projectFile, type, functionName, dataTag), directParentHook(functionName, dataTag), - QVariant::fromValue(QtTestData{projectFile, type, functionName, dataTag})}) + intermediateHook(projectFile, functionName, dataTag)}) , m_projectFile(projectFile) , m_type(type) , m_function(functionName) , m_dataTag(dataTag) {} -bool QtTestResult::isIntermediateFor(const TestResult *other) const -{ - QTC_ASSERT(other, return false); - const QtTestResult *qtOther = static_cast(other); - return m_dataTag == qtOther->m_dataTag && m_function == qtOther->m_function - && name() == qtOther->name() && id() == qtOther->id() - && m_projectFile == qtOther->m_projectFile; -} - TestResult *QtTestResult::createIntermediateResultFor(const TestResult *other) const { QTC_ASSERT(other, return nullptr); const QtTestResult *qtOther = static_cast(other); QtTestResult *intermediate = new QtTestResult(qtOther->id(), qtOther->name(), qtOther->m_projectFile, - m_type); + m_type, qtOther->m_function, qtOther->m_dataTag); intermediate->m_function = qtOther->m_function; intermediate->m_dataTag = qtOther->m_dataTag; // intermediates will be needed only for data tags diff --git a/src/plugins/autotest/qtest/qttestresult.h b/src/plugins/autotest/qtest/qttestresult.h index 66ff5dc4570..0f9c3e9c9cd 100644 --- a/src/plugins/autotest/qtest/qttestresult.h +++ b/src/plugins/autotest/qtest/qttestresult.h @@ -18,14 +18,9 @@ public: QtTestResult(const QString &id, const QString &name, const Utils::FilePath &projectFile, TestType type, const QString &functionName = {}, const QString &dataTag = {}); - bool isIntermediateFor(const TestResult *other) const override; TestResult *createIntermediateResultFor(const TestResult *other) const override; private: - bool isTestCase() const { return m_function.isEmpty() && m_dataTag.isEmpty(); } - bool isTestFunction() const { return !m_function.isEmpty() && m_dataTag.isEmpty(); } - bool isDataTag() const { return !m_function.isEmpty() && !m_dataTag.isEmpty(); } - Utils::FilePath m_projectFile; TestType m_type; QString m_function; diff --git a/src/plugins/autotest/testresult.cpp b/src/plugins/autotest/testresult.cpp index 6a9478cbc6b..3749b0a8acc 100644 --- a/src/plugins/autotest/testresult.cpp +++ b/src/plugins/autotest/testresult.cpp @@ -170,6 +170,8 @@ bool TestResult::isDirectParentOf(const TestResult *other, bool *needsIntermedia bool TestResult::isIntermediateFor(const TestResult *other) const { QTC_ASSERT(other, return false); + if (m_hooks.intermediate) + return m_hooks.intermediate(*this, *other); return !m_id.isEmpty() && m_id == other->m_id && m_name == other->m_name; } diff --git a/src/plugins/autotest/testresult.h b/src/plugins/autotest/testresult.h index 34d0b9d0466..23ad1ddd248 100644 --- a/src/plugins/autotest/testresult.h +++ b/src/plugins/autotest/testresult.h @@ -65,10 +65,12 @@ struct ResultHooks using OutputStringHook = std::function; using FindTestItemHook = std::function; using DirectParentHook = std::function; + using IntermediateHook = std::function; + QVariant extraData; OutputStringHook outputString; FindTestItemHook findTestItem; DirectParentHook directParent; - QVariant extraData; + IntermediateHook intermediate = {}; }; class TestResult @@ -100,7 +102,7 @@ public: static QColor colorForType(const ResultType type); bool isDirectParentOf(const TestResult *other, bool *needsIntermediate) const; - virtual bool isIntermediateFor(const TestResult *other) const; + bool isIntermediateFor(const TestResult *other) const; virtual TestResult *createIntermediateResultFor(const TestResult *other) const; private: