summaryrefslogtreecommitdiffstats
path: root/src/util_test.cc
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2012-01-19 00:09:16 (GMT)
committerNico Weber <thakis@chromium.org>2012-01-19 00:09:16 (GMT)
commita2c4b6780dcf105821e4f2ec1f0b591adbeb6dca (patch)
treea62348131d053354b7d8d5fb1c3ca5b3d5527d67 /src/util_test.cc
parent63013b3bd5ca79d454a95a6f985d98f16f21da1c (diff)
downloadNinja-a2c4b6780dcf105821e4f2ec1f0b591adbeb6dca.zip
Ninja-a2c4b6780dcf105821e4f2ec1f0b591adbeb6dca.tar.gz
Ninja-a2c4b6780dcf105821e4f2ec1f0b591adbeb6dca.tar.bz2
Strip ansi escape sequences from subcommand output when not writing to a smart terminal.
Diffstat (limited to 'src/util_test.cc')
-rw-r--r--src/util_test.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/util_test.cc b/src/util_test.cc
index 8c3d023..c44ab77 100644
--- a/src/util_test.cc
+++ b/src/util_test.cc
@@ -73,3 +73,20 @@ TEST(CanonicalizePath, AbsolutePath) {
EXPECT_TRUE(CanonicalizePath(&path, &err));
EXPECT_EQ("/usr/include/stdio.h", path);
}
+
+TEST(StripAnsiEscapeCodes, EscapeAtEnd) {
+ string stripped = StripAnsiEscapeCodes("foo\33");
+ EXPECT_EQ("foo", stripped);
+
+ stripped = StripAnsiEscapeCodes("foo\33[");
+ EXPECT_EQ("foo", stripped);
+}
+
+TEST(StripAnsiEscapeCodes, StripColors) {
+ // An actual clang warning.
+ string input = "\33[1maffixmgr.cxx:286:15: \33[0m\33[0;1;35mwarning: "
+ "\33[0m\33[1musing the result... [-Wparentheses]\33[0m";
+ string stripped = StripAnsiEscapeCodes(input);
+ EXPECT_EQ("affixmgr.cxx:286:15: warning: using the result... [-Wparentheses]",
+ stripped);
+}