AutoTest: Fix file path construction again

b74ec90 fixed the cmake part, but broke the rest.
Redo the file path construction to make it work with
qmake, qbs and cmake on Windows when using Catch2.

Change-Id: Ic41e015458ccf750421c29b1a200115c13db3ccf
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2020-09-24 10:48:31 +02:00
parent c74714da04
commit 7bba76d0ff

View File

@@ -173,12 +173,12 @@ TestResultPtr CatchOutputReader::createDefaultResult() const
result = new CatchResult(id(), m_testCaseInfo.first().name); result = new CatchResult(id(), m_testCaseInfo.first().name);
result->setDescription(m_testCaseInfo.last().name); result->setDescription(m_testCaseInfo.last().name);
result->setLine(m_testCaseInfo.last().line); result->setLine(m_testCaseInfo.last().line);
const QFileInfo fileInfo(m_testCaseInfo.last().filename); const QString givenPath = m_testCaseInfo.last().filename;
const Utils::FilePath filePath = Utils::FilePath::fromFileInfo(fileInfo); const Utils::FilePath filePath = Utils::FilePath::fromFileInfo(QFileInfo(givenPath));
if (!filePath.isEmpty()) { if (!givenPath.isEmpty()) {
result->setFileName(fileInfo.isAbsolute() result->setFileName(QDir::isAbsolutePath(givenPath)
? filePath.toString() ? filePath.toString()
: QFileInfo(m_buildDir + '/' + filePath.toString()).canonicalFilePath()); : QFileInfo(m_buildDir + '/' + givenPath).canonicalFilePath());
} }
} else { } else {
result = new CatchResult(id(), QString()); result = new CatchResult(id(), QString());