Index: test/libcxx/test/config.py =================================================================== --- test/libcxx/test/config.py +++ test/libcxx/test/config.py @@ -91,6 +91,7 @@ self.configure_env() self.configure_compile_flags() self.configure_link_flags() + self.configure_color_diagnostics() self.configure_debug_mode() self.configure_warnings() self.configure_sanitizer() @@ -469,6 +470,25 @@ else: self.lit_config.fatal("unrecognized system: %r" % target_platform) + def configure_color_diagnostics(self): + use_color = self.get_lit_conf('color_diagnostics') + if use_color is None: + use_color = os.environ.get('LIBCXX_COLOR_DIAGNOSTICS') + if use_color is None: + return + if use_color != '': + self.lit_config.fatal('Invalid value for color_diagnostics "%s".' + % use_color) + cxx_type = self.cxx.type + if cxx_type is None: + self.lit_config.warning( + 'Unable to force color output for unknown compiler "%s"' + % cxx.path) + elif cxx_type in ['clang', 'apple-clang']: + self.cxx.flags += ['-fcolor-diagnostics'] + elif cxx_type == 'gcc': + self.cxx.flags += ['-fdiagnostics-color=always'] + def configure_debug_mode(self): debug_level = self.get_lit_conf('debug_level', None) if not debug_level: Index: www/lit_usage.html =================================================================== --- www/lit_usage.html +++ www/lit_usage.html @@ -192,6 +192,16 @@

+

+

color_diagnostics

+
+Enable the use of colorized compile diagnostics. If the +color_diagnostics option is specified or the enviroment variable +LIBCXX_COLOR_DIAGNOSTICS is present then color diagnostics will be +enabled. +
+

+