aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@qt.io>2020-07-01 17:01:10 +0200
committerChristian Stenger <christian.stenger@qt.io>2020-07-10 05:06:58 +0000
commit502ad9badb73119fccea48c9c19413dea1e87493 (patch)
tree269e6c0d3b68fbc560e468157ffbfafe6b10ccc3
parentcd1a848e16c400d5d32bda2fb1eaf0f99e25f9da (diff)
AutoTest: Correct completing test run configuration
Ensure all possible project parts are taken into account when gathering build system targets. When having multiple possible build system targets for a test - which may easily happen e.g. when defining tests beside the main application inside a big top-level CMakeLists.txt - let the user decide which one to run. Fixes: QTCREATORBUG-24268 Change-Id: Ia7b7e4148fe8e8dab55832c435f12cc78f5c2f7a Reviewed-by: David Schulz <david.schulz@qt.io>
-rw-r--r--src/plugins/autotest/quick/quicktesttreeitem.cpp4
-rw-r--r--src/plugins/autotest/testconfiguration.cpp19
2 files changed, 11 insertions, 12 deletions
diff --git a/src/plugins/autotest/quick/quicktesttreeitem.cpp b/src/plugins/autotest/quick/quicktesttreeitem.cpp
index 5274a27099..5c6cf57aa9 100644
--- a/src/plugins/autotest/quick/quicktesttreeitem.cpp
+++ b/src/plugins/autotest/quick/quicktesttreeitem.cpp
@@ -420,10 +420,8 @@ QSet<QString> QuickTestTreeItem::internalTargets() const
for (const CppTools::ProjectPart::Ptr &projectPart : projectInfo.projectParts()) {
if (projectPart->buildTargetType != ProjectExplorer::BuildTargetType::Executable)
continue;
- if (projectPart->projectFile == proFile()) {
+ if (projectPart->projectFile == proFile())
result.insert(projectPart->buildSystemTarget);
- break;
- }
}
return result;
}
diff --git a/src/plugins/autotest/testconfiguration.cpp b/src/plugins/autotest/testconfiguration.cpp
index 96a5a842db..c5ff920260 100644
--- a/src/plugins/autotest/testconfiguration.cpp
+++ b/src/plugins/autotest/testconfiguration.cpp
@@ -143,22 +143,23 @@ void TestConfiguration::completeTestInformation(TestRunMode runMode)
const QSet<QString> buildSystemTargets = m_buildTargets;
qCDebug(LOG) << "BuildSystemTargets\n " << buildSystemTargets;
- const QList<BuildTargetInfo> buildTargets = target->buildSystem()->applicationTargets();
- BuildTargetInfo targetInfo
- = Utils::findOrDefault(buildTargets,
- [&buildSystemTargets] (const BuildTargetInfo &bti) {
+ const QList<BuildTargetInfo> buildTargets
+ = Utils::filtered(target->buildSystem()->applicationTargets(),
+ [&buildSystemTargets](const BuildTargetInfo &bti) {
return buildSystemTargets.contains(bti.buildKey);
});
+ if (buildTargets.size() > 1 ) // there are multiple executables with the same build target
+ return; // let the user decide which one to run
+
+ const BuildTargetInfo targetInfo = buildTargets.first();
+
// we might end up with an empty targetFilePath - e.g. when having a library we just link to
// there would be no BuildTargetInfo that could match
if (targetInfo.targetFilePath.isEmpty()) {
qCDebug(LOG) << "BuildTargetInfos";
// if there is only one build target just use it (but be honest that we're deducing)
- if (buildTargets.size() == 1) {
- targetInfo = buildTargets.first();
- m_deducedConfiguration = true;
- m_deducedFrom = targetInfo.buildKey;
- }
+ m_deducedConfiguration = true;
+ m_deducedFrom = targetInfo.buildKey;
}
const FilePath localExecutable = ensureExeEnding(targetInfo.targetFilePath);