From c3715883ee6223d8bc4d7ca10b0783d629e68577 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Mon, 17 Apr 2023 13:02:51 +0200 Subject: [PATCH] AutoTest: Improve handling of Qt Quick Tests Qml files must not get declared inside the project files which makes it hard to correctly determine the correct project part they might belong to. The recommended and correct way of using Quick Tests is to have QUICK_TEST_SOURCE_DIR defined which is used internally anyhow to find the respective qml files. Make use of this fact also when determining the correct project part. Fixes: QTCREATORBUG-28716 Change-Id: I45371242ce931ee83b7bfbdd07a0848c7fd86abb Reviewed-by: David Schulz --- src/plugins/autotest/quick/quicktesttreeitem.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/plugins/autotest/quick/quicktesttreeitem.cpp b/src/plugins/autotest/quick/quicktesttreeitem.cpp index 49358f49ebd..f721ce3bc0d 100644 --- a/src/plugins/autotest/quick/quicktesttreeitem.cpp +++ b/src/plugins/autotest/quick/quicktesttreeitem.cpp @@ -375,8 +375,14 @@ QSet internalTargets(const FilePath &proFile) for (const CppEditor::ProjectPart::ConstPtr &projectPart : projectInfo->projectParts()) { if (projectPart->buildTargetType != ProjectExplorer::BuildTargetType::Executable) continue; - if (projectPart->projectFile == proFile.toString()) + if (projectPart->projectFile != proFile.toString()) + continue; + if (Utils::anyOf(projectPart->projectMacros, [](const ProjectExplorer::Macro ¯o){ + return macro.type == ProjectExplorer::MacroType::Define && + macro.key == "QUICK_TEST_SOURCE_DIR"; + })) { result.insert(projectPart->buildSystemTarget); + } } return result; }