Commit fe5ab8da authored by Christian Stenger's avatar Christian Stenger

AutoTest: Fix retrieval of build system target

If we failed to find a project part for the respective file
it is most likely that we had a header with declarations only
but we can still find depending targets for this file.

Task-number: QTCREATORBUG-18922
Change-Id: I80d0af569bbd6c2a41bf498fb55283704f16439c
Reviewed-by: Nikolai Kosjar's avatarNikolai Kosjar <>
parent 094f7120
......@@ -295,7 +295,10 @@ QSet<QString> GTestTreeItem::internalTargets() const
const auto cppMM = CppTools::CppModelManager::instance();
const auto projectInfo = cppMM->projectInfo(ProjectExplorer::SessionManager::startupProject());
const QString file = filePath();
for (const CppTools::ProjectPart::Ptr projectPart : projectInfo.projectParts()) {
const QVector<CppTools::ProjectPart::Ptr> projectParts = projectInfo.projectParts();
if (projectParts.isEmpty())
return TestTreeItem::dependingInternalTargets(cppMM, file);
for (const CppTools::ProjectPart::Ptr projectPart : projectParts) {
if (projectPart->projectFile == proFile()
&& Utils::anyOf(projectPart->files, [&file] (const CppTools::ProjectFile &pf) {
return pf.path == file;
......@@ -288,6 +288,9 @@ QSet<QString> TestTreeItem::internalTargets() const
auto cppMM = CppTools::CppModelManager::instance();
const QList<CppTools::ProjectPart::Ptr> projectParts = cppMM->projectPart(m_filePath);
// if we have no project parts it's most likely a header with declarations only and CMake based
if (projectParts.isEmpty())
return TestTreeItem::dependingInternalTargets(cppMM, m_filePath);
QSet<QString> targets;
for (const CppTools::ProjectPart::Ptr part : projectParts) {
targets.insert(part->buildSystemTarget + '|' + part->projectFile);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment