From e9f4b319a6c6d54d69f1598fd1c727eb2f6a0f7e Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Mon, 8 Jan 2024 16:06:19 +0100 Subject: [PATCH] AutoTest: Fix location parsing for Qt Test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are multiple ways to print the location depending on the OS the test is executed on. Do not "parse" again the location string, but use named captures instead as they are present anyhow. Former approach would return no location in case the location would be printed like /path/to/file:10 which might be used on UNIX. Task-number: QTCREATORBUG-30143 Change-Id: If48bd0d9d9d8121522a44dfa69a15a0ccabde708 Reviewed-by: David Schulz Reviewed-by: André Hartmann --- .../autotest/qtest/qttestoutputreader.cpp | 16 ++++++---------- src/plugins/autotest/qtest/qttestoutputreader.h | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/plugins/autotest/qtest/qttestoutputreader.cpp b/src/plugins/autotest/qtest/qttestoutputreader.cpp index 2f309da5f37..1d1b1503818 100644 --- a/src/plugins/autotest/qtest/qttestoutputreader.cpp +++ b/src/plugins/autotest/qtest/qttestoutputreader.cpp @@ -351,9 +351,9 @@ void QtTestOutputReader::processPlainTextOutput(const QByteArray &outputLine) if (hasMatch(result)) { processResultOutput(match.captured(1).toLower().trimmed(), match.captured(2)); } else if (hasMatch(locationUnix)) { - processLocationOutput(match.captured(1)); + processLocationOutput(match.captured("file"), match.captured("line")); } else if (hasMatch(locationWin)) { - processLocationOutput(match.captured(1)); + processLocationOutput(match.captured("file"), match.captured("line")); } else if (hasMatch(benchDetails)) { m_description = match.captured(1); } else if (hasMatch(config)) { @@ -412,15 +412,11 @@ void QtTestOutputReader::processResultOutput(const QString &result, const QStrin m_formerTestCase = m_testCase; } -void QtTestOutputReader::processLocationOutput(const QString &fileWithLine) +void QtTestOutputReader::processLocationOutput(const QStringView file, const QStringView line) { - QTC_ASSERT(fileWithLine.endsWith(')'), return); - int openBrace = fileWithLine.lastIndexOf('('); - QTC_ASSERT(openBrace != -1, return); - m_file = constructSourceFilePath(m_buildDir, fileWithLine.left(openBrace)); - QString numberStr = fileWithLine.mid(openBrace + 1); - numberStr.chop(1); - m_lineNumber = numberStr.toInt(); + QTC_ASSERT(!file.isEmpty(), return); + m_file = constructSourceFilePath(m_buildDir, file.toString()); + m_lineNumber = line.toInt(); } void QtTestOutputReader::processSummaryFinishOutput() diff --git a/src/plugins/autotest/qtest/qttestoutputreader.h b/src/plugins/autotest/qtest/qttestoutputreader.h index 0962c8d6845..d09f3d56116 100644 --- a/src/plugins/autotest/qtest/qttestoutputreader.h +++ b/src/plugins/autotest/qtest/qttestoutputreader.h @@ -33,7 +33,7 @@ private: void processXMLOutput(const QByteArray &outputLine); void processPlainTextOutput(const QByteArray &outputLine); void processResultOutput(const QString &result, const QString &message); - void processLocationOutput(const QString &fileWithLine); + void processLocationOutput(const QStringView file, const QStringView line); void processSummaryFinishOutput(); // helper functions void sendCompleteInformation();