summaryrefslogtreecommitdiffstats
path: root/src/testlib/qappletestlogger.cpp
diff options
context:
space:
mode:
authorAxel Spoerl <axel.spoerl@qt.io>2023-11-21 12:29:18 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2024-01-22 15:51:21 +0100
commit08ddf846aed3a14c485aa1d68bc3157e2420f316 (patch)
treed9d4e6f6c63cb624fb4fe8b96d729c570230f590 /src/testlib/qappletestlogger.cpp
parent091096fed7c69b8c61b313dc1b3b6fe40d42e0b4 (diff)
QAppleTestLogger: Add source link to failure messages
The apple test logger did not include the failure location in the log output, because the assumption was that the structured logging would report the file and line separately. Unfortunately we can't do that using the os_log machinery just yet, so we bring in the manual location printing as in the plain text logger. Pick-to: 6.7 Change-Id: Ief0a6a6e04d628c98ed09c09334b694504cbff2c Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/testlib/qappletestlogger.cpp')
-rw-r--r--src/testlib/qappletestlogger.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/testlib/qappletestlogger.cpp b/src/testlib/qappletestlogger.cpp
index 43968e7ebe..7517a95344 100644
--- a/src/testlib/qappletestlogger.cpp
+++ b/src/testlib/qappletestlogger.cpp
@@ -104,6 +104,14 @@ void QAppleTestLogger::addIncident(IncidentTypes type, const char *description,
if (qstrlen(description))
message += u'\n' % QString::fromLatin1(description);
+ // As long as the Apple logger doesn't propagate the context's file and
+ // line number we need to manually print it.
+ if (context.line && context.file) {
+ QTestCharBuffer line;
+ QTest::qt_asprintf(&line, "\n [Loc: %s:%d]", context.file, context.line);
+ message += QLatin1String(line.data());
+ }
+
AppleUnifiedLogger::messageHandler(messageData.messageType, context, message, subsystem());
}