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 <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2020-09-17 11:17:03 +02:00
parent 18be09f55a
commit b74ec903a7

View File

@@ -27,6 +27,7 @@
#include "../testtreeitem.h"
#include <utils/fileutils.h>
#include <utils/qtcassert.h>
#include <QFileInfo>
@@ -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());