summaryrefslogtreecommitdiffstats
path: root/src/testlib/qappletestlogger.cpp
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2019-01-17 16:03:03 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2019-03-05 22:29:57 +0000
commit18da1dac20c7d27342e987586a16d125e39197c9 (patch)
tree099503358097e5dfadebfbcfdeabb75cc6b26121 /src/testlib/qappletestlogger.cpp
parent83864b315ff48bca33c39e1bdc03e522f68214fd (diff)
testlib: Prevent Apple test logger from stomping on other loggers
We were potentially adding the Apple test logger multiple times, and we didn't consider whether the existing loggers were logging to file or not when circumventing them. We now don't use the Apple logger if it would touch stderr and some other logger is using stdout. In the case of no explicit logger being specified on the command line, we allow the Apple logger to take priority over the default plain test logger. Change-Id: I31bbec4f4b3ab84ba9a2be35e8e5db08fee071a7 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/testlib/qappletestlogger.cpp')
-rw-r--r--src/testlib/qappletestlogger.cpp20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/testlib/qappletestlogger.cpp b/src/testlib/qappletestlogger.cpp
index 8e75da88f8..959ff6cf64 100644
--- a/src/testlib/qappletestlogger.cpp
+++ b/src/testlib/qappletestlogger.cpp
@@ -55,9 +55,8 @@ bool QAppleTestLogger::debugLoggingEnabled()
return os_log_type_enabled(OS_LOG_DEFAULT, OS_LOG_TYPE_DEBUG);
}
-QAppleTestLogger::QAppleTestLogger(QAbstractTestLogger *logger)
+QAppleTestLogger::QAppleTestLogger()
: QAbstractTestLogger(nullptr)
- , m_logger(logger)
{
}
@@ -65,6 +64,8 @@ static QAppleLogActivity testFunctionActivity;
void QAppleTestLogger::enterTestFunction(const char *function)
{
+ Q_UNUSED(function);
+
// Re-create activity each time
testFunctionActivity = QT_APPLE_LOG_ACTIVITY("Running test function").enter();
@@ -73,15 +74,12 @@ void QAppleTestLogger::enterTestFunction(const char *function)
QString identifier = QString::fromLatin1(testIdentifier.data());
QMessageLogContext context(nullptr, 0, nullptr, "qt.test.enter");
QString message = identifier;
- if (AppleUnifiedLogger::messageHandler(QtDebugMsg, context, message, identifier))
- return; // AUL already printed to stderr
- m_logger->enterTestFunction(function);
+ AppleUnifiedLogger::messageHandler(QtDebugMsg, context, message, identifier);
}
void QAppleTestLogger::leaveTestFunction()
{
- m_logger->leaveTestFunction();
testFunctionActivity.leave();
}
@@ -134,18 +132,12 @@ void QAppleTestLogger::addIncident(IncidentTypes type, const char *description,
if (qstrlen(description))
message += QLatin1Char('\n') % QString::fromLatin1(description);
- if (AppleUnifiedLogger::messageHandler(incidentClassification.first, context, message, subsystem))
- return; // AUL already printed to stderr
-
- m_logger->addIncident(type, description, file, line);
+ AppleUnifiedLogger::messageHandler(incidentClassification.first, context, message, subsystem);
}
void QAppleTestLogger::addMessage(QtMsgType type, const QMessageLogContext &context, const QString &message)
{
- if (AppleUnifiedLogger::messageHandler(type, context, message))
- return; // AUL already printed to stderr
-
- m_logger->addMessage(type, context, message);
+ AppleUnifiedLogger::messageHandler(type, context, message);
}
#endif // QT_USE_APPLE_UNIFIED_LOGGING