AutoTest: Use single build target as fallback

If we cannot find the respective build target to execute
tests, but we only have a single build target then
we now assume that this will be the right one.

Change-Id: I0f7c3c4f371bce3a7f328e7c28dc61cadf7f6e9e
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
This commit is contained in:
Christian Stenger
2017-09-13 11:03:29 +02:00
parent 3c602b32d4
commit 090dea66ee

View File

@@ -90,7 +90,7 @@ void TestConfiguration::completeTestInformation(TestRunMode runMode)
const QSet<QString> buildSystemTargets = m_buildTargets;
qCDebug(LOG) << "BuildSystemTargets\n " << buildSystemTargets;
const BuildTargetInfo targetInfo
BuildTargetInfo targetInfo
= Utils::findOrDefault(target->applicationTargets().list,
[&buildSystemTargets] (const BuildTargetInfo &bti) {
return Utils::anyOf(buildSystemTargets, [&bti](const QString &b) {
@@ -101,11 +101,19 @@ void TestConfiguration::completeTestInformation(TestRunMode runMode)
&& targWithProjectFile.at(1).startsWith(bti.projectFilePath.toString());
});
});
if (!QTC_GUARD(!targetInfo.targetFilePath.isEmpty())) { // empty if BTI default created
// 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";
for (const BuildTargetInfo &bti : target->applicationTargets().list)
qCDebug(LOG) << " " << bti.targetName << bti.projectFilePath << bti.targetFilePath;
const QList<BuildTargetInfo> buildTargets = target->applicationTargets().list;
// if there is only one build target just use it (but be honest that we're guessing)
if (buildTargets.size() == 1) {
targetInfo = buildTargets.first();
m_guessedConfiguration = true;
m_guessedFrom = targetInfo.targetName;
}
}
const QString localExecutable = ensureExeEnding(targetInfo.targetFilePath.toString());
QString buildBase;