@@ -13,6 +13,7 @@ use common::{CompileFail, ParseFail, Pretty, RunFail, RunPass, RunPassValgrind};
13
13
use common:: { Codegen , CodegenUnits , DebugInfoGdb , DebugInfoLldb , Rustdoc } ;
14
14
use common:: { Incremental , MirOpt , RunMake , Ui } ;
15
15
use common:: { expected_output_path, UI_STDERR , UI_STDOUT } ;
16
+ use common:: CompareMode ;
16
17
use diff;
17
18
use errors:: { self , Error , ErrorKind } ;
18
19
use filetime:: FileTime ;
@@ -1681,6 +1682,13 @@ impl<'test> TestCx<'test> {
1681
1682
}
1682
1683
}
1683
1684
1685
+ match self . config . compare_mode {
1686
+ Some ( CompareMode :: Nll ) => {
1687
+ rustc. args ( & [ "-Znll" , "-Zborrowck=mir" , "-Ztwo-phase-borrows" ] ) ;
1688
+ } ,
1689
+ None => { } ,
1690
+ }
1691
+
1684
1692
if self . props . force_host {
1685
1693
rustc. args ( self . split_maybe_args ( & self . config . host_rustcflags ) ) ;
1686
1694
} else {
@@ -2507,11 +2515,8 @@ impl<'test> TestCx<'test> {
2507
2515
let proc_res = self . compile_test ( ) ;
2508
2516
self . check_if_test_should_compile ( & proc_res) ;
2509
2517
2510
- let expected_stderr_path = self . expected_output_path ( UI_STDERR ) ;
2511
- let expected_stderr = self . load_expected_output ( & expected_stderr_path) ;
2512
-
2513
- let expected_stdout_path = self . expected_output_path ( UI_STDOUT ) ;
2514
- let expected_stdout = self . load_expected_output ( & expected_stdout_path) ;
2518
+ let expected_stderr = self . load_expected_output ( UI_STDERR ) ;
2519
+ let expected_stdout = self . load_expected_output ( UI_STDOUT ) ;
2515
2520
2516
2521
let normalized_stdout =
2517
2522
self . normalize_output ( & proc_res. stdout , & self . props . normalize_stdout ) ;
@@ -2797,19 +2802,31 @@ impl<'test> TestCx<'test> {
2797
2802
normalized
2798
2803
}
2799
2804
2800
- fn expected_output_path ( & self , kind : & str ) -> PathBuf {
2801
- expected_output_path ( & self . testpaths , self . revision , kind)
2802
- }
2805
+ fn expected_output_path ( & self , kind : & str ) -> Result < PathBuf , String > {
2806
+ let mut path = expected_output_path ( & self . testpaths , self . revision , & self . config . compare_mode , kind) ;
2807
+ if !path. exists ( ) && self . config . compare_mode . is_some ( ) {
2808
+ // fallback!
2809
+ path = expected_output_path ( & self . testpaths , self . revision , & None , kind) ;
2810
+ }
2803
2811
2804
- fn load_expected_output ( & self , path : & Path ) -> String {
2805
- if !path. exists ( ) {
2806
- return String :: new ( ) ;
2812
+ if path. exists ( ) {
2813
+ Ok ( path)
2814
+ } else {
2815
+ Err ( String :: from ( "no existing output_path found" ) )
2807
2816
}
2817
+ }
2808
2818
2819
+ fn load_expected_output ( & self , kind : & str ) -> String {
2820
+ self . expected_output_path ( kind)
2821
+ . and_then ( |x| self . load_expected_output_from_path ( & x) )
2822
+ . unwrap_or_else ( |x| self . fatal ( & x) )
2823
+ }
2824
+
2825
+ fn load_expected_output_from_path ( & self , path : & Path ) -> Result < String , String > {
2809
2826
let mut result = String :: new ( ) ;
2810
2827
match File :: open ( path) . and_then ( |mut f| f. read_to_string ( & mut result) ) {
2811
- Ok ( _) => result,
2812
- Err ( e) => self . fatal ( & format ! (
2828
+ Ok ( _) => Ok ( result) ,
2829
+ Err ( e) => Err ( format ! (
2813
2830
"failed to load expected output from `{}`: {}" ,
2814
2831
path. display( ) ,
2815
2832
e
0 commit comments