@@ -61,7 +61,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
61
61
. optopt ( "" , "jsondoclint-path" , "path to jsondoclint to use for doc tests" , "PATH" )
62
62
. optopt ( "" , "run-clang-based-tests-with" , "path to Clang executable" , "PATH" )
63
63
. optopt ( "" , "llvm-filecheck" , "path to LLVM's FileCheck binary" , "DIR" )
64
- . reqopt ( "" , "src-base" , "directory to scan for test files" , "PATH" )
64
+ . reqopt ( "" , "src-root" , "directory containing sources" , "PATH" )
65
+ . reqopt ( "" , "src-test-suite-root" , "directory containing test suite sources" , "PATH" )
65
66
. reqopt ( "" , "build-base" , "directory to deposit test outputs" , "PATH" )
66
67
. reqopt ( "" , "sysroot-base" , "directory containing the compiler sysroot" , "PATH" )
67
68
. reqopt ( "" , "stage" , "stage number under test" , "N" )
@@ -243,7 +244,6 @@ pub fn parse_config(args: Vec<String>) -> Config {
243
244
|| header:: extract_llvm_version_from_binary ( & matches. opt_str ( "llvm-filecheck" ) ?) ,
244
245
) ;
245
246
246
- let src_base = opt_path ( matches, "src-base" ) ;
247
247
let run_ignored = matches. opt_present ( "ignored" ) ;
248
248
let with_rustc_debug_assertions = matches. opt_present ( "with-rustc-debug-assertions" ) ;
249
249
let with_std_debug_assertions = matches. opt_present ( "with-std-debug-assertions" ) ;
@@ -300,6 +300,15 @@ pub fn parse_config(args: Vec<String>) -> Config {
300
300
None => panic ! ( "`--stage` is required" ) ,
301
301
} ;
302
302
303
+ let src_root = opt_path ( matches, "src-root" ) ;
304
+ let src_test_suite_root = opt_path ( matches, "src-test-suite-root" ) ;
305
+ assert ! (
306
+ src_test_suite_root. starts_with( & src_root) ,
307
+ "`src-root` must be a parent of `src-test-suite-root`: `src-root`=`{}`, `src-test-suite-root` = `{}`" ,
308
+ src_root. display( ) ,
309
+ src_test_suite_root. display( )
310
+ ) ;
311
+
303
312
Config {
304
313
bless : matches. opt_present ( "bless" ) ,
305
314
compile_lib_path : make_absolute ( opt_path ( matches, "compile-lib-path" ) ) ,
@@ -314,7 +323,10 @@ pub fn parse_config(args: Vec<String>) -> Config {
314
323
run_clang_based_tests_with : matches. opt_str ( "run-clang-based-tests-with" ) ,
315
324
llvm_filecheck : matches. opt_str ( "llvm-filecheck" ) . map ( PathBuf :: from) ,
316
325
llvm_bin_dir : matches. opt_str ( "llvm-bin-dir" ) . map ( PathBuf :: from) ,
317
- src_base,
326
+
327
+ src_root,
328
+ src_test_suite_root,
329
+
318
330
build_base : opt_path ( matches, "build-base" ) ,
319
331
sysroot_base : opt_path ( matches, "sysroot-base" ) ,
320
332
@@ -422,7 +434,10 @@ pub fn log_config(config: &Config) {
422
434
logv ( c, format ! ( "rustc_path: {:?}" , config. rustc_path. display( ) ) ) ;
423
435
logv ( c, format ! ( "cargo_path: {:?}" , config. cargo_path) ) ;
424
436
logv ( c, format ! ( "rustdoc_path: {:?}" , config. rustdoc_path) ) ;
425
- logv ( c, format ! ( "src_base: {:?}" , config. src_base. display( ) ) ) ;
437
+
438
+ logv ( c, format ! ( "src_root: {}" , config. src_root. display( ) ) ) ;
439
+ logv ( c, format ! ( "src_test_suite_root: {}" , config. src_test_suite_root. display( ) ) ) ;
440
+
426
441
logv ( c, format ! ( "build_base: {:?}" , config. build_base. display( ) ) ) ;
427
442
logv ( c, format ! ( "stage: {}" , config. stage) ) ;
428
443
logv ( c, format ! ( "stage_id: {}" , config. stage_id) ) ;
@@ -620,20 +635,29 @@ struct TestCollector {
620
635
/// regardless of whether any filters/tests were specified on the command-line,
621
636
/// because filtering is handled later by libtest.
622
637
pub fn collect_and_make_tests ( config : Arc < Config > ) -> Vec < test:: TestDescAndFn > {
623
- debug ! ( "making tests from {:? }" , config. src_base . display( ) ) ;
638
+ debug ! ( "making tests from {}" , config. src_test_suite_root . display( ) ) ;
624
639
let common_inputs_stamp = common_inputs_stamp ( & config) ;
625
- let modified_tests = modified_tests ( & config, & config. src_base ) . unwrap_or_else ( |err| {
626
- panic ! ( "modified_tests got error from dir: {}, error: {}" , config. src_base. display( ) , err)
627
- } ) ;
640
+ let modified_tests =
641
+ modified_tests ( & config, & config. src_test_suite_root ) . unwrap_or_else ( |err| {
642
+ panic ! (
643
+ "modified_tests got error from dir: {}, error: {}" ,
644
+ config. src_test_suite_root. display( ) ,
645
+ err
646
+ )
647
+ } ) ;
628
648
let cache = HeadersCache :: load ( & config) ;
629
649
630
650
let cx = TestCollectorCx { config, cache, common_inputs_stamp, modified_tests } ;
631
651
let mut collector =
632
652
TestCollector { tests : vec ! [ ] , found_path_stems : HashSet :: new ( ) , poisoned : false } ;
633
653
634
- collect_tests_from_dir ( & cx, & mut collector, & cx. config . src_base , Path :: new ( "" ) ) . unwrap_or_else (
635
- |reason| panic ! ( "Could not read tests from {}: {reason}" , cx. config. src_base. display( ) ) ,
636
- ) ;
654
+ collect_tests_from_dir ( & cx, & mut collector, & cx. config . src_test_suite_root , Path :: new ( "" ) )
655
+ . unwrap_or_else ( |reason| {
656
+ panic ! (
657
+ "Could not read tests from {}: {reason}" ,
658
+ cx. config. src_test_suite_root. display( )
659
+ )
660
+ } ) ;
637
661
638
662
let TestCollector { tests, found_path_stems, poisoned } = collector;
639
663
@@ -655,7 +679,7 @@ pub fn collect_and_make_tests(config: Arc<Config>) -> Vec<test::TestDescAndFn> {
655
679
/// common to some subset of tests, and are hopefully unlikely to be modified
656
680
/// while working on other tests.)
657
681
fn common_inputs_stamp ( config : & Config ) -> Stamp {
658
- let rust_src_dir = config. find_rust_src_root ( ) . expect ( "Could not find Rust source root" ) ;
682
+ let src_root = & config. src_root ;
659
683
660
684
let mut stamp = Stamp :: from_path ( & config. rustc_path ) ;
661
685
@@ -670,17 +694,17 @@ fn common_inputs_stamp(config: &Config) -> Stamp {
670
694
"src/etc/lldb_providers.py" ,
671
695
] ;
672
696
for file in & pretty_printer_files {
673
- let path = rust_src_dir . join ( file) ;
697
+ let path = src_root . join ( file) ;
674
698
stamp. add_path ( & path) ;
675
699
}
676
700
677
- stamp. add_dir ( & rust_src_dir . join ( "src/etc/natvis" ) ) ;
701
+ stamp. add_dir ( & src_root . join ( "src/etc/natvis" ) ) ;
678
702
679
703
stamp. add_dir ( & config. run_lib_path ) ;
680
704
681
705
if let Some ( ref rustdoc_path) = config. rustdoc_path {
682
706
stamp. add_path ( & rustdoc_path) ;
683
- stamp. add_path ( & rust_src_dir . join ( "src/etc/htmldocck.py" ) ) ;
707
+ stamp. add_path ( & src_root . join ( "src/etc/htmldocck.py" ) ) ;
684
708
}
685
709
686
710
// Re-run coverage tests if the `coverage-dump` tool was modified,
@@ -689,10 +713,10 @@ fn common_inputs_stamp(config: &Config) -> Stamp {
689
713
stamp. add_path ( coverage_dump_path)
690
714
}
691
715
692
- stamp. add_dir ( & rust_src_dir . join ( "src/tools/run-make-support" ) ) ;
716
+ stamp. add_dir ( & src_root . join ( "src/tools/run-make-support" ) ) ;
693
717
694
718
// Compiletest itself.
695
- stamp. add_dir ( & rust_src_dir . join ( "src/tools/compiletest/ " ) ) ;
719
+ stamp. add_dir ( & src_root . join ( "src/tools/compiletest" ) ) ;
696
720
697
721
stamp
698
722
}
@@ -933,10 +957,7 @@ fn files_related_to_test(
933
957
}
934
958
935
959
// `minicore.rs` test auxiliary: we need to make sure tests get rerun if this changes.
936
- //
937
- // FIXME(jieyouxu): untangle these paths, we should provide both a path to root `tests/` or
938
- // `tests/auxiliary/` and the test suite in question. `src_base` is also a terrible name.
939
- related. push ( config. src_base . parent ( ) . unwrap ( ) . join ( "auxiliary" ) . join ( "minicore.rs" ) ) ;
960
+ related. push ( config. src_root . join ( "tests" ) . join ( "auxiliary" ) . join ( "minicore.rs" ) ) ;
940
961
941
962
related
942
963
}
@@ -1026,10 +1047,8 @@ fn make_test_name(
1026
1047
testpaths : & TestPaths ,
1027
1048
revision : Option < & str > ,
1028
1049
) -> test:: TestName {
1029
- // Print the name of the file, relative to the repository root.
1030
- // `src_base` looks like `/path/to/rust/tests/ui`
1031
- let root_directory = config. src_base . parent ( ) . unwrap ( ) . parent ( ) . unwrap ( ) ;
1032
- let path = testpaths. file . strip_prefix ( root_directory) . unwrap ( ) ;
1050
+ // Print the name of the file, relative to the sources root.
1051
+ let path = testpaths. file . strip_prefix ( & config. src_root ) . unwrap ( ) ;
1033
1052
let debugger = match config. debugger {
1034
1053
Some ( d) => format ! ( "-{}" , d) ,
1035
1054
None => String :: new ( ) ,
0 commit comments