@@ -37,7 +37,7 @@ use filetime::FileTime;
3737use getopts:: { optopt, optflag, reqopt} ;
3838use common:: Config ;
3939use common:: { Pretty , DebugInfoGdb , DebugInfoLldb , Mode } ;
40- use test:: TestPaths ;
40+ use test:: { TestPaths , ColorConfig } ;
4141use util:: logv;
4242
4343use self :: header:: EarlyProps ;
@@ -90,6 +90,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
9090 optopt( "" , "target-rustcflags" , "flags to pass to rustc for target" , "FLAGS" ) ,
9191 optflag( "" , "verbose" , "run tests verbosely, showing all output" ) ,
9292 optflag( "" , "quiet" , "print one character per test instead of one line" ) ,
93+ optopt( "" , "color" , "coloring: auto, always, never" , "WHEN" ) ,
9394 optopt( "" , "logfile" , "file to log test execution to" , "FILE" ) ,
9495 optopt( "" , "target" , "the target to build for" , "TARGET" ) ,
9596 optopt( "" , "host" , "the host to build for" , "HOST" ) ,
@@ -147,6 +148,13 @@ pub fn parse_config(args: Vec<String> ) -> Config {
147148
148149 let ( gdb, gdb_version, gdb_native_rust) = analyze_gdb ( matches. opt_str ( "gdb" ) ) ;
149150
151+ let color = match matches. opt_str ( "color" ) . as_ref ( ) . map ( |x| & * * x) {
152+ Some ( "auto" ) | None => ColorConfig :: AutoColor ,
153+ Some ( "always" ) => ColorConfig :: AlwaysColor ,
154+ Some ( "never" ) => ColorConfig :: NeverColor ,
155+ Some ( x) => panic ! ( "argument for --color must be auto, always, or never, but found `{}`" , x) ,
156+ } ;
157+
150158 Config {
151159 compile_lib_path : make_absolute ( opt_path ( matches, "compile-lib-path" ) ) ,
152160 run_lib_path : make_absolute ( opt_path ( matches, "run-lib-path" ) ) ,
@@ -185,6 +193,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
185193 lldb_python_dir : matches. opt_str ( "lldb-python-dir" ) ,
186194 verbose : matches. opt_present ( "verbose" ) ,
187195 quiet : matches. opt_present ( "quiet" ) ,
196+ color : color,
188197 remote_test_client : matches. opt_str ( "remote-test-client" ) . map ( PathBuf :: from) ,
189198
190199 cc : matches. opt_str ( "cc" ) . unwrap ( ) ,
@@ -332,7 +341,7 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
332341 Ok ( val) => & val != "0" ,
333342 Err ( _) => false
334343 } ,
335- color : test :: AutoColor ,
344+ color : config . color ,
336345 test_threads : None ,
337346 skip : vec ! [ ] ,
338347 list : false ,
0 commit comments