@@ -2358,6 +2358,7 @@ impl<'test> TestCx<'test> {
2358
2358
let suffix =
2359
2359
self . safe_revision ( ) . map_or ( "nightly" . into ( ) , |path| path. to_owned ( ) + "-nightly" ) ;
2360
2360
let compare_dir = output_base_dir ( self . config , self . testpaths , Some ( & suffix) ) ;
2361
+ // Don't give an error if the directory didn't already exist
2361
2362
let _ = fs:: remove_dir_all ( & compare_dir) ;
2362
2363
create_dir_all ( & compare_dir) . unwrap ( ) ;
2363
2364
@@ -2406,18 +2407,28 @@ impl<'test> TestCx<'test> {
2406
2407
self . fatal ( "failed to run tidy" ) ;
2407
2408
}
2408
2409
2409
- let has_delta = Command :: new ( "delta" )
2410
- . arg ( "--version" )
2411
- . stdout ( Stdio :: null ( ) )
2412
- . status ( )
2413
- . map_or ( false , |status| status. success ( ) ) ;
2410
+ let pager = {
2411
+ let output = Command :: new ( "git" ) . args ( & [ "config" , "--get" , "core.pager" ] ) . output ( ) . ok ( ) ;
2412
+ output. and_then ( |out| {
2413
+ if out. status . success ( ) {
2414
+ Some ( String :: from_utf8 ( out. stdout ) . expect ( "invalid UTF8 in git pager" ) )
2415
+ } else {
2416
+ None
2417
+ }
2418
+ } )
2419
+ } ;
2414
2420
let mut diff = Command :: new ( "diff" ) ;
2415
2421
diff. args ( & [ "-u" , "-r" ] ) . args ( & [ out_dir, & compare_dir] ) ;
2416
2422
2417
- let output = if has_delta {
2423
+ let output = if let Some ( pager ) = pager {
2418
2424
let diff_pid = diff. stdout ( Stdio :: piped ( ) ) . spawn ( ) . expect ( "failed to run `diff`" ) ;
2419
- let output = Command :: new ( "delta" )
2420
- . arg ( "--paging=never" )
2425
+ let pager = pager. trim ( ) ;
2426
+ if self . config . verbose {
2427
+ eprintln ! ( "using pager {}" , pager) ;
2428
+ }
2429
+ let output = Command :: new ( pager)
2430
+ // disable paging; we want this to be non-interactive
2431
+ . env ( "PAGER" , "" )
2421
2432
. stdin ( diff_pid. stdout . unwrap ( ) )
2422
2433
// Capture output and print it explicitly so it will in turn be
2423
2434
// captured by libtest.
@@ -2426,7 +2437,10 @@ impl<'test> TestCx<'test> {
2426
2437
assert ! ( output. status. success( ) ) ;
2427
2438
output
2428
2439
} else {
2429
- eprintln ! ( "warning: `delta` not installed, falling back to `diff --color`" ) ;
2440
+ eprintln ! ( "warning: no pager configured, falling back to `diff --color`" ) ;
2441
+ eprintln ! (
2442
+ "help: try configuring a git pager (e.g. `delta`) with `git config --global core.pager delta`"
2443
+ ) ;
2430
2444
let output = diff. arg ( "--color" ) . output ( ) . unwrap ( ) ;
2431
2445
assert ! ( output. status. success( ) || output. status. code( ) == Some ( 1 ) ) ;
2432
2446
output
0 commit comments