summaryrefslogtreecommitdiffstats
path: root/src/testlib/qabstracttestlogger.cpp
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2018-03-08 13:19:18 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2018-03-09 16:31:53 +0000
commit73b2dd49c2396ab6a2b8ee31385119ec41257920 (patch)
tree030ac6d829c55766b38e749f391b6e1c31adc893 /src/testlib/qabstracttestlogger.cpp
parentbc008afb0e3724a89890e9bd68451b1903bc8e17 (diff)
testlib: Feed test log messages to Apple Unified Logging
QtTestLib uses its own message handler for plain text logging, so it doesn't go though the logic in qDefaultMessageHandler that dispatches logging to alternate logging sinks. Building on the approach of Android and Windows, we log to AUL from the plain text logger. A future improvement in this area would be to make QtTestLib make more use of the infrastructure in qlogging.cpp, but this is a bigger task and requires a better overview of the requirements. The AUL code has been isolated into a wrapper, to allow logging both to AUl and to e.g. the QPlainTextLogger. This is needed so that we short circuit the plain text logger in case AUL already has handled printing to stderr. Change-Id: Iee0c3902190bd081b7ffbaf77c41b3118ce7f6da Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/testlib/qabstracttestlogger.cpp')
-rw-r--r--src/testlib/qabstracttestlogger.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/testlib/qabstracttestlogger.cpp b/src/testlib/qabstracttestlogger.cpp
index 63c165b9dc..2b54cd410b 100644
--- a/src/testlib/qabstracttestlogger.cpp
+++ b/src/testlib/qabstracttestlogger.cpp
@@ -39,6 +39,7 @@
#include <QtTest/private/qabstracttestlogger_p.h>
#include <QtTest/qtestassert.h>
+#include <qtestresult_p.h>
#include <QtCore/qbytearray.h>
#include <QtCore/qstring.h>
@@ -189,4 +190,26 @@ int qt_asprintf(QTestCharBuffer *str, const char *format, ...)
}
+namespace QTestPrivate
+{
+
+void generateTestIdentifier(QTestCharBuffer *identifier, int parts)
+{
+ const char *testObject = parts & TestObject ? QTestResult::currentTestObjectName() : "";
+ const char *testFunction = parts & TestFunction ? (QTestResult::currentTestFunction() ? QTestResult::currentTestFunction() : "UnknownTestFunc") : "";
+ const char *objectFunctionFiller = parts & TestObject && parts & (TestFunction | TestDataTag) ? "::" : "";
+ const char *testFuctionStart = parts & TestFunction ? "(" : "";
+ const char *testFuctionEnd = parts & TestFunction ? ")" : "";
+
+ const char *dataTag = (parts & TestDataTag) && QTestResult::currentDataTag() ? QTestResult::currentDataTag() : "";
+ const char *globalDataTag = (parts & TestDataTag) && QTestResult::currentGlobalDataTag() ? QTestResult::currentGlobalDataTag() : "";
+ const char *tagFiller = (dataTag[0] && globalDataTag[0]) ? ":" : "";
+
+ QTest::qt_asprintf(identifier, "%s%s%s%s%s%s%s%s",
+ testObject, objectFunctionFiller, testFunction, testFuctionStart,
+ globalDataTag, tagFiller, dataTag, testFuctionEnd);
+}
+
+}
+
QT_END_NAMESPACE