From 6b7a167dca7a9007d14fc95a07f4f6e07fec3162 Mon Sep 17 00:00:00 2001 From: "zhanyong.wan" Date: Mon, 11 Mar 2013 17:52:13 +0000 Subject: [PATCH] Supports colored output on term type screen-256color. Proposed as a one-line patch by Tom Jakubowski (tom@crystae.net); finished by Zhanyong Wan. --- src/gtest.cc | 3 ++- test/gtest_unittest.cc | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gtest.cc b/src/gtest.cc index 62b69291..911919d8 100644 --- a/src/gtest.cc +++ b/src/gtest.cc @@ -204,7 +204,7 @@ GTEST_DEFINE_string_( "Whether to use colors in the output. Valid values: yes, no, " "and auto. 'auto' means to use colors if the output is " "being sent to a terminal and the TERM environment variable " - "is set to xterm, xterm-color, xterm-256color, linux or cygwin."); + "is set to a terminal type that supports colors."); GTEST_DEFINE_string_( filter, @@ -2497,6 +2497,7 @@ bool ShouldUseColor(bool stdout_is_tty) { String::CStringEquals(term, "xterm-color") || String::CStringEquals(term, "xterm-256color") || String::CStringEquals(term, "screen") || + String::CStringEquals(term, "screen-256color") || String::CStringEquals(term, "linux") || String::CStringEquals(term, "cygwin"); return stdout_is_tty && term_supports_color; diff --git a/test/gtest_unittest.cc b/test/gtest_unittest.cc index f594a447..769b75c3 100644 --- a/test/gtest_unittest.cc +++ b/test/gtest_unittest.cc @@ -6429,6 +6429,9 @@ TEST(ColoredOutputTest, UsesColorsWhenTermSupportsColors) { SetEnv("TERM", "screen"); // TERM supports colors. EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY. + SetEnv("TERM", "screen-256color"); // TERM supports colors. + EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY. + SetEnv("TERM", "linux"); // TERM supports colors. EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY.