diff options
author | Christian Stenger <christian.stenger@qt.io> | 2024-01-08 16:06:19 +0100 |
---|---|---|
committer | Christian Stenger <christian.stenger@qt.io> | 2024-01-11 05:39:03 +0000 |
commit | e9f4b319a6c6d54d69f1598fd1c727eb2f6a0f7e (patch) | |
tree | b306ce694a1558fb2ae1673d5d7881481112911e /src/plugins/autotest | |
parent | 981a0160a2be28f3dcb82d65bc57e4b491281e63 (diff) |
AutoTest: Fix location parsing for Qt Test
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 <david.schulz@qt.io>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Diffstat (limited to 'src/plugins/autotest')
-rw-r--r-- | src/plugins/autotest/qtest/qttestoutputreader.cpp | 16 | ||||
-rw-r--r-- | 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(); |