@@ -18,7 +18,6 @@ use crate::common::{
1818 CompareMode , Config , Debugger , FailMode , PassMode , RunFailMode , RunResult , TestMode , TestPaths ,
1919 TestSuite , UI_EXTENSIONS , UI_FIXED , UI_RUN_STDERR , UI_RUN_STDOUT , UI_STDERR , UI_STDOUT , UI_SVG ,
2020 UI_WINDOWS_SVG , expected_output_path, incremental_dir, output_base_dir, output_base_name,
21- output_testname_unique,
2221} ;
2322use crate :: directives:: TestProps ;
2423use crate :: errors:: { Error , ErrorKind , load_errors} ;
@@ -563,7 +562,7 @@ impl<'test> TestCx<'test> {
563562 self . maybe_add_external_args ( & mut rustc, & self . config . target_rustcflags ) ;
564563 rustc. args ( & self . props . compile_flags ) ;
565564
566- self . compose_and_run_compiler ( rustc, Some ( src) , self . testpaths )
565+ self . compose_and_run_compiler ( rustc, Some ( src) )
567566 }
568567
569568 fn maybe_add_external_args ( & self , cmd : & mut Command , args : & Vec < String > ) {
@@ -994,37 +993,38 @@ impl<'test> TestCx<'test> {
994993 passes,
995994 ) ;
996995
997- self . compose_and_run_compiler ( rustc, None , self . testpaths )
996+ self . compose_and_run_compiler ( rustc, None )
998997 }
999998
1000999 /// `root_out_dir` and `root_testpaths` refer to the parameters of the actual test being run.
10011000 /// Auxiliaries, no matter how deep, have the same root_out_dir and root_testpaths.
1002- fn document (
1001+ fn document ( & self , root_out_dir : & Utf8Path , kind : DocKind ) -> ProcRes {
1002+ self . document_inner ( & self . testpaths . file , root_out_dir, kind)
1003+ }
1004+
1005+ fn document_inner (
10031006 & self ,
1007+ file_to_doc : & Utf8Path ,
10041008 root_out_dir : & Utf8Path ,
1005- root_testpaths : & TestPaths ,
10061009 kind : DocKind ,
10071010 ) -> ProcRes {
10081011 if self . props . build_aux_docs {
10091012 assert_eq ! ( kind, DocKind :: Html , "build-aux-docs only make sense for html output" ) ;
10101013
10111014 for rel_ab in & self . props . aux . builds {
1012- let aux_testpaths = self . compute_aux_test_paths ( root_testpaths, rel_ab) ;
1013- let props_for_aux =
1014- self . props . from_aux_file ( & aux_testpaths. file , self . revision , self . config ) ;
1015+ let aux_path = self . compute_aux_test_paths ( rel_ab) ;
1016+ let props_for_aux = self . props . from_aux_file ( & aux_path, self . revision , self . config ) ;
10151017 let aux_cx = TestCx {
10161018 config : self . config ,
10171019 stdout : self . stdout ,
10181020 stderr : self . stderr ,
10191021 props : & props_for_aux,
1020- testpaths : & aux_testpaths ,
1022+ testpaths : self . testpaths ,
10211023 revision : self . revision ,
10221024 } ;
10231025 // Create the directory for the stdout/stderr files.
10241026 create_dir_all ( aux_cx. output_base_dir ( ) ) . unwrap ( ) ;
1025- // use root_testpaths here, because aux-builds should have the
1026- // same --out-dir and auxiliary directory.
1027- let auxres = aux_cx. document ( & root_out_dir, root_testpaths, kind) ;
1027+ let auxres = aux_cx. document_inner ( & aux_path, & root_out_dir, kind) ;
10281028 if !auxres. status . success ( ) {
10291029 return auxres;
10301030 }
@@ -1038,7 +1038,7 @@ impl<'test> TestCx<'test> {
10381038 // actual --out-dir given to the auxiliary or test, as opposed to the root out dir for the entire
10391039 // test
10401040 let out_dir: Cow < ' _ , Utf8Path > = if self . props . unique_doc_out_dir {
1041- let file_name = self . testpaths . file . file_stem ( ) . expect ( "file name should not be empty" ) ;
1041+ let file_name = file_to_doc . file_stem ( ) . expect ( "file name should not be empty" ) ;
10421042 let out_dir = Utf8PathBuf :: from_iter ( [
10431043 root_out_dir,
10441044 Utf8Path :: new ( "docs" ) ,
@@ -1052,7 +1052,7 @@ impl<'test> TestCx<'test> {
10521052 } ;
10531053
10541054 let mut rustdoc = Command :: new ( rustdoc_path) ;
1055- let current_dir = output_base_dir ( self . config , root_testpaths , self . safe_revision ( ) ) ;
1055+ let current_dir = self . output_base_dir ( ) ;
10561056 rustdoc. current_dir ( current_dir) ;
10571057 rustdoc
10581058 . arg ( "-L" )
@@ -1063,7 +1063,7 @@ impl<'test> TestCx<'test> {
10631063 . arg ( out_dir. as_ref ( ) )
10641064 . arg ( "--deny" )
10651065 . arg ( "warnings" )
1066- . arg ( & self . testpaths . file )
1066+ . arg ( file_to_doc )
10671067 . arg ( "-A" )
10681068 . arg ( "internal_features" )
10691069 . args ( & self . props . compile_flags )
@@ -1080,7 +1080,7 @@ impl<'test> TestCx<'test> {
10801080 rustdoc. arg ( format ! ( "-Clinker={}" , linker) ) ;
10811081 }
10821082
1083- self . compose_and_run_compiler ( rustdoc, None , root_testpaths )
1083+ self . compose_and_run_compiler ( rustdoc, None )
10841084 }
10851085
10861086 fn exec_compiled_test ( & self ) -> ProcRes {
@@ -1195,24 +1195,19 @@ impl<'test> TestCx<'test> {
11951195
11961196 /// For each `aux-build: foo/bar` annotation, we check to find the file in an `auxiliary`
11971197 /// directory relative to the test itself (not any intermediate auxiliaries).
1198- fn compute_aux_test_paths ( & self , of : & TestPaths , rel_ab : & str ) -> TestPaths {
1199- let test_ab =
1200- of. file . parent ( ) . expect ( "test file path has no parent" ) . join ( "auxiliary" ) . join ( rel_ab) ;
1198+ fn compute_aux_test_paths ( & self , rel_ab : & str ) -> Utf8PathBuf {
1199+ let test_ab = self
1200+ . testpaths
1201+ . file
1202+ . parent ( )
1203+ . expect ( "test file path has no parent" )
1204+ . join ( "auxiliary" )
1205+ . join ( rel_ab) ;
12011206 if !test_ab. exists ( ) {
12021207 self . fatal ( & format ! ( "aux-build `{}` source not found" , test_ab) )
12031208 }
12041209
1205- TestPaths {
1206- file : test_ab,
1207- relative_dir : of
1208- . relative_dir
1209- . join ( self . output_testname_unique ( ) )
1210- . join ( "auxiliary" )
1211- . join ( rel_ab)
1212- . parent ( )
1213- . expect ( "aux-build path has no parent" )
1214- . to_path_buf ( ) ,
1215- }
1210+ test_ab
12161211 }
12171212
12181213 fn is_vxworks_pure_static ( & self ) -> bool {
@@ -1258,13 +1253,13 @@ impl<'test> TestCx<'test> {
12581253 aux_dir
12591254 }
12601255
1261- fn build_all_auxiliary ( & self , of : & TestPaths , aux_dir : & Utf8Path , rustc : & mut Command ) {
1256+ fn build_all_auxiliary ( & self , aux_dir : & Utf8Path , rustc : & mut Command ) {
12621257 for rel_ab in & self . props . aux . builds {
1263- self . build_auxiliary ( of , rel_ab, & aux_dir, None ) ;
1258+ self . build_auxiliary ( rel_ab, & aux_dir, None ) ;
12641259 }
12651260
12661261 for rel_ab in & self . props . aux . bins {
1267- self . build_auxiliary ( of , rel_ab, & aux_dir, Some ( AuxType :: Bin ) ) ;
1262+ self . build_auxiliary ( rel_ab, & aux_dir, Some ( AuxType :: Bin ) ) ;
12681263 }
12691264
12701265 let path_to_crate_name = |path : & str | -> String {
@@ -1283,20 +1278,20 @@ impl<'test> TestCx<'test> {
12831278 } ;
12841279
12851280 for ( aux_name, aux_path) in & self . props . aux . crates {
1286- let aux_type = self . build_auxiliary ( of , & aux_path, & aux_dir, None ) ;
1281+ let aux_type = self . build_auxiliary ( & aux_path, & aux_dir, None ) ;
12871282 add_extern ( rustc, aux_name, aux_path, aux_type) ;
12881283 }
12891284
12901285 for proc_macro in & self . props . aux . proc_macros {
1291- self . build_auxiliary ( of , proc_macro, & aux_dir, Some ( AuxType :: ProcMacro ) ) ;
1286+ self . build_auxiliary ( proc_macro, & aux_dir, Some ( AuxType :: ProcMacro ) ) ;
12921287 let crate_name = path_to_crate_name ( proc_macro) ;
12931288 add_extern ( rustc, & crate_name, proc_macro, AuxType :: ProcMacro ) ;
12941289 }
12951290
12961291 // Build any `//@ aux-codegen-backend`, and pass the resulting library
12971292 // to `-Zcodegen-backend` when compiling the test file.
12981293 if let Some ( aux_file) = & self . props . aux . codegen_backend {
1299- let aux_type = self . build_auxiliary ( of , aux_file, aux_dir, None ) ;
1294+ let aux_type = self . build_auxiliary ( aux_file, aux_dir, None ) ;
13001295 if let Some ( lib_name) = get_lib_name ( aux_file. trim_end_matches ( ".rs" ) , aux_type) {
13011296 let lib_path = aux_dir. join ( & lib_name) ;
13021297 rustc. arg ( format ! ( "-Zcodegen-backend={}" , lib_path) ) ;
@@ -1306,20 +1301,15 @@ impl<'test> TestCx<'test> {
13061301
13071302 /// `root_testpaths` refers to the path of the original test. the auxiliary and the test with an
13081303 /// aux-build have the same `root_testpaths`.
1309- fn compose_and_run_compiler (
1310- & self ,
1311- mut rustc : Command ,
1312- input : Option < String > ,
1313- root_testpaths : & TestPaths ,
1314- ) -> ProcRes {
1304+ fn compose_and_run_compiler ( & self , mut rustc : Command , input : Option < String > ) -> ProcRes {
13151305 if self . props . add_core_stubs {
13161306 let minicore_path = self . build_minicore ( ) ;
13171307 rustc. arg ( "--extern" ) ;
13181308 rustc. arg ( & format ! ( "minicore={}" , minicore_path) ) ;
13191309 }
13201310
13211311 let aux_dir = self . aux_output_dir ( ) ;
1322- self . build_all_auxiliary ( root_testpaths , & aux_dir, & mut rustc) ;
1312+ self . build_all_auxiliary ( & aux_dir, & mut rustc) ;
13231313
13241314 rustc. envs ( self . props . rustc_env . clone ( ) ) ;
13251315 self . props . unset_rustc_env . iter ( ) . fold ( & mut rustc, Command :: env_remove) ;
@@ -1364,14 +1354,12 @@ impl<'test> TestCx<'test> {
13641354 /// If `aux_type` is `None`, then this will determine the aux-type automatically.
13651355 fn build_auxiliary (
13661356 & self ,
1367- of : & TestPaths ,
13681357 source_path : & str ,
13691358 aux_dir : & Utf8Path ,
13701359 aux_type : Option < AuxType > ,
13711360 ) -> AuxType {
1372- let aux_testpaths = self . compute_aux_test_paths ( of, source_path) ;
1373- let mut aux_props =
1374- self . props . from_aux_file ( & aux_testpaths. file , self . revision , self . config ) ;
1361+ let aux_path = self . compute_aux_test_paths ( source_path) ;
1362+ let mut aux_props = self . props . from_aux_file ( & aux_path, self . revision , self . config ) ;
13751363 if aux_type == Some ( AuxType :: ProcMacro ) {
13761364 aux_props. force_host = true ;
13771365 }
@@ -1388,21 +1376,20 @@ impl<'test> TestCx<'test> {
13881376 stdout : self . stdout ,
13891377 stderr : self . stderr ,
13901378 props : & aux_props,
1391- testpaths : & aux_testpaths ,
1379+ testpaths : self . testpaths ,
13921380 revision : self . revision ,
13931381 } ;
13941382 // Create the directory for the stdout/stderr files.
13951383 create_dir_all ( aux_cx. output_base_dir ( ) ) . unwrap ( ) ;
1396- let input_file = & aux_testpaths. file ;
13971384 let mut aux_rustc = aux_cx. make_compile_args (
1398- input_file ,
1385+ & aux_path ,
13991386 aux_output,
14001387 Emit :: None ,
14011388 AllowUnused :: No ,
14021389 LinkToAux :: No ,
14031390 Vec :: new ( ) ,
14041391 ) ;
1405- aux_cx. build_all_auxiliary ( of , & aux_dir, & mut aux_rustc) ;
1392+ aux_cx. build_all_auxiliary ( & aux_dir, & mut aux_rustc) ;
14061393
14071394 aux_rustc. envs ( aux_props. rustc_env . clone ( ) ) ;
14081395 for key in & aux_props. unset_rustc_env {
@@ -1471,7 +1458,7 @@ impl<'test> TestCx<'test> {
14711458 ) ;
14721459 if !auxres. status . success ( ) {
14731460 self . fatal_proc_rec (
1474- & format ! ( "auxiliary build of {} failed to compile: " , aux_testpaths . file ) ,
1461+ & format ! ( "auxiliary build of {aux_path } failed to compile: " ) ,
14751462 & auxres,
14761463 ) ;
14771464 }
@@ -2033,11 +2020,6 @@ impl<'test> TestCx<'test> {
20332020 self . aux_output_dir_name ( ) . join ( "bin" )
20342021 }
20352022
2036- /// Generates a unique name for the test, such as `testname.revision.mode`.
2037- fn output_testname_unique ( & self ) -> Utf8PathBuf {
2038- output_testname_unique ( self . config , self . testpaths , self . safe_revision ( ) )
2039- }
2040-
20412023 /// The revision, ignored for incremental compilation since it wants all revisions in
20422024 /// the same directory.
20432025 fn safe_revision ( & self ) -> Option < & str > {
@@ -2132,7 +2114,7 @@ impl<'test> TestCx<'test> {
21322114 Vec :: new ( ) ,
21332115 ) ;
21342116
2135- let proc_res = self . compose_and_run_compiler ( rustc, None , self . testpaths ) ;
2117+ let proc_res = self . compose_and_run_compiler ( rustc, None ) ;
21362118 ( proc_res, output_path)
21372119 }
21382120
@@ -2210,9 +2192,9 @@ impl<'test> TestCx<'test> {
22102192 Vec :: new ( ) ,
22112193 ) ;
22122194 let aux_dir = new_rustdoc. aux_output_dir ( ) ;
2213- new_rustdoc. build_all_auxiliary ( & new_rustdoc . testpaths , & aux_dir, & mut rustc) ;
2195+ new_rustdoc. build_all_auxiliary ( & aux_dir, & mut rustc) ;
22142196
2215- let proc_res = new_rustdoc. document ( & compare_dir, & new_rustdoc . testpaths , DocKind :: Html ) ;
2197+ let proc_res = new_rustdoc. document ( & compare_dir, DocKind :: Html ) ;
22162198 if !proc_res. status . success ( ) {
22172199 writeln ! ( self . stderr, "failed to run nightly rustdoc" ) ;
22182200 return ;
0 commit comments