diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2018-03-08 13:19:18 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2018-03-09 16:31:53 +0000 |
commit | 73b2dd49c2396ab6a2b8ee31385119ec41257920 (patch) | |
tree | 030ac6d829c55766b38e749f391b6e1c31adc893 /src/testlib/qplaintestlogger.cpp | |
parent | bc008afb0e3724a89890e9bd68451b1903bc8e17 (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/qplaintestlogger.cpp')
-rw-r--r-- | src/testlib/qplaintestlogger.cpp | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp index e5226b7820..853515f2d9 100644 --- a/src/testlib/qplaintestlogger.cpp +++ b/src/testlib/qplaintestlogger.cpp @@ -221,18 +221,6 @@ void QPlainTestLogger::outputMessage(const char *str) outputString(str); } -static void testIdentifier(QTestCharBuffer *identifier) -{ - const char *testObject = QTestResult::currentTestObjectName(); - const char *testFunction = QTestResult::currentTestFunction() ? QTestResult::currentTestFunction() : "UnknownTestFunc"; - - const char *dataTag = QTestResult::currentDataTag() ? QTestResult::currentDataTag() : ""; - const char *globalDataTag = QTestResult::currentGlobalDataTag() ? QTestResult::currentGlobalDataTag() : ""; - const char *tagFiller = (dataTag[0] && globalDataTag[0]) ? ":" : ""; - - QTest::qt_asprintf(identifier, "%s::%s(%s%s%s)", testObject, testFunction, globalDataTag, tagFiller, dataTag); -} - void QPlainTestLogger::printMessage(const char *type, const char *msg, const char *file, int line) { QTEST_ASSERT(type); @@ -251,10 +239,10 @@ void QPlainTestLogger::printMessage(const char *type, const char *msg, const cha } const char *msgFiller = msg[0] ? " " : ""; - QTestCharBuffer testIdent; - testIdentifier(&testIdent); + QTestCharBuffer testIdentifier; + QTestPrivate::generateTestIdentifier(&testIdentifier); QTest::qt_asprintf(&messagePrefix, "%s: %s%s%s%s\n", - type, testIdent.data(), msgFiller, msg, failureLocation.data()); + type, testIdentifier.data(), msgFiller, msg, failureLocation.data()); // In colored mode, printf above stripped our nonprintable control characters. // Put them back. |