From 1bb70830d4ea030c4ce2d41be3e31a9c05c6b976 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 23 Aug 2017 12:28:51 +0200 Subject: 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 --- src/testlib/qtestcase.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/testlib') 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"); } -- cgit v1.2.3