@@ -363,16 +363,19 @@ impl Build {
363363 cc_detect:: find ( & mut build) ;
364364 build. verbose ( "running sanity check" ) ;
365365 sanity:: check ( & mut build) ;
366- // If local-rust is the same major.minor as the current version, then force a local-rebuild
367- let local_version_verbose = output (
368- Command :: new ( & build. initial_rustc ) . arg ( "--version" ) . arg ( "--verbose" ) ) ;
369- let local_release = local_version_verbose
370- . lines ( ) . filter ( |x| x. starts_with ( "release:" ) )
371- . next ( ) . unwrap ( ) . trim_left_matches ( "release:" ) . trim ( ) ;
372- let my_version = channel:: CFG_RELEASE_NUM ;
373- if local_release. split ( '.' ) . take ( 2 ) . eq ( my_version. split ( '.' ) . take ( 2 ) ) {
374- build. verbose ( & format ! ( "auto-detected local-rebuild {}" , local_release) ) ;
375- build. local_rebuild = true ;
366+ if !cfg ! ( test) {
367+ // If local-rust is the same major.minor as the current version, then force a
368+ // local-rebuild
369+ let local_version_verbose = output (
370+ Command :: new ( & build. initial_rustc ) . arg ( "--version" ) . arg ( "--verbose" ) ) ;
371+ let local_release = local_version_verbose
372+ . lines ( ) . filter ( |x| x. starts_with ( "release:" ) )
373+ . next ( ) . unwrap ( ) . trim_left_matches ( "release:" ) . trim ( ) ;
374+ let my_version = channel:: CFG_RELEASE_NUM ;
375+ if local_release. split ( '.' ) . take ( 2 ) . eq ( my_version. split ( '.' ) . take ( 2 ) ) {
376+ build. verbose ( & format ! ( "auto-detected local-rebuild {}" , local_release) ) ;
377+ build. local_rebuild = true ;
378+ }
376379 }
377380 build. verbose ( "learning about cargo" ) ;
378381 metadata:: build ( & mut build) ;
@@ -419,6 +422,7 @@ impl Build {
419422 ///
420423 /// After this executes, it will also ensure that `dir` exists.
421424 fn clear_if_dirty ( & self , dir : & Path , input : & Path ) -> bool {
425+ if cfg ! ( test) { return true ; }
422426 let stamp = dir. join ( ".stamp" ) ;
423427 let mut cleared = false ;
424428 if mtime ( & stamp) < mtime ( input) {
@@ -593,12 +597,14 @@ impl Build {
593597
594598 /// Runs a command, printing out nice contextual information if it fails.
595599 fn run ( & self , cmd : & mut Command ) {
600+ if cfg ! ( test) { return ; }
596601 self . verbose ( & format ! ( "running: {:?}" , cmd) ) ;
597602 run_silent ( cmd)
598603 }
599604
600605 /// Runs a command, printing out nice contextual information if it fails.
601606 fn run_quiet ( & self , cmd : & mut Command ) {
607+ if cfg ! ( test) { return ; }
602608 self . verbose ( & format ! ( "running: {:?}" , cmd) ) ;
603609 run_suppressed ( cmd)
604610 }
@@ -607,6 +613,7 @@ impl Build {
607613 /// Exits if the command failed to execute at all, otherwise returns its
608614 /// `status.success()`.
609615 fn try_run ( & self , cmd : & mut Command ) -> bool {
616+ if cfg ! ( test) { return true ; }
610617 self . verbose ( & format ! ( "running: {:?}" , cmd) ) ;
611618 try_run_silent ( cmd)
612619 }
@@ -615,6 +622,7 @@ impl Build {
615622 /// Exits if the command failed to execute at all, otherwise returns its
616623 /// `status.success()`.
617624 fn try_run_quiet ( & self , cmd : & mut Command ) -> bool {
625+ if cfg ! ( test) { return true ; }
618626 self . verbose ( & format ! ( "running: {:?}" , cmd) ) ;
619627 try_run_suppressed ( cmd)
620628 }
@@ -685,6 +693,7 @@ impl Build {
685693
686694 /// Returns the path to the linker for the given target if it needs to be overridden.
687695 fn linker ( & self , target : Interned < String > ) -> Option < & Path > {
696+ if cfg ! ( test) { return None ; }
688697 if let Some ( linker) = self . config . target_config . get ( & target)
689698 . and_then ( |c| c. linker . as_ref ( ) ) {
690699 Some ( linker)
0 commit comments