22
33use crate :: common:: { CompareMode , PassMode } ;
44use crate :: common:: { expected_output_path, UI_EXTENSIONS , UI_FIXED , UI_STDERR , UI_STDOUT } ;
5+ use crate :: common:: { UI_RUN_STDERR , UI_RUN_STDOUT } ;
56use crate :: common:: { output_base_dir, output_base_name, output_testname_unique} ;
67use crate :: common:: { Codegen , CodegenUnits , Rustdoc } ;
78use crate :: common:: { DebugInfoCdb , DebugInfoGdbLldb , DebugInfoGdb , DebugInfoLldb } ;
@@ -288,6 +289,11 @@ enum ReadFrom {
288289 Stdin ( String ) ,
289290}
290291
292+ enum TestOutput {
293+ Compile ,
294+ Run ,
295+ }
296+
291297impl < ' test > TestCx < ' test > {
292298 /// Code executed for each revision in turn (or, if there are no
293299 /// revisions, exactly once, with revision == None).
@@ -2934,9 +2940,16 @@ impl<'test> TestCx<'test> {
29342940 }
29352941 }
29362942
2937- fn load_compare_outputs ( & self , proc_res : & ProcRes , explicit_format : bool ) -> usize {
2938- let expected_stderr = self . load_expected_output ( UI_STDERR ) ;
2939- let expected_stdout = self . load_expected_output ( UI_STDOUT ) ;
2943+ fn load_compare_outputs ( & self , proc_res : & ProcRes ,
2944+ output_kind : TestOutput , explicit_format : bool ) -> usize {
2945+
2946+ let ( stderr_kind, stdout_kind) = match output_kind {
2947+ TestOutput :: Compile => ( UI_STDERR , UI_STDOUT ) ,
2948+ TestOutput :: Run => ( UI_RUN_STDERR , UI_RUN_STDOUT )
2949+ } ;
2950+
2951+ let expected_stderr = self . load_expected_output ( stderr_kind) ;
2952+ let expected_stdout = self . load_expected_output ( stdout_kind) ;
29402953
29412954 let normalized_stdout =
29422955 self . normalize_output ( & proc_res. stdout , & self . props . normalize_stdout ) ;
@@ -2949,11 +2962,19 @@ impl<'test> TestCx<'test> {
29492962
29502963 let normalized_stderr = self . normalize_output ( & stderr, & self . props . normalize_stderr ) ;
29512964 let mut errors = 0 ;
2952- if !self . props . dont_check_compiler_stdout {
2953- errors += self . compare_output ( "stdout" , & normalized_stdout, & expected_stdout) ;
2954- }
2955- if !self . props . dont_check_compiler_stderr {
2956- errors += self . compare_output ( "stderr" , & normalized_stderr, & expected_stderr) ;
2965+ match output_kind {
2966+ TestOutput :: Compile => {
2967+ if !self . props . dont_check_compiler_stdout {
2968+ errors += self . compare_output ( "stdout" , & normalized_stdout, & expected_stdout) ;
2969+ }
2970+ if !self . props . dont_check_compiler_stderr {
2971+ errors += self . compare_output ( "stderr" , & normalized_stderr, & expected_stderr) ;
2972+ }
2973+ }
2974+ TestOutput :: Run => {
2975+ errors += self . compare_output ( stdout_kind, & normalized_stdout, & expected_stdout) ;
2976+ errors += self . compare_output ( stderr_kind, & normalized_stderr, & expected_stderr) ;
2977+ }
29572978 }
29582979 errors
29592980 }
@@ -2975,14 +2996,7 @@ impl<'test> TestCx<'test> {
29752996 let modes_to_prune = vec ! [ CompareMode :: Nll ] ;
29762997 self . prune_duplicate_outputs ( & modes_to_prune) ;
29772998
2978- // if the user specified to check the results of the
2979- // run-pass test, delay loading and comparing output
2980- // until execution of the binary
2981- let mut errors = if !self . props . check_run_results {
2982- self . load_compare_outputs ( & proc_res, explicit)
2983- } else {
2984- 0
2985- } ;
2999+ let mut errors = self . load_compare_outputs ( & proc_res, TestOutput :: Compile , explicit) ;
29863000
29873001 if self . config . compare_mode . is_some ( ) {
29883002 // don't test rustfix with nll right now
@@ -3062,7 +3076,7 @@ impl<'test> TestCx<'test> {
30623076 if self . should_run_successfully ( ) {
30633077 let proc_res = self . exec_compiled_test ( ) ;
30643078 let run_output_errors = if self . props . check_run_results {
3065- self . load_compare_outputs ( & proc_res, explicit)
3079+ self . load_compare_outputs ( & proc_res, TestOutput :: Run , explicit)
30663080 } else {
30673081 0
30683082 } ;
0 commit comments