aboutsummaryrefslogtreecommitdiffstats
path: root/src/gtest.cc
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2010-01-28 21:50:29 +0000
committerzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2010-01-28 21:50:29 +0000
commit81e1cc73c83265e54b2ec7edc17e77f4d1b89e86 (patch)
tree29625437b9179b51a87fa77745ec093d50e8f1b7 /src/gtest.cc
parentfd6f2a8a4b3fe8beb31f26b774b460727c410b66 (diff)
downloadgoogletest-81e1cc73c83265e54b2ec7edc17e77f4d1b89e86.tar.gz
googletest-81e1cc73c83265e54b2ec7edc17e77f4d1b89e86.tar.bz2
googletest-81e1cc73c83265e54b2ec7edc17e77f4d1b89e86.zip
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).
Diffstat (limited to 'src/gtest.cc')
-rw-r--r--src/gtest.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/gtest.cc b/src/gtest.cc
index f5de645b..fb5bae94 100644
--- a/src/gtest.cc
+++ b/src/gtest.cc
@@ -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