@@ -13,6 +13,7 @@ use common::{CompileFail, ParseFail, Pretty, RunFail, RunPass, RunPassValgrind};
1313use common:: { Codegen , CodegenUnits , DebugInfoGdb , DebugInfoLldb , Rustdoc } ;
1414use common:: { Incremental , MirOpt , RunMake , Ui } ;
1515use common:: { expected_output_path, UI_STDERR , UI_STDOUT } ;
16+ use common:: CompareMode ;
1617use diff;
1718use errors:: { self , Error , ErrorKind } ;
1819use filetime:: FileTime ;
@@ -1683,6 +1684,13 @@ impl<'test> TestCx<'test> {
16831684 }
16841685 }
16851686
1687+ match self . config . compare_mode {
1688+ Some ( CompareMode :: Nll ) => {
1689+ rustc. args ( & [ "-Znll" , "-Zborrowck=mir" , "-Ztwo-phase-borrows" ] ) ;
1690+ } ,
1691+ None => { } ,
1692+ }
1693+
16861694 if self . props . force_host {
16871695 rustc. args ( self . split_maybe_args ( & self . config . host_rustcflags ) ) ;
16881696 } else {
@@ -2505,11 +2513,8 @@ impl<'test> TestCx<'test> {
25052513 let proc_res = self . compile_test ( ) ;
25062514 self . check_if_test_should_compile ( & proc_res) ;
25072515
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 ) ;
25132518
25142519 let normalized_stdout =
25152520 self . normalize_output ( & proc_res. stdout , & self . props . normalize_stdout ) ;
@@ -2552,7 +2557,7 @@ impl<'test> TestCx<'test> {
25522557 self . fatal_proc_rec ( "test run failed!" , & proc_res) ;
25532558 }
25542559 }
2555- if !explicit {
2560+ if !explicit && self . config . compare_mode . is_none ( ) {
25562561 if !expected_errors. is_empty ( ) || !proc_res. status . success ( ) {
25572562 // "// error-pattern" comments
25582563 self . check_expected_errors ( expected_errors, & proc_res) ;
@@ -2795,19 +2800,32 @@ impl<'test> TestCx<'test> {
27952800 normalized
27962801 }
27972802
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) ;
28012808
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 ) ;
28052812 }
28062813
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 > {
28072825 let mut result = String :: new ( ) ;
28082826 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 ! (
28112829 "failed to load expected output from `{}`: {}" ,
28122830 path. display( ) ,
28132831 e
0 commit comments