@@ -525,7 +525,9 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
525
525
pub fn make_tests ( config : & Config , tests : & mut Vec < test:: TestDescAndFn > ) {
526
526
debug ! ( "making tests from {:?}" , config. src_base. display( ) ) ;
527
527
let inputs = common_inputs_stamp ( config) ;
528
- let modified_tests = modified_tests ( config, & config. src_base ) ;
528
+ let modified_tests = modified_tests ( config, & config. src_base ) . unwrap_or_else ( |err| {
529
+ panic ! ( "modified_tests got error from dir: {}, error: {}" , config. src_base. display( ) , err)
530
+ } ) ;
529
531
collect_tests_from_dir (
530
532
config,
531
533
& config. src_base ,
@@ -573,13 +575,14 @@ fn common_inputs_stamp(config: &Config) -> Stamp {
573
575
stamp
574
576
}
575
577
576
- fn modified_tests ( config : & Config , dir : & Path ) -> Vec < PathBuf > {
578
+ fn modified_tests ( config : & Config , dir : & Path ) -> Result < Vec < PathBuf > , String > {
577
579
if !config. only_modified {
578
- return vec ! [ ] ;
580
+ return Ok ( vec ! [ ] ) ;
579
581
}
580
- let Ok ( Some ( files) ) = get_git_modified_files ( Some ( dir) , & vec ! [ "rs" , "stderr" , "fixed" ] ) else { return vec ! [ ] ; } ;
582
+ let files =
583
+ get_git_modified_files ( Some ( dir) , & vec ! [ "rs" , "stderr" , "fixed" ] ) ?. unwrap_or ( vec ! [ ] ) ;
581
584
// Add new test cases to the list, it will be convenient in daily development.
582
- let Ok ( Some ( untracked_files) ) = get_git_untracked_files ( None ) else { return vec ! [ ] ; } ;
585
+ let untracked_files = get_git_untracked_files ( None ) ? . unwrap_or ( vec ! [ ] ) ;
583
586
584
587
let all_paths = [ & files[ ..] , & untracked_files[ ..] ] . concat ( ) ;
585
588
let full_paths = {
@@ -591,7 +594,7 @@ fn modified_tests(config: &Config, dir: &Path) -> Vec<PathBuf> {
591
594
full_paths. sort_unstable ( ) ;
592
595
full_paths
593
596
} ;
594
- full_paths
597
+ Ok ( full_paths)
595
598
}
596
599
597
600
fn collect_tests_from_dir (
@@ -600,7 +603,7 @@ fn collect_tests_from_dir(
600
603
relative_dir_path : & Path ,
601
604
inputs : & Stamp ,
602
605
tests : & mut Vec < test:: TestDescAndFn > ,
603
- only_modified : & Vec < PathBuf > ,
606
+ modified_tests : & Vec < PathBuf > ,
604
607
) -> io:: Result < ( ) > {
605
608
// Ignore directories that contain a file named `compiletest-ignore-dir`.
606
609
if dir. join ( "compiletest-ignore-dir" ) . exists ( ) {
@@ -631,7 +634,7 @@ fn collect_tests_from_dir(
631
634
let file = file?;
632
635
let file_path = file. path ( ) ;
633
636
let file_name = file. file_name ( ) ;
634
- if is_test ( & file_name) && ( !config. only_modified || only_modified . contains ( & file_path) ) {
637
+ if is_test ( & file_name) && ( !config. only_modified || modified_tests . contains ( & file_path) ) {
635
638
debug ! ( "found test file: {:?}" , file_path. display( ) ) ;
636
639
let paths =
637
640
TestPaths { file : file_path, relative_dir : relative_dir_path. to_path_buf ( ) } ;
@@ -647,7 +650,7 @@ fn collect_tests_from_dir(
647
650
& relative_file_path,
648
651
inputs,
649
652
tests,
650
- only_modified ,
653
+ modified_tests ,
651
654
) ?;
652
655
}
653
656
} else {
0 commit comments