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 <hjk@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
Joerg Bornemann 2017-08-23 12:28:51 +02:00
parent f1a857c079
commit 1bb70830d4

View File

@ -1652,9 +1652,15 @@ static LONG WINAPI windowsFaultHandler(struct _EXCEPTION_POINTERS *exInfo)
} }
#endif // Q_OS_WIN) && !Q_OS_WINRT #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() static void initEnvironment()
{ {
qputenv("QT_LOGGING_TO_CONSOLE", "1"); qputenvIfEmpty("QT_LOGGING_TO_CONSOLE", "1");
qputenv("QT_QTESTLIB_RUNNING", "1"); qputenv("QT_QTESTLIB_RUNNING", "1");
} }