CMakePM: Widen ctest detection

If tests are not set up using add_test() but are supported
by ctest due to a different registering mechanism we failed
to get these right.
Expect also tests configured differently and just omit the
respective file information.

Fixes: QTCREATORBUG-25847
Change-Id: I16fcbec1a3a262f7d77ffdf15e4114e5a15e3757
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2021-06-10 13:34:10 +02:00
parent d0c32df3fe
commit caf515929b

View File

@@ -951,14 +951,19 @@ void CMakeBuildSystem::runCTest()
++counter;
const QJsonObject test = testVal.toObject();
QTC_ASSERT(!test.isEmpty(), continue);
int file = -1;
int line = -1;
const int bt = test.value("backtrace").toInt(-1);
QTC_ASSERT(bt != -1, continue);
// we may have no real backtrace due to different registering
if (bt != -1) {
const QJsonObject btRef = nodes.at(bt).toObject();
int file = btRef.value("file").toInt(-1);
int line = btRef.value("line").toInt(-1);
QTC_ASSERT(file != -1 && line != -1, continue);
m_testNames.append({ test.value("name").toString(), counter,
FilePath::fromString(cmakelists.at(file).toString()), line });
file = btRef.value("file").toInt(-1);
line = btRef.value("line").toInt(-1);
}
// we may have no CMakeLists.txt file reference due to different registering
const FilePath cmakeFile = file != -1
? FilePath::fromString(cmakelists.at(file).toString()) : FilePath();
m_testNames.append({ test.value("name").toString(), counter, cmakeFile, line });
}
}
}