@@ -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 ;
@@ -1683,6 +1684,13 @@ impl<'test> TestCx<'test> {
1683
1684
}
1684
1685
}
1685
1686
1687
+ match self . config . compare_mode {
1688
+ Some ( CompareMode :: Nll ) => {
1689
+ rustc. args ( & [ "-Znll" , "-Zborrowck=mir" , "-Ztwo-phase-borrows" ] ) ;
1690
+ } ,
1691
+ None => { } ,
1692
+ }
1693
+
1686
1694
if self . props . force_host {
1687
1695
rustc. args ( self . split_maybe_args ( & self . config . host_rustcflags ) ) ;
1688
1696
} else {
@@ -2505,11 +2513,8 @@ impl<'test> TestCx<'test> {
2505
2513
let proc_res = self . compile_test ( ) ;
2506
2514
self . check_if_test_should_compile ( & proc_res) ;
2507
2515
2508
- let expected_stderr_path = self . expected_output_path ( UI_STDERR ) ;
2509
- let expected_stderr = self . load_expected_output ( & expected_stderr_path) ;
2510
-
2511
- let expected_stdout_path = self . expected_output_path ( UI_STDOUT ) ;
2512
- let expected_stdout = self . load_expected_output ( & expected_stdout_path) ;
2516
+ let expected_stderr = self . load_expected_output ( UI_STDERR ) ;
2517
+ let expected_stdout = self . load_expected_output ( UI_STDOUT ) ;
2513
2518
2514
2519
let normalized_stdout =
2515
2520
self . normalize_output ( & proc_res. stdout , & self . props . normalize_stdout ) ;
@@ -2552,7 +2557,7 @@ impl<'test> TestCx<'test> {
2552
2557
self . fatal_proc_rec ( "test run failed!" , & proc_res) ;
2553
2558
}
2554
2559
}
2555
- if !explicit {
2560
+ if !explicit && self . config . compare_mode . is_none ( ) {
2556
2561
if !expected_errors. is_empty ( ) || !proc_res. status . success ( ) {
2557
2562
// "// error-pattern" comments
2558
2563
self . check_expected_errors ( expected_errors, & proc_res) ;
@@ -2795,19 +2800,32 @@ impl<'test> TestCx<'test> {
2795
2800
normalized
2796
2801
}
2797
2802
2798
- fn expected_output_path ( & self , kind : & str ) -> PathBuf {
2799
- expected_output_path ( & self . testpaths , self . revision , kind)
2800
- }
2803
+ fn load_expected_output ( & self , kind : & str ) -> String {
2804
+ let mut path = expected_output_path ( & self . testpaths ,
2805
+ self . revision ,
2806
+ & self . config . compare_mode ,
2807
+ kind) ;
2801
2808
2802
- fn load_expected_output ( & self , path : & Path ) -> String {
2803
- if !path . exists ( ) {
2804
- return String :: new ( ) ;
2809
+ if ! path. exists ( ) && self . config . compare_mode . is_some ( ) {
2810
+ // fallback!
2811
+ path = expected_output_path ( & self . testpaths , self . revision , & None , kind ) ;
2805
2812
}
2806
2813
2814
+ if path. exists ( ) {
2815
+ match self . load_expected_output_from_path ( & path) {
2816
+ Ok ( x) => x,
2817
+ Err ( x) => self . fatal ( & x) ,
2818
+ }
2819
+ } else {
2820
+ String :: new ( )
2821
+ }
2822
+ }
2823
+
2824
+ fn load_expected_output_from_path ( & self , path : & Path ) -> Result < String , String > {
2807
2825
let mut result = String :: new ( ) ;
2808
2826
match File :: open ( path) . and_then ( |mut f| f. read_to_string ( & mut result) ) {
2809
- Ok ( _) => result,
2810
- Err ( e) => self . fatal ( & format ! (
2827
+ Ok ( _) => Ok ( result) ,
2828
+ Err ( e) => Err ( format ! (
2811
2829
"failed to load expected output from `{}`: {}" ,
2812
2830
path. display( ) ,
2813
2831
e
0 commit comments