@@ -574,22 +574,59 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
574574
575575pub fn make_tests ( config : & Config ) -> Vec < test:: TestDescAndFn > {
576576 debug ! ( "making tests from {:?}" , config. src_base. display( ) ) ;
577+ let inputs = common_inputs_stamp ( config) ;
577578 let mut tests = Vec :: new ( ) ;
578579 collect_tests_from_dir (
579580 config,
580581 & config. src_base ,
581582 & config. src_base ,
582583 & PathBuf :: new ( ) ,
584+ & inputs,
583585 & mut tests,
584586 ) . unwrap ( ) ;
585587 tests
586588}
587589
590+ /// Returns a stamp constructed from input files common to all test cases.
591+ fn common_inputs_stamp ( config : & Config ) -> Stamp {
592+ let rust_src_dir = config
593+ . find_rust_src_root ( )
594+ . expect ( "Could not find Rust source root" ) ;
595+
596+ let mut stamp = Stamp :: from_path ( & config. rustc_path ) ;
597+
598+ // Relevant pretty printer files
599+ let pretty_printer_files = [
600+ "src/etc/debugger_pretty_printers_common.py" ,
601+ "src/etc/gdb_load_rust_pretty_printers.py" ,
602+ "src/etc/gdb_rust_pretty_printing.py" ,
603+ "src/etc/lldb_batchmode.py" ,
604+ "src/etc/lldb_rust_formatters.py" ,
605+ ] ;
606+ for file in & pretty_printer_files {
607+ let path = rust_src_dir. join ( file) ;
608+ stamp. add_path ( & path) ;
609+ }
610+
611+ stamp. add_dir ( & config. run_lib_path ) ;
612+
613+ if let Some ( ref rustdoc_path) = config. rustdoc_path {
614+ stamp. add_path ( & rustdoc_path) ;
615+ stamp. add_path ( & rust_src_dir. join ( "src/etc/htmldocck.py" ) ) ;
616+ }
617+
618+ // Compiletest itself.
619+ stamp. add_dir ( & rust_src_dir. join ( "src/tools/compiletest/" ) ) ;
620+
621+ stamp
622+ }
623+
588624fn collect_tests_from_dir (
589625 config : & Config ,
590626 base : & Path ,
591627 dir : & Path ,
592628 relative_dir_path : & Path ,
629+ inputs : & Stamp ,
593630 tests : & mut Vec < test:: TestDescAndFn > ,
594631) -> io:: Result < ( ) > {
595632 // Ignore directories that contain a file named `compiletest-ignore-dir`.
@@ -602,7 +639,7 @@ fn collect_tests_from_dir(
602639 file : dir. to_path_buf ( ) ,
603640 relative_dir : relative_dir_path. parent ( ) . unwrap ( ) . to_path_buf ( ) ,
604641 } ;
605- tests. extend ( make_test ( config, & paths) ) ;
642+ tests. extend ( make_test ( config, & paths, inputs ) ) ;
606643 return Ok ( ( ) ) ;
607644 }
608645
@@ -627,12 +664,14 @@ fn collect_tests_from_dir(
627664 file : file_path,
628665 relative_dir : relative_dir_path. to_path_buf ( ) ,
629666 } ;
630- tests. extend ( make_test ( config, & paths) )
667+ tests. extend ( make_test ( config, & paths, inputs ) )
631668 } else if file_path. is_dir ( ) {
632669 let relative_file_path = relative_dir_path. join ( file. file_name ( ) ) ;
633670 if & file_name != "auxiliary" {
634671 debug ! ( "found directory: {:?}" , file_path. display( ) ) ;
635- collect_tests_from_dir ( config, base, & file_path, & relative_file_path, tests) ?;
672+ collect_tests_from_dir (
673+ config, base, & file_path, & relative_file_path,
674+ inputs, tests) ?;
636675 }
637676 } else {
638677 debug ! ( "found other file/directory: {:?}" , file_path. display( ) ) ;
@@ -655,7 +694,7 @@ pub fn is_test(file_name: &OsString) -> bool {
655694 !invalid_prefixes. iter ( ) . any ( |p| file_name. starts_with ( p) )
656695}
657696
658- pub fn make_test ( config : & Config , testpaths : & TestPaths ) -> Vec < test:: TestDescAndFn > {
697+ fn make_test ( config : & Config , testpaths : & TestPaths , inputs : & Stamp ) -> Vec < test:: TestDescAndFn > {
659698 let early_props = if config. mode == Mode :: RunMake {
660699 // Allow `ignore` directives to be in the Makefile.
661700 EarlyProps :: from_file ( config, & testpaths. file . join ( "Makefile" ) )
@@ -685,19 +724,20 @@ pub fn make_test(config: &Config, testpaths: &TestPaths) -> Vec<test::TestDescAn
685724 revisions
686725 . into_iter ( )
687726 . map ( |revision| {
688- // Debugging emscripten code doesn't make sense today
689727 let ignore = early_props. ignore == Ignore :: Ignore
690- || !up_to_date (
691- config,
692- testpaths,
693- & early_props,
694- revision. map ( |s| s. as_str ( ) ) ,
695- )
728+ // Debugging emscripten code doesn't make sense today
696729 || ( ( config. mode == DebugInfoGdbLldb || config. mode == DebugInfoCdb ||
697730 config. mode == DebugInfoGdb || config. mode == DebugInfoLldb )
698731 && config. target . contains ( "emscripten" ) )
699732 || ( config. mode == DebugInfoGdb && !early_props. ignore . can_run_gdb ( ) )
700- || ( config. mode == DebugInfoLldb && !early_props. ignore . can_run_lldb ( ) ) ;
733+ || ( config. mode == DebugInfoLldb && !early_props. ignore . can_run_lldb ( ) )
734+ || !is_outdated (
735+ config,
736+ testpaths,
737+ & early_props,
738+ revision. map ( |s| s. as_str ( ) ) ,
739+ inputs,
740+ ) ;
701741 test:: TestDescAndFn {
702742 desc : test:: TestDesc {
703743 name : make_test_name ( config, testpaths, revision) ,
@@ -716,11 +756,12 @@ fn stamp(config: &Config, testpaths: &TestPaths, revision: Option<&str>) -> Path
716756 output_base_dir ( config, testpaths, revision) . join ( "stamp" )
717757}
718758
719- fn up_to_date (
759+ fn is_outdated (
720760 config : & Config ,
721761 testpaths : & TestPaths ,
722762 props : & EarlyProps ,
723763 revision : Option < & str > ,
764+ inputs : & Stamp ,
724765) -> bool {
725766 let stamp_name = stamp ( config, testpaths, revision) ;
726767 // Check hash.
@@ -735,79 +776,55 @@ fn up_to_date(
735776 }
736777
737778 // Check timestamps.
738- let rust_src_dir = config
739- . find_rust_src_root ( )
740- . expect ( "Could not find Rust source root" ) ;
741- let stamp = Stamp :: from_path ( & stamp_name) ;
742- let mut inputs = vec ! [ Stamp :: from_path( & testpaths. file) , Stamp :: from_path( & config. rustc_path) ] ;
743- inputs. extend (
744- props
745- . aux
746- . iter ( )
747- . map ( |aux| {
748- Stamp :: from_path ( & testpaths. file . parent ( ) . unwrap ( ) . join ( "auxiliary" ) . join ( aux) )
749- } ) ,
750- ) ;
751- // Relevant pretty printer files
752- let pretty_printer_files = [
753- "src/etc/debugger_pretty_printers_common.py" ,
754- "src/etc/gdb_load_rust_pretty_printers.py" ,
755- "src/etc/gdb_rust_pretty_printing.py" ,
756- "src/etc/lldb_batchmode.py" ,
757- "src/etc/lldb_rust_formatters.py" ,
758- ] ;
759- inputs. extend ( pretty_printer_files. iter ( ) . map ( |pretty_printer_file| {
760- Stamp :: from_path ( & rust_src_dir. join ( pretty_printer_file) )
761- } ) ) ;
762- inputs. extend ( Stamp :: from_dir ( & config. run_lib_path ) ) ;
763- if let Some ( ref rustdoc_path) = config. rustdoc_path {
764- inputs. push ( Stamp :: from_path ( & rustdoc_path) ) ;
765- inputs. push ( Stamp :: from_path ( & rust_src_dir. join ( "src/etc/htmldocck.py" ) ) ) ;
779+ let mut inputs = inputs. clone ( ) ;
780+ inputs. add_path ( & testpaths. file ) ;
781+
782+ for aux in & props. aux {
783+ let path = testpaths. file . parent ( )
784+ . unwrap ( )
785+ . join ( "auxiliary" )
786+ . join ( aux) ;
787+ inputs. add_path ( & path) ;
766788 }
767789
768790 // UI test files.
769- inputs . extend ( UI_EXTENSIONS . iter ( ) . map ( | extension| {
791+ for extension in UI_EXTENSIONS {
770792 let path = & expected_output_path ( testpaths, revision, & config. compare_mode , extension) ;
771- Stamp :: from_path ( path)
772- } ) ) ;
773-
774- // Compiletest itself.
775- inputs. extend ( Stamp :: from_dir ( & rust_src_dir. join ( "src/tools/compiletest/" ) ) ) ;
793+ inputs. add_path ( path) ;
794+ }
776795
777- inputs. iter ( ) . any ( |input| input > & stamp )
796+ inputs > Stamp :: from_path ( & stamp_name )
778797}
779798
780- #[ derive( Debug , PartialEq , PartialOrd , Ord , Eq ) ]
799+ #[ derive( Clone , Debug , PartialEq , Eq , PartialOrd , Ord ) ]
781800struct Stamp {
782801 time : SystemTime ,
783- file : PathBuf ,
784802}
785803
786804impl Stamp {
787- fn from_path ( p : & Path ) -> Self {
788- let time = fs:: metadata ( p)
805+ fn from_path ( path : & Path ) -> Self {
806+ let mut stamp = Stamp { time : SystemTime :: UNIX_EPOCH } ;
807+ stamp. add_path ( path) ;
808+ stamp
809+ }
810+
811+ fn add_path ( & mut self , path : & Path ) {
812+ let modified = fs:: metadata ( path)
789813 . and_then ( |metadata| metadata. modified ( ) )
790814 . unwrap_or ( SystemTime :: UNIX_EPOCH ) ;
791-
792- Stamp {
793- time,
794- file : p. into ( ) ,
795- }
815+ self . time = self . time . max ( modified) ;
796816 }
797817
798- fn from_dir ( path : & Path ) -> impl Iterator < Item = Stamp > {
799- WalkDir :: new ( path)
800- . into_iter ( )
801- . map ( |entry| entry. unwrap ( ) )
802- . filter ( |entry| entry. file_type ( ) . is_file ( ) )
803- . map ( |entry| {
804- let time = ( || -> io:: Result < _ > { entry. metadata ( ) ?. modified ( ) } ) ( ) ;
805-
806- Stamp {
807- time : time. unwrap_or ( SystemTime :: UNIX_EPOCH ) ,
808- file : entry. path ( ) . into ( ) ,
809- }
810- } )
818+ fn add_dir ( & mut self , path : & Path ) {
819+ for entry in WalkDir :: new ( path) {
820+ let entry = entry. unwrap ( ) ;
821+ if entry. file_type ( ) . is_file ( ) {
822+ let modified = entry. metadata ( ) . ok ( )
823+ . and_then ( |metadata| metadata. modified ( ) . ok ( ) )
824+ . unwrap_or ( SystemTime :: UNIX_EPOCH ) ;
825+ self . time = self . time . max ( modified) ;
826+ }
827+ }
811828 }
812829}
813830
0 commit comments