2
2
3
3
use crate :: common:: { CompareMode , PassMode } ;
4
4
use crate :: common:: { expected_output_path, UI_EXTENSIONS , UI_FIXED , UI_STDERR , UI_STDOUT } ;
5
+ use crate :: common:: { UI_RUN_STDERR , UI_RUN_STDOUT } ;
5
6
use crate :: common:: { output_base_dir, output_base_name, output_testname_unique} ;
6
7
use crate :: common:: { Codegen , CodegenUnits , Rustdoc } ;
7
8
use crate :: common:: { DebugInfoCdb , DebugInfoGdbLldb , DebugInfoGdb , DebugInfoLldb } ;
@@ -288,6 +289,11 @@ enum ReadFrom {
288
289
Stdin ( String ) ,
289
290
}
290
291
292
+ enum TestOutput {
293
+ Compile ,
294
+ Run ,
295
+ }
296
+
291
297
impl < ' test > TestCx < ' test > {
292
298
/// Code executed for each revision in turn (or, if there are no
293
299
/// revisions, exactly once, with revision == None).
@@ -2934,9 +2940,16 @@ impl<'test> TestCx<'test> {
2934
2940
}
2935
2941
}
2936
2942
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) ;
2940
2953
2941
2954
let normalized_stdout =
2942
2955
self . normalize_output ( & proc_res. stdout , & self . props . normalize_stdout ) ;
@@ -2949,11 +2962,19 @@ impl<'test> TestCx<'test> {
2949
2962
2950
2963
let normalized_stderr = self . normalize_output ( & stderr, & self . props . normalize_stderr ) ;
2951
2964
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
+ }
2957
2978
}
2958
2979
errors
2959
2980
}
@@ -2975,14 +2996,7 @@ impl<'test> TestCx<'test> {
2975
2996
let modes_to_prune = vec ! [ CompareMode :: Nll ] ;
2976
2997
self . prune_duplicate_outputs ( & modes_to_prune) ;
2977
2998
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) ;
2986
3000
2987
3001
if self . config . compare_mode . is_some ( ) {
2988
3002
// don't test rustfix with nll right now
@@ -3062,7 +3076,7 @@ impl<'test> TestCx<'test> {
3062
3076
if self . should_run_successfully ( ) {
3063
3077
let proc_res = self . exec_compiled_test ( ) ;
3064
3078
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)
3066
3080
} else {
3067
3081
0
3068
3082
} ;
0 commit comments