AutoTest: Fix constructing of source file path

Changes in Utils::FilePath need some adjustments to fix the
expected behavior.

Fixes: QTCREATORBUG-25979
Change-Id: Ife35a68458db9ae7c08637687a3fc9acd7d058e9
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2021-07-08 13:23:44 +02:00
parent 7b7fb9f6c7
commit f922d22ad4
2 changed files with 7 additions and 9 deletions

View File

@@ -179,7 +179,7 @@ void GTestOutputReader::processOutputLine(const QByteArray &outputLine)
testResult->setResult(type); testResult->setResult(type);
testResult->setLine(match.captured(3).toInt()); testResult->setLine(match.captured(3).toInt());
const Utils::FilePath file = constructSourceFilePath(m_buildDir, match.captured(2)); const Utils::FilePath file = constructSourceFilePath(m_buildDir, match.captured(2));
if (!file.isEmpty()) if (file.exists())
testResult->setFileName(file); testResult->setFileName(file);
testResult->setDescription(match.captured(4)); testResult->setDescription(match.captured(4));
reportResult(testResult); reportResult(testResult);
@@ -247,7 +247,7 @@ void GTestOutputReader::handleDescriptionAndReportResult(TestResultPtr testResul
testResult->setResult(ResultType::MessageLocation); testResult->setResult(ResultType::MessageLocation);
testResult->setLine(innerMatch.captured(2).toInt()); testResult->setLine(innerMatch.captured(2).toInt());
const Utils::FilePath file = constructSourceFilePath(m_buildDir, innerMatch.captured(1)); const Utils::FilePath file = constructSourceFilePath(m_buildDir, innerMatch.captured(1));
if (!file.isEmpty()) if (file.exists())
testResult->setFileName(file); testResult->setFileName(file);
resultDescription << output; resultDescription << output;
} }

View File

@@ -39,11 +39,10 @@
namespace Autotest { namespace Autotest {
Utils::FilePath TestOutputReader::constructSourceFilePath(const Utils::FilePath &path, Utils::FilePath TestOutputReader::constructSourceFilePath(const Utils::FilePath &path,
const QString &filePath) const QString &file)
{ {
if (!filePath.isEmpty() && filePath.at(0) != '.') const Utils::FilePath filePath = path.resolvePath(file);
return Utils::FilePath::fromFileInfo(QFileInfo(filePath)); return filePath.exists() ? filePath : Utils::FilePath();
return (path / filePath).canonicalPath();
} }
TestOutputReader::TestOutputReader(const QFutureInterface<TestResultPtr> &futureInterface, TestOutputReader::TestOutputReader(const QFutureInterface<TestResultPtr> &futureInterface,
@@ -177,9 +176,8 @@ void TestOutputReader::checkForSanitizerOutput(const QByteArray &line)
if (m_sanitizerOutputMode == SanitizerOutputMode::Ubsan) { if (m_sanitizerOutputMode == SanitizerOutputMode::Ubsan) {
const Utils::FilePath path = constructSourceFilePath(m_buildDir, match.captured(1)); const Utils::FilePath path = constructSourceFilePath(m_buildDir, match.captured(1));
// path may be empty if not existing - so, provide at least what we have // path may be empty if not existing - so, provide at least what we have
m_sanitizerResult->setFileName(path.isEmpty() m_sanitizerResult->setFileName(
? Utils::FilePath::fromString(match.captured(1)) path.exists() ? path : Utils::FilePath::fromString(match.captured(1)));
: path);
m_sanitizerResult->setLine(match.captured(2).toInt()); m_sanitizerResult->setLine(match.captured(2).toInt());
} }
} }