@@ -21,7 +21,6 @@ use colored::Colorize;
2121use miropt_test_tools:: { files_for_miropt_test, MiroptTest , MiroptTestFile } ;
2222use regex:: { Captures , Regex } ;
2323use rustfix:: { apply_suggestions, get_suggestions_from_json, Filter } ;
24- use std:: borrow:: Cow ;
2524use std:: collections:: { HashMap , HashSet } ;
2625use std:: env;
2726use std:: ffi:: { OsStr , OsString } ;
@@ -732,7 +731,7 @@ impl<'test> TestCx<'test> {
732731 self . maybe_add_external_args ( & mut rustc, & self . config . target_rustcflags ) ;
733732 rustc. args ( & self . props . compile_flags ) ;
734733
735- self . compose_and_run_compiler ( rustc, Some ( src) , self . testpaths )
734+ self . compose_and_run_compiler ( rustc, Some ( src) )
736735 }
737736
738737 fn run_debuginfo_test ( & self ) {
@@ -1588,15 +1587,13 @@ impl<'test> TestCx<'test> {
15881587 passes,
15891588 ) ;
15901589
1591- self . compose_and_run_compiler ( rustc, None , self . testpaths )
1590+ self . compose_and_run_compiler ( rustc, None )
15921591 }
15931592
1594- /// `root_out_dir` and `root_testpaths` refer to the parameters of the actual test being run.
1595- /// Auxiliaries, no matter how deep, have the same root_out_dir and root_testpaths.
1596- fn document ( & self , root_out_dir : & Path , root_testpaths : & TestPaths ) -> ProcRes {
1593+ fn document ( & self , out_dir : & Path ) -> ProcRes {
15971594 if self . props . build_aux_docs {
15981595 for rel_ab in & self . props . aux_builds {
1599- let aux_testpaths = self . compute_aux_test_paths ( root_testpaths , rel_ab) ;
1596+ let aux_testpaths = self . compute_aux_test_paths ( & self . testpaths , rel_ab) ;
16001597 let aux_props =
16011598 self . props . from_aux_file ( & aux_testpaths. file , self . revision , self . config ) ;
16021599 let aux_cx = TestCx {
@@ -1607,7 +1604,7 @@ impl<'test> TestCx<'test> {
16071604 } ;
16081605 // Create the directory for the stdout/stderr files.
16091606 create_dir_all ( aux_cx. output_base_dir ( ) ) . unwrap ( ) ;
1610- let auxres = aux_cx. document ( & root_out_dir , root_testpaths ) ;
1607+ let auxres = aux_cx. document ( out_dir ) ;
16111608 if !auxres. status . success ( ) {
16121609 return auxres;
16131610 }
@@ -1617,47 +1614,21 @@ impl<'test> TestCx<'test> {
16171614 let aux_dir = self . aux_output_dir_name ( ) ;
16181615
16191616 let rustdoc_path = self . config . rustdoc_path . as_ref ( ) . expect ( "--rustdoc-path not passed" ) ;
1620-
1621- // actual --out-dir given to the auxiliary or test, as opposed to the root out dir for the entire
1622- // test
1623- let out_dir: Cow < ' _ , Path > = if self . props . unique_doc_out_dir {
1624- let file_name = self
1625- . testpaths
1626- . file
1627- . file_name ( )
1628- . expect ( "file name should not be empty" )
1629- . to_str ( )
1630- . expect ( "file name utf8" )
1631- . trim_end_matches ( ".rs" ) ;
1632- let out_dir = PathBuf :: from_iter ( [
1633- root_out_dir,
1634- Path :: new ( "docs" ) ,
1635- Path :: new ( file_name) ,
1636- Path :: new ( "doc" ) ,
1637- ] ) ;
1638- create_dir_all ( & out_dir) . unwrap ( ) ;
1639- Cow :: Owned ( out_dir)
1640- } else {
1641- Cow :: Borrowed ( root_out_dir)
1642- } ;
1643-
16441617 let mut rustdoc = Command :: new ( rustdoc_path) ;
1645- let current_dir = output_base_dir ( self . config , root_testpaths, self . safe_revision ( ) ) ;
1646- rustdoc. current_dir ( current_dir) ;
1618+
16471619 rustdoc
16481620 . arg ( "-L" )
16491621 . arg ( self . config . run_lib_path . to_str ( ) . unwrap ( ) )
16501622 . arg ( "-L" )
16511623 . arg ( aux_dir)
16521624 . arg ( "-o" )
1653- . arg ( out_dir. as_ref ( ) )
1625+ . arg ( out_dir)
16541626 . arg ( "--deny" )
16551627 . arg ( "warnings" )
16561628 . arg ( & self . testpaths . file )
16571629 . arg ( "-A" )
16581630 . arg ( "internal_features" )
1659- . args ( & self . props . compile_flags )
1660- . args ( & self . props . doc_flags ) ;
1631+ . args ( & self . props . compile_flags ) ;
16611632
16621633 if self . config . mode == RustdocJson {
16631634 rustdoc. arg ( "--output-format" ) . arg ( "json" ) . arg ( "-Zunstable-options" ) ;
@@ -1667,7 +1638,7 @@ impl<'test> TestCx<'test> {
16671638 rustdoc. arg ( format ! ( "-Clinker={}" , linker) ) ;
16681639 }
16691640
1670- self . compose_and_run_compiler ( rustdoc, None , root_testpaths )
1641+ self . compose_and_run_compiler ( rustdoc, None )
16711642 }
16721643
16731644 fn exec_compiled_test ( & self ) -> ProcRes {
@@ -1865,16 +1836,9 @@ impl<'test> TestCx<'test> {
18651836 }
18661837 }
18671838
1868- /// `root_testpaths` refers to the path of the original test.
1869- /// the auxiliary and the test with an aux-build have the same `root_testpaths`.
1870- fn compose_and_run_compiler (
1871- & self ,
1872- mut rustc : Command ,
1873- input : Option < String > ,
1874- root_testpaths : & TestPaths ,
1875- ) -> ProcRes {
1839+ fn compose_and_run_compiler ( & self , mut rustc : Command , input : Option < String > ) -> ProcRes {
18761840 let aux_dir = self . aux_output_dir ( ) ;
1877- self . build_all_auxiliary ( root_testpaths , & aux_dir, & mut rustc) ;
1841+ self . build_all_auxiliary ( & self . testpaths , & aux_dir, & mut rustc) ;
18781842
18791843 rustc. envs ( self . props . rustc_env . clone ( ) ) ;
18801844 self . props . unset_rustc_env . iter ( ) . fold ( & mut rustc, Command :: env_remove) ;
@@ -2589,7 +2553,7 @@ impl<'test> TestCx<'test> {
25892553 Vec :: new ( ) ,
25902554 ) ;
25912555
2592- let proc_res = self . compose_and_run_compiler ( rustc, None , self . testpaths ) ;
2556+ let proc_res = self . compose_and_run_compiler ( rustc, None ) ;
25932557 let output_path = self . get_filecheck_file ( "ll" ) ;
25942558 ( proc_res, output_path)
25952559 }
@@ -2625,7 +2589,7 @@ impl<'test> TestCx<'test> {
26252589 Vec :: new ( ) ,
26262590 ) ;
26272591
2628- let proc_res = self . compose_and_run_compiler ( rustc, None , self . testpaths ) ;
2592+ let proc_res = self . compose_and_run_compiler ( rustc, None ) ;
26292593 let output_path = self . get_filecheck_file ( "s" ) ;
26302594 ( proc_res, output_path)
26312595 }
@@ -2708,7 +2672,7 @@ impl<'test> TestCx<'test> {
27082672 let out_dir = self . output_base_dir ( ) ;
27092673 remove_and_create_dir_all ( & out_dir) ;
27102674
2711- let proc_res = self . document ( & out_dir, & self . testpaths ) ;
2675+ let proc_res = self . document ( & out_dir) ;
27122676 if !proc_res. status . success ( ) {
27132677 self . fatal_proc_rec ( "rustdoc failed!" , & proc_res) ;
27142678 }
@@ -2767,7 +2731,7 @@ impl<'test> TestCx<'test> {
27672731 let aux_dir = new_rustdoc. aux_output_dir ( ) ;
27682732 new_rustdoc. build_all_auxiliary ( & new_rustdoc. testpaths , & aux_dir, & mut rustc) ;
27692733
2770- let proc_res = new_rustdoc. document ( & compare_dir, & new_rustdoc . testpaths ) ;
2734+ let proc_res = new_rustdoc. document ( & compare_dir) ;
27712735 if !proc_res. status . success ( ) {
27722736 eprintln ! ( "failed to run nightly rustdoc" ) ;
27732737 return ;
@@ -2890,7 +2854,7 @@ impl<'test> TestCx<'test> {
28902854 let out_dir = self . output_base_dir ( ) ;
28912855 remove_and_create_dir_all ( & out_dir) ;
28922856
2893- let proc_res = self . document ( & out_dir, & self . testpaths ) ;
2857+ let proc_res = self . document ( & out_dir) ;
28942858 if !proc_res. status . success ( ) {
28952859 self . fatal_proc_rec ( "rustdoc failed!" , & proc_res) ;
28962860 }
@@ -2966,15 +2930,24 @@ impl<'test> TestCx<'test> {
29662930 fn check_rustdoc_test_option ( & self , res : ProcRes ) {
29672931 let mut other_files = Vec :: new ( ) ;
29682932 let mut files: HashMap < String , Vec < usize > > = HashMap :: new ( ) ;
2969- let normalized = fs:: canonicalize ( & self . testpaths . file ) . expect ( "failed to canonicalize" ) ;
2970- let normalized = normalized. to_str ( ) . unwrap ( ) . replace ( '\\' , "/" ) ;
2971- files. insert ( normalized, self . get_lines ( & self . testpaths . file , Some ( & mut other_files) ) ) ;
2933+ let cwd = env:: current_dir ( ) . unwrap ( ) ;
2934+ files. insert (
2935+ self . testpaths
2936+ . file
2937+ . strip_prefix ( & cwd)
2938+ . unwrap_or ( & self . testpaths . file )
2939+ . to_str ( )
2940+ . unwrap ( )
2941+ . replace ( '\\' , "/" ) ,
2942+ self . get_lines ( & self . testpaths . file , Some ( & mut other_files) ) ,
2943+ ) ;
29722944 for other_file in other_files {
29732945 let mut path = self . testpaths . file . clone ( ) ;
29742946 path. set_file_name ( & format ! ( "{}.rs" , other_file) ) ;
2975- let path = fs:: canonicalize ( path) . expect ( "failed to canonicalize" ) ;
2976- let normalized = path. to_str ( ) . unwrap ( ) . replace ( '\\' , "/" ) ;
2977- files. insert ( normalized, self . get_lines ( & path, None ) ) ;
2947+ files. insert (
2948+ path. strip_prefix ( & cwd) . unwrap_or ( & path) . to_str ( ) . unwrap ( ) . replace ( '\\' , "/" ) ,
2949+ self . get_lines ( & path, None ) ,
2950+ ) ;
29782951 }
29792952
29802953 let mut tested = 0 ;
@@ -3813,7 +3786,7 @@ impl<'test> TestCx<'test> {
38133786 if let Some ( nodejs) = & self . config . nodejs {
38143787 let out_dir = self . output_base_dir ( ) ;
38153788
3816- self . document ( & out_dir, & self . testpaths ) ;
3789+ self . document ( & out_dir) ;
38173790
38183791 let root = self . config . find_rust_src_root ( ) . unwrap ( ) ;
38193792 let file_stem =
@@ -4129,7 +4102,7 @@ impl<'test> TestCx<'test> {
41294102 rustc. arg ( crate_name) ;
41304103 }
41314104
4132- let res = self . compose_and_run_compiler ( rustc, None , self . testpaths ) ;
4105+ let res = self . compose_and_run_compiler ( rustc, None ) ;
41334106 if !res. status . success ( ) {
41344107 self . fatal_proc_rec ( "failed to compile fixed code" , & res) ;
41354108 }
0 commit comments