From caf515929b08b9d0e432ba0819c61f532d2404bc Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Thu, 10 Jun 2021 13:34:10 +0200 Subject: [PATCH] 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 --- .../cmakeprojectmanager/cmakebuildsystem.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp index ddd12468821..5620c08754a 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp @@ -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 }); } } }