diff options
| author | Liang Qi <liang.qi@qt.io> | 2019-03-06 12:31:50 +0100 |
|---|---|---|
| committer | Liang Qi <liang.qi@qt.io> | 2019-03-06 12:31:50 +0100 |
| commit | 2add2dbdaa9ff6ca6637ca22d6a9b7c7027751be (patch) | |
| tree | 585628b0ceacfbdef5b9661c4043b9f71dfe9b01 /src/testlib/qtestcase.cpp | |
| parent | f792fed2ff519ffac1436e41e47cc0504d253a77 (diff) | |
| parent | 4eda22ea0db1fc571ae9f44a68825056e6245548 (diff) | |
Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts:
src/network/access/http2/hpacktable_p.h
Change-Id: Ie0c296667dfdebba84f4858056a1ac80c24ee7df
Diffstat (limited to 'src/testlib/qtestcase.cpp')
| -rw-r--r-- | src/testlib/qtestcase.cpp | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 3ee8094ddf8..8d109113c4d 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -78,6 +78,10 @@ #include <QtTest/private/qtestutil_macos_p.h> #endif +#if defined(Q_OS_DARWIN) +#include <QtTest/private/qappletestlogger_p.h> +#endif + #include <cmath> #include <numeric> #include <algorithm> @@ -511,7 +515,7 @@ static int qToInt(const char *str) Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, const char *const argv[], bool qml) { - QTestLog::LogMode logFormat = QTestLog::Plain; + int logFormat = -1; // Not set const char *logFilename = 0; QTest::testFunctions.clear(); @@ -679,7 +683,7 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, const char *const argv[], bool fprintf(stderr, "only one logger can log to stdout\n"); exit(1); } - QTestLog::addLogger(logFormat, filename); + QTestLog::addLogger(QTestLog::LogMode(logFormat), filename); } delete [] filename; delete [] format; @@ -841,10 +845,25 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, const char *const argv[], bool QTestLog::setInstalledTestCoverage(installedTestCoverage); // If no loggers were created by the long version of the -o command-line - // option, create a logger using whatever filename and format were - // set using the old-style command-line options. - if (QTestLog::loggerCount() == 0) - QTestLog::addLogger(logFormat, logFilename); + // option, but a logger was requested via the old-style option, add it. + const bool explicitLoggerRequested = logFormat != -1; + if (QTestLog::loggerCount() == 0 && explicitLoggerRequested) + QTestLog::addLogger(QTestLog::LogMode(logFormat), logFilename); + + bool addFallbackLogger = !explicitLoggerRequested; + +#if defined(QT_USE_APPLE_UNIFIED_LOGGING) + // Any explicitly requested loggers will be added by now, so we can check if they use stdout + const bool safeToAddAppleLogger = !AppleUnifiedLogger::willMirrorToStderr() || !QTestLog::loggerUsingStdout(); + if (safeToAddAppleLogger && QAppleTestLogger::debugLoggingEnabled()) { + QTestLog::addLogger(QTestLog::Apple, nullptr); + if (AppleUnifiedLogger::willMirrorToStderr() && !logFilename) + addFallbackLogger = false; // Prevent plain test logger fallback below + } +#endif + + if (addFallbackLogger) + QTestLog::addLogger(QTestLog::Plain, logFilename); } // Temporary, backwards compatibility, until qtdeclarative's use of it is converted |
