From b74ec903a700729fbbfe0dbef98ba8ef0788a0ab Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Thu, 17 Sep 2020 11:17:03 +0200 Subject: [PATCH] AutoTest: Fix construction of file paths for catch results Using Catch2 on Windows with CMake lead to not having file information as the file information was generated differently. Change-Id: I3e0951b517a4a8a86f1ffa1009c1a2815565f3b3 Reviewed-by: David Schulz --- src/plugins/autotest/catch/catchoutputreader.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/plugins/autotest/catch/catchoutputreader.cpp b/src/plugins/autotest/catch/catchoutputreader.cpp index 68d4f0b260c..7837cce3f97 100644 --- a/src/plugins/autotest/catch/catchoutputreader.cpp +++ b/src/plugins/autotest/catch/catchoutputreader.cpp @@ -27,6 +27,7 @@ #include "../testtreeitem.h" +#include #include #include @@ -172,10 +173,12 @@ TestResultPtr CatchOutputReader::createDefaultResult() const result = new CatchResult(id(), m_testCaseInfo.first().name); result->setDescription(m_testCaseInfo.last().name); result->setLine(m_testCaseInfo.last().line); - const QString &relativePathFromBuildDir = m_testCaseInfo.last().filename; - if (!relativePathFromBuildDir.isEmpty()) { - const QFileInfo fileInfo(m_buildDir + '/' + relativePathFromBuildDir); - result->setFileName(fileInfo.canonicalFilePath()); + const QFileInfo fileInfo(m_testCaseInfo.last().filename); + const Utils::FilePath filePath = Utils::FilePath::fromFileInfo(fileInfo); + if (!filePath.isEmpty()) { + result->setFileName(fileInfo.isAbsolute() + ? filePath.toString() + : QFileInfo(m_buildDir + '/' + filePath.toString()).canonicalFilePath()); } } else { result = new CatchResult(id(), QString());