Windows: Do not print test output to both stdout and system debug log
Avoid piping the test output to both the Windows system debugger, and stdout. This fixes duplicate output in Qt Creator, which displays messages from both sources. [ChangeLog][QtTestLib] The (default) plain text logger on Windows now logs to either the system debug log (in case no console is open), or stdout, not both. Task-number: QTBUG-34630 Change-Id: I35fe9f4a50cc660d79fad7dffa6d19659b2102ae Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
parent
e1330ecfdc
commit
7fab8eb56b
@ -102,7 +102,7 @@ static inline bool hasStdErr()
|
||||
}
|
||||
# endif // !Q_OS_WINCE && !Q_OS_WINRT
|
||||
|
||||
bool qWinLogToStderr()
|
||||
Q_CORE_EXPORT bool qWinLogToStderr()
|
||||
{
|
||||
# if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
|
||||
static const bool result = hasStdErr();
|
||||
|
@ -197,6 +197,10 @@ namespace QTest {
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
Q_CORE_EXPORT bool qWinLogToStderr(); // defined in qlogging.cpp
|
||||
#endif
|
||||
|
||||
void QPlainTestLogger::outputMessage(const char *str)
|
||||
{
|
||||
#if defined(Q_OS_WINCE)
|
||||
@ -209,7 +213,11 @@ void QPlainTestLogger::outputMessage(const char *str)
|
||||
} while (!strUtf16.isEmpty());
|
||||
if (stream != stdout)
|
||||
#elif defined(Q_OS_WIN)
|
||||
OutputDebugStringA(str);
|
||||
// log to system log only if output is not redirected, and no console is attached
|
||||
if (!qWinLogToStderr() && stream == stdout) {
|
||||
OutputDebugStringA(str);
|
||||
return;
|
||||
}
|
||||
#elif defined(Q_OS_ANDROID)
|
||||
__android_log_write(ANDROID_LOG_INFO, "QTestLib", str);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user