File tree Expand file tree Collapse file tree 1 file changed +20
-14
lines changed
src/tools/compiletest/src Expand file tree Collapse file tree 1 file changed +20
-14
lines changed Original file line number Diff line number Diff line change @@ -2388,20 +2388,26 @@ impl<'test> TestCx<'test> {
23882388 self . fatal ( "failed to run tidy" ) ;
23892389 }
23902390
2391- let diff_pid = Command :: new ( "diff" )
2392- . args ( & [ "-u" , "-r" ] )
2393- . args ( & [ out_dir, & compare_dir] )
2394- . stdout ( Stdio :: piped ( ) )
2395- . spawn ( )
2396- . expect ( "failed to run `diff`" ) ;
2397- let status = Command :: new ( "delta" )
2398- . arg ( "--paging=never" )
2399- . stdin ( diff_pid. stdout . unwrap ( ) )
2400- . spawn ( )
2401- . expect ( "delta not found" )
2402- . wait ( )
2403- . unwrap ( ) ;
2404- assert ! ( status. success( ) ) ;
2391+ let has_delta = Command :: new ( "delta" )
2392+ . arg ( "--version" )
2393+ . status ( )
2394+ . map_or ( false , |status| status. success ( ) ) ;
2395+ let mut diff = Command :: new ( "diff" ) ;
2396+ diff. args ( & [ "-u" , "-r" ] ) . args ( & [ out_dir, & compare_dir] ) ;
2397+
2398+ if has_delta {
2399+ let diff_pid = diff. stdout ( Stdio :: piped ( ) ) . spawn ( ) . expect ( "failed to run `diff`" ) ;
2400+ let status = Command :: new ( "delta" )
2401+ . arg ( "--paging=never" )
2402+ . stdin ( diff_pid. stdout . unwrap ( ) )
2403+ . status ( )
2404+ . unwrap ( ) ;
2405+ assert ! ( status. success( ) ) ;
2406+ } else {
2407+ eprintln ! ( "warning: `delta` not installed, falling back to `diff --color`" ) ;
2408+ diff. arg ( "--color" ) . spawn ( ) . expect ( "failed to run `diff`" ) . wait ( ) . unwrap ( ) ;
2409+ assert ! ( status. success( ) || status. code( ) == Some ( 1 ) ) ;
2410+ }
24052411 }
24062412
24072413 fn get_lines < P : AsRef < Path > > (
You can’t perform that action at this time.
0 commit comments