forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -420,10 +420,8 @@ QSet<QString> QuickTestTreeItem::internalTargets() const
|
|||||||
for (const CppTools::ProjectPart::Ptr &projectPart : projectInfo.projectParts()) {
|
for (const CppTools::ProjectPart::Ptr &projectPart : projectInfo.projectParts()) {
|
||||||
if (projectPart->buildTargetType != ProjectExplorer::BuildTargetType::Executable)
|
if (projectPart->buildTargetType != ProjectExplorer::BuildTargetType::Executable)
|
||||||
continue;
|
continue;
|
||||||
if (projectPart->projectFile == proFile()) {
|
if (projectPart->projectFile == proFile())
|
||||||
result.insert(projectPart->buildSystemTarget);
|
result.insert(projectPart->buildSystemTarget);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@@ -143,22 +143,23 @@ void TestConfiguration::completeTestInformation(TestRunMode runMode)
|
|||||||
|
|
||||||
const QSet<QString> buildSystemTargets = m_buildTargets;
|
const QSet<QString> buildSystemTargets = m_buildTargets;
|
||||||
qCDebug(LOG) << "BuildSystemTargets\n " << buildSystemTargets;
|
qCDebug(LOG) << "BuildSystemTargets\n " << buildSystemTargets;
|
||||||
const QList<BuildTargetInfo> buildTargets = target->buildSystem()->applicationTargets();
|
const QList<BuildTargetInfo> buildTargets
|
||||||
BuildTargetInfo targetInfo
|
= Utils::filtered(target->buildSystem()->applicationTargets(),
|
||||||
= Utils::findOrDefault(buildTargets,
|
[&buildSystemTargets](const BuildTargetInfo &bti) {
|
||||||
[&buildSystemTargets] (const BuildTargetInfo &bti) {
|
|
||||||
return buildSystemTargets.contains(bti.buildKey);
|
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
|
// 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
|
// there would be no BuildTargetInfo that could match
|
||||||
if (targetInfo.targetFilePath.isEmpty()) {
|
if (targetInfo.targetFilePath.isEmpty()) {
|
||||||
qCDebug(LOG) << "BuildTargetInfos";
|
qCDebug(LOG) << "BuildTargetInfos";
|
||||||
// if there is only one build target just use it (but be honest that we're deducing)
|
// if there is only one build target just use it (but be honest that we're deducing)
|
||||||
if (buildTargets.size() == 1) {
|
m_deducedConfiguration = true;
|
||||||
targetInfo = buildTargets.first();
|
m_deducedFrom = targetInfo.buildKey;
|
||||||
m_deducedConfiguration = true;
|
|
||||||
m_deducedFrom = targetInfo.buildKey;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const FilePath localExecutable = ensureExeEnding(targetInfo.targetFilePath);
|
const FilePath localExecutable = ensureExeEnding(targetInfo.targetFilePath);
|
||||||
|
Reference in New Issue
Block a user