@@ -735,7 +735,7 @@ impl<'test> TestCx<'test> {
735
735
self . maybe_add_external_args ( & mut rustc, & self . config . target_rustcflags ) ;
736
736
rustc. args ( & self . props . compile_flags ) ;
737
737
738
- self . compose_and_run_compiler ( rustc, Some ( src) )
738
+ self . compose_and_run_compiler ( & self . testpaths , rustc, Some ( src) )
739
739
}
740
740
741
741
fn run_debuginfo_test ( & self ) {
@@ -1591,14 +1591,14 @@ impl<'test> TestCx<'test> {
1591
1591
passes,
1592
1592
) ;
1593
1593
1594
- self . compose_and_run_compiler ( rustc, None )
1594
+ self . compose_and_run_compiler ( & self . testpaths , rustc, None )
1595
1595
}
1596
1596
1597
1597
/// aux: whether we are building the aux docs or main docs
1598
- fn document ( & self , out_dir : & Path ) -> ProcRes {
1598
+ fn document ( & self , out_dir : & Path , of : & TestPaths ) -> ProcRes {
1599
1599
if self . props . build_aux_docs {
1600
1600
for rel_ab in & self . props . aux_builds {
1601
- let aux_testpaths = self . compute_aux_test_paths ( dbg ! ( & self . testpaths ) , dbg ! ( rel_ab) ) ;
1601
+ let aux_testpaths = self . compute_aux_test_paths ( of , rel_ab) ;
1602
1602
let aux_props =
1603
1603
self . props . from_aux_file ( & aux_testpaths. file , self . revision , self . config ) ;
1604
1604
let aux_cx = TestCx {
@@ -1609,12 +1609,7 @@ impl<'test> TestCx<'test> {
1609
1609
} ;
1610
1610
// Create the directory for the stdout/stderr files.
1611
1611
create_dir_all ( aux_cx. output_base_dir ( ) ) . unwrap ( ) ;
1612
- let out_dir = if aux_props. unique_doc_aux_dir {
1613
- out_dir. join ( "docs" ) . join ( rel_ab. trim_end_matches ( ".rs" ) ) . join ( "doc" )
1614
- } else {
1615
- out_dir. to_owned ( )
1616
- } ;
1617
- let auxres = aux_cx. document ( & out_dir) ;
1612
+ let auxres = aux_cx. document ( & out_dir, of) ;
1618
1613
if !auxres. status . success ( ) {
1619
1614
return auxres;
1620
1615
}
@@ -1625,14 +1620,28 @@ impl<'test> TestCx<'test> {
1625
1620
1626
1621
let rustdoc_path = self . config . rustdoc_path . as_ref ( ) . expect ( "--rustdoc-path not passed" ) ;
1627
1622
1623
+ let out_dir = if self . props . unique_doc_aux_dir {
1624
+ let file_name = self . testpaths . file . file_name ( ) . expect ( "file name should not be empty" )
1625
+ . to_str ( )
1626
+ . expect ( "file name utf8" )
1627
+ . trim_end_matches ( ".rs" ) ;
1628
+ let out_dir = out_dir. join ( "docs" ) . join ( file_name) . join ( "doc" ) ;
1629
+ create_dir_all ( & out_dir) . unwrap ( ) ;
1630
+ out_dir
1631
+ } else {
1632
+ out_dir. to_path_buf ( )
1633
+ } ;
1634
+
1628
1635
let mut rustdoc = Command :: new ( rustdoc_path) ;
1636
+ let current_dir = output_base_dir ( self . config , of, self . safe_revision ( ) ) ;
1637
+ rustdoc. current_dir ( current_dir) ;
1629
1638
rustdoc
1630
1639
. arg ( "-L" )
1631
1640
. arg ( self . config . run_lib_path . to_str ( ) . unwrap ( ) )
1632
1641
. arg ( "-L" )
1633
1642
. arg ( aux_dir)
1634
1643
. arg ( "-o" )
1635
- . arg ( out_dir)
1644
+ . arg ( & out_dir)
1636
1645
. arg ( "--deny" )
1637
1646
. arg ( "warnings" )
1638
1647
. arg ( & self . testpaths . file )
@@ -1649,7 +1658,7 @@ impl<'test> TestCx<'test> {
1649
1658
rustdoc. arg ( format ! ( "-Clinker={}" , linker) ) ;
1650
1659
}
1651
1660
1652
- self . compose_and_run_compiler ( rustdoc, None )
1661
+ self . compose_and_run_compiler ( of , rustdoc, None )
1653
1662
}
1654
1663
1655
1664
fn exec_compiled_test ( & self ) -> ProcRes {
@@ -1765,7 +1774,6 @@ impl<'test> TestCx<'test> {
1765
1774
fn compute_aux_test_paths ( & self , of : & TestPaths , rel_ab : & str ) -> TestPaths {
1766
1775
let test_ab =
1767
1776
of. file . parent ( ) . expect ( "test file path has no parent" ) . join ( "auxiliary" ) . join ( rel_ab) ;
1768
- dbg ! ( & of, rel_ab, & test_ab) ;
1769
1777
if !test_ab. exists ( ) {
1770
1778
self . fatal ( & format ! ( "aux-build `{}` source not found" , test_ab. display( ) ) )
1771
1779
}
@@ -1848,9 +1856,9 @@ impl<'test> TestCx<'test> {
1848
1856
}
1849
1857
}
1850
1858
1851
- fn compose_and_run_compiler ( & self , mut rustc : Command , input : Option < String > ) -> ProcRes {
1859
+ fn compose_and_run_compiler ( & self , testpaths : & TestPaths , mut rustc : Command , input : Option < String > ) -> ProcRes {
1852
1860
let aux_dir = self . aux_output_dir ( ) ;
1853
- self . build_all_auxiliary ( & self . testpaths , & aux_dir, & mut rustc) ;
1861
+ self . build_all_auxiliary ( testpaths, & aux_dir, & mut rustc) ;
1854
1862
1855
1863
rustc. envs ( self . props . rustc_env . clone ( ) ) ;
1856
1864
self . props . unset_rustc_env . iter ( ) . fold ( & mut rustc, Command :: env_remove) ;
@@ -1870,7 +1878,7 @@ impl<'test> TestCx<'test> {
1870
1878
aux_dir : & Path ,
1871
1879
is_bin : bool ,
1872
1880
) -> AuxType {
1873
- let aux_testpaths = self . compute_aux_test_paths ( dbg ! ( of ) , dbg ! ( source_path) ) ;
1881
+ let aux_testpaths = self . compute_aux_test_paths ( of , source_path) ;
1874
1882
let aux_props = self . props . from_aux_file ( & aux_testpaths. file , self . revision , self . config ) ;
1875
1883
let mut aux_dir = aux_dir. to_path_buf ( ) ;
1876
1884
if is_bin {
@@ -2041,7 +2049,7 @@ impl<'test> TestCx<'test> {
2041
2049
let is_aux = input_file. components ( ) . map ( |c| c. as_os_str ( ) ) . any ( |c| c == "auxiliary" ) ;
2042
2050
let is_rustdoc = self . is_rustdoc ( ) && !is_aux;
2043
2051
let mut rustc = if !is_rustdoc {
2044
- Command :: new ( & self . config . rustc_path )
2052
+ Command :: new ( dbg ! ( & self . config. rustc_path) )
2045
2053
} else {
2046
2054
Command :: new ( & self . config . rustdoc_path . clone ( ) . expect ( "no rustdoc built yet" ) )
2047
2055
} ;
@@ -2565,7 +2573,7 @@ impl<'test> TestCx<'test> {
2565
2573
Vec :: new ( ) ,
2566
2574
) ;
2567
2575
2568
- let proc_res = self . compose_and_run_compiler ( rustc, None ) ;
2576
+ let proc_res = self . compose_and_run_compiler ( & self . testpaths , rustc, None ) ;
2569
2577
let output_path = self . get_filecheck_file ( "ll" ) ;
2570
2578
( proc_res, output_path)
2571
2579
}
@@ -2601,7 +2609,7 @@ impl<'test> TestCx<'test> {
2601
2609
Vec :: new ( ) ,
2602
2610
) ;
2603
2611
2604
- let proc_res = self . compose_and_run_compiler ( rustc, None ) ;
2612
+ let proc_res = self . compose_and_run_compiler ( & self . testpaths , rustc, None ) ;
2605
2613
let output_path = self . get_filecheck_file ( "s" ) ;
2606
2614
( proc_res, output_path)
2607
2615
}
@@ -2684,7 +2692,7 @@ impl<'test> TestCx<'test> {
2684
2692
let out_dir = self . output_base_dir ( ) ;
2685
2693
remove_and_create_dir_all ( & out_dir) ;
2686
2694
2687
- let proc_res = self . document ( & out_dir) ;
2695
+ let proc_res = self . document ( & out_dir, & self . testpaths ) ;
2688
2696
if !proc_res. status . success ( ) {
2689
2697
self . fatal_proc_rec ( "rustdoc failed!" , & proc_res) ;
2690
2698
}
@@ -2743,7 +2751,7 @@ impl<'test> TestCx<'test> {
2743
2751
let aux_dir = new_rustdoc. aux_output_dir ( ) ;
2744
2752
new_rustdoc. build_all_auxiliary ( & new_rustdoc. testpaths , & aux_dir, & mut rustc) ;
2745
2753
2746
- let proc_res = new_rustdoc. document ( & compare_dir) ;
2754
+ let proc_res = new_rustdoc. document ( & compare_dir, & new_rustdoc . testpaths ) ;
2747
2755
if !proc_res. status . success ( ) {
2748
2756
eprintln ! ( "failed to run nightly rustdoc" ) ;
2749
2757
return ;
@@ -2866,7 +2874,7 @@ impl<'test> TestCx<'test> {
2866
2874
let out_dir = self . output_base_dir ( ) ;
2867
2875
remove_and_create_dir_all ( & out_dir) ;
2868
2876
2869
- let proc_res = self . document ( & out_dir) ;
2877
+ let proc_res = self . document ( & out_dir, & self . testpaths ) ;
2870
2878
if !proc_res. status . success ( ) {
2871
2879
self . fatal_proc_rec ( "rustdoc failed!" , & proc_res) ;
2872
2880
}
@@ -2942,28 +2950,27 @@ impl<'test> TestCx<'test> {
2942
2950
fn check_rustdoc_test_option ( & self , res : ProcRes ) {
2943
2951
let mut other_files = Vec :: new ( ) ;
2944
2952
let mut files: HashMap < String , Vec < usize > > = HashMap :: new ( ) ;
2945
- let cwd = env:: current_dir ( ) . unwrap ( ) ;
2946
- files. insert (
2947
- self . testpaths
2948
- . file
2949
- . strip_prefix ( & cwd)
2950
- . unwrap_or ( & self . testpaths . file )
2953
+ let testpath = fs:: canonicalize ( & self . testpaths . file )
2954
+ . expect ( "failed to canonicalize" ) ;
2955
+ let testpath = testpath
2951
2956
. to_str ( )
2952
2957
. unwrap ( )
2953
- . replace ( '\\' , "/" ) ,
2958
+ . replace ( '\\' , "/" ) ;
2959
+ files. insert (
2960
+ testpath,
2954
2961
self . get_lines ( & self . testpaths . file , Some ( & mut other_files) ) ,
2955
2962
) ;
2956
2963
for other_file in other_files {
2957
2964
let mut path = self . testpaths . file . clone ( ) ;
2958
2965
path. set_file_name ( & format ! ( "{}.rs" , other_file) ) ;
2959
- files. insert (
2960
- path. strip_prefix ( & cwd) . unwrap_or ( & path) . to_str ( ) . unwrap ( ) . replace ( '\\' , "/" ) ,
2961
- self . get_lines ( & path, None ) ,
2962
- ) ;
2966
+ let path = fs:: canonicalize ( path) . expect ( "failed to canonicalize" ) ;
2967
+ let normalized = path. to_str ( ) . unwrap ( ) . replace ( '\\' , "/" ) ;
2968
+ files. insert ( normalized, self . get_lines ( & path, None ) ) ;
2963
2969
}
2964
2970
2965
2971
let mut tested = 0 ;
2966
2972
for _ in res. stdout . split ( '\n' ) . filter ( |s| s. starts_with ( "test " ) ) . inspect ( |s| {
2973
+ dbg ! ( & s) ;
2967
2974
if let Some ( ( left, right) ) = s. split_once ( " - " ) {
2968
2975
let path = left. rsplit ( "test " ) . next ( ) . unwrap ( ) ;
2969
2976
if let Some ( ref mut v) = files. get_mut ( & path. replace ( '\\' , "/" ) ) {
@@ -3796,7 +3803,7 @@ impl<'test> TestCx<'test> {
3796
3803
if let Some ( nodejs) = & self . config . nodejs {
3797
3804
let out_dir = self . output_base_dir ( ) ;
3798
3805
3799
- self . document ( & out_dir) ;
3806
+ self . document ( & out_dir, & self . testpaths ) ;
3800
3807
3801
3808
let root = self . config . find_rust_src_root ( ) . unwrap ( ) ;
3802
3809
let file_stem =
@@ -4112,7 +4119,7 @@ impl<'test> TestCx<'test> {
4112
4119
rustc. arg ( crate_name) ;
4113
4120
}
4114
4121
4115
- let res = self . compose_and_run_compiler ( rustc, None ) ;
4122
+ let res = self . compose_and_run_compiler ( & self . testpaths , rustc, None ) ;
4116
4123
if !res. status . success ( ) {
4117
4124
self . fatal_proc_rec ( "failed to compile fixed code" , & res) ;
4118
4125
}
0 commit comments