path: root/src/testlib
diff options
authorJoerg Bornemann <>2017-08-23 12:28:51 +0200
committerJoerg Bornemann <>2017-08-28 11:01:17 +0000
commit1bb70830d4ea030c4ce2d41be3e31a9c05c6b976 (patch)
treedf99b1e8344553983c00f4c920aeaafb3a3378e1 /src/testlib
parentf1a857c079e11c8e298ec8f2dafef49039f8ca40 (diff)
Make it possible to override QT_LOGGING_TO_CONSOLE in test cases
It is currently impossible to get output from autotests in Visual Studio or Qt Creator when running under the debugger. Qt Creator's cdb integration cannot distinguish between the inferior's console output and cdb's console output. If the inferior's output came from OutputDebugString we'd be able to catch and display it. Pave a way to force QTestLib's logging facility use OutputDebugString. Task-number: QTCREATORBUG-16161 Change-Id: Iccd69c283626266ee4384a6163a8b72bb0e7df27 Reviewed-by: hjk <> Reviewed-by: Thiago Macieira <> Reviewed-by: Simon Hausmann <>
Diffstat (limited to 'src/testlib')
1 files changed, 7 insertions, 1 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index 8b0820b941..74a5d0ac19 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -1652,9 +1652,15 @@ static LONG WINAPI windowsFaultHandler(struct _EXCEPTION_POINTERS *exInfo)
#endif // Q_OS_WIN) && !Q_OS_WINRT
+static void qputenvIfEmpty(const char *name, const QByteArray &value)
+ if (qEnvironmentVariableIsEmpty(name))
+ qputenv(name, value);
static void initEnvironment()
- qputenv("QT_LOGGING_TO_CONSOLE", "1");
+ qputenvIfEmpty("QT_LOGGING_TO_CONSOLE", "1");
qputenv("QT_QTESTLIB_RUNNING", "1");