File tree Expand file tree Collapse file tree 3 files changed +30
-2
lines changed Expand file tree Collapse file tree 3 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -20,3 +20,6 @@ regex = "1"
2020
2121[dev-dependencies ]
2222expect-test = " 1.0"
23+
24+ [target .'cfg(windows)' .dependencies ]
25+ termcolor = " 1.0"
Original file line number Diff line number Diff line change @@ -298,10 +298,31 @@ fn run_test(
298298 ErrorOutputType :: HumanReadable ( kind) => {
299299 let ( _, color_config) = kind. unzip ( ) ;
300300 match color_config {
301- ColorConfig :: Never => { }
302- _ => {
301+ ColorConfig :: Never => {
302+ compiler. arg ( "--color" ) . arg ( "never" ) ;
303+ }
304+ ColorConfig :: Always => {
303305 compiler. arg ( "--color" ) . arg ( "always" ) ;
304306 }
307+ ColorConfig :: Auto => {
308+ #[ cfg( windows) ]
309+ {
310+ // This specific check is because old windows consoles require a connection
311+ // to be able to display colors (and they don't support ANSI), which we
312+ // cannot in here, so in case this is an old windows console, we can't
313+ // display colors.
314+ use crate :: termcolor:: { ColorChoice , StandardStream , WriteColor } ;
315+ if StandardStream :: stdout ( ColorChoice :: Auto ) . is_synchronous ( ) {
316+ compiler. arg ( "--color" ) . arg ( "never" ) ;
317+ } else {
318+ compiler. arg ( "--color" ) . arg ( "always" ) ;
319+ }
320+ }
321+ #[ cfg( not( windows) ) ]
322+ {
323+ compiler. arg ( "--color" ) . arg ( "always" ) ;
324+ }
325+ }
305326 }
306327 }
307328 _ => { }
Original file line number Diff line number Diff line change @@ -54,6 +54,10 @@ extern crate rustc_target;
5454extern crate rustc_trait_selection;
5555extern crate rustc_typeck;
5656extern crate test as testing;
57+ #[ macro_use]
58+ extern crate tracing;
59+ #[ cfg( windows) ]
60+ extern crate termcolor;
5761
5862use std:: default:: Default ;
5963use std:: env;
You can’t perform that action at this time.
0 commit comments