@@ -21,7 +21,6 @@ use colored::Colorize;
21
21
use miropt_test_tools:: { files_for_miropt_test, MiroptTest , MiroptTestFile } ;
22
22
use regex:: { Captures , Regex } ;
23
23
use rustfix:: { apply_suggestions, get_suggestions_from_json, Filter } ;
24
- use std:: borrow:: Cow ;
25
24
use std:: collections:: { HashMap , HashSet } ;
26
25
use std:: env;
27
26
use std:: ffi:: { OsStr , OsString } ;
@@ -732,7 +731,7 @@ impl<'test> TestCx<'test> {
732
731
self . maybe_add_external_args ( & mut rustc, & self . config . target_rustcflags ) ;
733
732
rustc. args ( & self . props . compile_flags ) ;
734
733
735
- self . compose_and_run_compiler ( rustc, Some ( src) , self . testpaths )
734
+ self . compose_and_run_compiler ( rustc, Some ( src) )
736
735
}
737
736
738
737
fn run_debuginfo_test ( & self ) {
@@ -1588,15 +1587,13 @@ impl<'test> TestCx<'test> {
1588
1587
passes,
1589
1588
) ;
1590
1589
1591
- self . compose_and_run_compiler ( rustc, None , self . testpaths )
1590
+ self . compose_and_run_compiler ( rustc, None )
1592
1591
}
1593
1592
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 {
1597
1594
if self . props . build_aux_docs {
1598
1595
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) ;
1600
1597
let aux_props =
1601
1598
self . props . from_aux_file ( & aux_testpaths. file , self . revision , self . config ) ;
1602
1599
let aux_cx = TestCx {
@@ -1607,7 +1604,7 @@ impl<'test> TestCx<'test> {
1607
1604
} ;
1608
1605
// Create the directory for the stdout/stderr files.
1609
1606
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 ) ;
1611
1608
if !auxres. status . success ( ) {
1612
1609
return auxres;
1613
1610
}
@@ -1617,47 +1614,21 @@ impl<'test> TestCx<'test> {
1617
1614
let aux_dir = self . aux_output_dir_name ( ) ;
1618
1615
1619
1616
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
-
1644
1617
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
+
1647
1619
rustdoc
1648
1620
. arg ( "-L" )
1649
1621
. arg ( self . config . run_lib_path . to_str ( ) . unwrap ( ) )
1650
1622
. arg ( "-L" )
1651
1623
. arg ( aux_dir)
1652
1624
. arg ( "-o" )
1653
- . arg ( out_dir. as_ref ( ) )
1625
+ . arg ( out_dir)
1654
1626
. arg ( "--deny" )
1655
1627
. arg ( "warnings" )
1656
1628
. arg ( & self . testpaths . file )
1657
1629
. arg ( "-A" )
1658
1630
. arg ( "internal_features" )
1659
- . args ( & self . props . compile_flags )
1660
- . args ( & self . props . doc_flags ) ;
1631
+ . args ( & self . props . compile_flags ) ;
1661
1632
1662
1633
if self . config . mode == RustdocJson {
1663
1634
rustdoc. arg ( "--output-format" ) . arg ( "json" ) . arg ( "-Zunstable-options" ) ;
@@ -1667,7 +1638,7 @@ impl<'test> TestCx<'test> {
1667
1638
rustdoc. arg ( format ! ( "-Clinker={}" , linker) ) ;
1668
1639
}
1669
1640
1670
- self . compose_and_run_compiler ( rustdoc, None , root_testpaths )
1641
+ self . compose_and_run_compiler ( rustdoc, None )
1671
1642
}
1672
1643
1673
1644
fn exec_compiled_test ( & self ) -> ProcRes {
@@ -1865,16 +1836,9 @@ impl<'test> TestCx<'test> {
1865
1836
}
1866
1837
}
1867
1838
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 {
1876
1840
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) ;
1878
1842
1879
1843
rustc. envs ( self . props . rustc_env . clone ( ) ) ;
1880
1844
self . props . unset_rustc_env . iter ( ) . fold ( & mut rustc, Command :: env_remove) ;
@@ -2589,7 +2553,7 @@ impl<'test> TestCx<'test> {
2589
2553
Vec :: new ( ) ,
2590
2554
) ;
2591
2555
2592
- let proc_res = self . compose_and_run_compiler ( rustc, None , self . testpaths ) ;
2556
+ let proc_res = self . compose_and_run_compiler ( rustc, None ) ;
2593
2557
let output_path = self . get_filecheck_file ( "ll" ) ;
2594
2558
( proc_res, output_path)
2595
2559
}
@@ -2625,7 +2589,7 @@ impl<'test> TestCx<'test> {
2625
2589
Vec :: new ( ) ,
2626
2590
) ;
2627
2591
2628
- let proc_res = self . compose_and_run_compiler ( rustc, None , self . testpaths ) ;
2592
+ let proc_res = self . compose_and_run_compiler ( rustc, None ) ;
2629
2593
let output_path = self . get_filecheck_file ( "s" ) ;
2630
2594
( proc_res, output_path)
2631
2595
}
@@ -2708,7 +2672,7 @@ impl<'test> TestCx<'test> {
2708
2672
let out_dir = self . output_base_dir ( ) ;
2709
2673
remove_and_create_dir_all ( & out_dir) ;
2710
2674
2711
- let proc_res = self . document ( & out_dir, & self . testpaths ) ;
2675
+ let proc_res = self . document ( & out_dir) ;
2712
2676
if !proc_res. status . success ( ) {
2713
2677
self . fatal_proc_rec ( "rustdoc failed!" , & proc_res) ;
2714
2678
}
@@ -2767,7 +2731,7 @@ impl<'test> TestCx<'test> {
2767
2731
let aux_dir = new_rustdoc. aux_output_dir ( ) ;
2768
2732
new_rustdoc. build_all_auxiliary ( & new_rustdoc. testpaths , & aux_dir, & mut rustc) ;
2769
2733
2770
- let proc_res = new_rustdoc. document ( & compare_dir, & new_rustdoc . testpaths ) ;
2734
+ let proc_res = new_rustdoc. document ( & compare_dir) ;
2771
2735
if !proc_res. status . success ( ) {
2772
2736
eprintln ! ( "failed to run nightly rustdoc" ) ;
2773
2737
return ;
@@ -2890,7 +2854,7 @@ impl<'test> TestCx<'test> {
2890
2854
let out_dir = self . output_base_dir ( ) ;
2891
2855
remove_and_create_dir_all ( & out_dir) ;
2892
2856
2893
- let proc_res = self . document ( & out_dir, & self . testpaths ) ;
2857
+ let proc_res = self . document ( & out_dir) ;
2894
2858
if !proc_res. status . success ( ) {
2895
2859
self . fatal_proc_rec ( "rustdoc failed!" , & proc_res) ;
2896
2860
}
@@ -2966,15 +2930,24 @@ impl<'test> TestCx<'test> {
2966
2930
fn check_rustdoc_test_option ( & self , res : ProcRes ) {
2967
2931
let mut other_files = Vec :: new ( ) ;
2968
2932
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
+ ) ;
2972
2944
for other_file in other_files {
2973
2945
let mut path = self . testpaths . file . clone ( ) ;
2974
2946
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
+ ) ;
2978
2951
}
2979
2952
2980
2953
let mut tested = 0 ;
@@ -3813,7 +3786,7 @@ impl<'test> TestCx<'test> {
3813
3786
if let Some ( nodejs) = & self . config . nodejs {
3814
3787
let out_dir = self . output_base_dir ( ) ;
3815
3788
3816
- self . document ( & out_dir, & self . testpaths ) ;
3789
+ self . document ( & out_dir) ;
3817
3790
3818
3791
let root = self . config . find_rust_src_root ( ) . unwrap ( ) ;
3819
3792
let file_stem =
@@ -4129,7 +4102,7 @@ impl<'test> TestCx<'test> {
4129
4102
rustc. arg ( crate_name) ;
4130
4103
}
4131
4104
4132
- let res = self . compose_and_run_compiler ( rustc, None , self . testpaths ) ;
4105
+ let res = self . compose_and_run_compiler ( rustc, None ) ;
4133
4106
if !res. status . success ( ) {
4134
4107
self . fatal_proc_rec ( "failed to compile fixed code" , & res) ;
4135
4108
}
0 commit comments