Introduces macro GTEST_HAS_STREAM_REDIRECTION_ (by Vlad Losev); fixes unsynchronized color text output on Windows (by Vlad Losev); fixes the cmake script to work with MSVC 10 (by Manuel Klimek).
This commit is contained in:
@@ -441,8 +441,7 @@ GTestLog::~GTestLog() {
|
||||
#pragma warning(disable: 4996)
|
||||
#endif // _MSC_VER
|
||||
|
||||
// Stream capturing is not supported on Windows Mobile.
|
||||
#if !GTEST_OS_WINDOWS_MOBILE
|
||||
#if GTEST_HAS_STREAM_REDIRECTION_
|
||||
|
||||
// Object that captures an output stream (stdout/stderr).
|
||||
class CapturedStream {
|
||||
@@ -575,7 +574,7 @@ String GetCapturedStdout() { return GetCapturedStream(&g_captured_stdout); }
|
||||
// Stops capturing stderr and returns the captured string.
|
||||
String GetCapturedStderr() { return GetCapturedStream(&g_captured_stderr); }
|
||||
|
||||
#endif // !GTEST_OS_WINDOWS_MOBILE
|
||||
#endif // GTEST_HAS_STREAM_REDIRECTION_
|
||||
|
||||
#if GTEST_HAS_DEATH_TEST
|
||||
|
||||
|
||||
@@ -2631,13 +2631,15 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) {
|
||||
GetConsoleScreenBufferInfo(stdout_handle, &buffer_info);
|
||||
const WORD old_color_attrs = buffer_info.wAttributes;
|
||||
|
||||
// We need to flush the stream buffers into the console before each
|
||||
// SetConsoleTextAttribute call lest it affect the text that is already
|
||||
// printed but has not yet reached the console.
|
||||
fflush(stdout);
|
||||
SetConsoleTextAttribute(stdout_handle,
|
||||
GetColorAttribute(color) | FOREGROUND_INTENSITY);
|
||||
vprintf(fmt, args);
|
||||
// Unless we flush stream buffers now the next SetConsoleTextAttribute
|
||||
// call can reset the color before the output reaches the console.
|
||||
fflush(stdout);
|
||||
|
||||
fflush(stdout);
|
||||
// Restores the text color.
|
||||
SetConsoleTextAttribute(stdout_handle, old_color_attrs);
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user