|
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,44 +2940,64 @@ impl<'test> TestCx<'test> {
|
2934 | 2940 | }
|
2935 | 2941 | }
|
2936 | 2942 |
|
2937 |
| - fn run_ui_test(&self) { |
2938 |
| - // if the user specified a format in the ui test |
2939 |
| - // print the output to the stderr file, otherwise extract |
2940 |
| - // the rendered error messages from json and print them |
2941 |
| - let explicit = self |
2942 |
| - .props |
2943 |
| - .compile_flags |
2944 |
| - .iter() |
2945 |
| - .any(|s| s.contains("--error-format")); |
2946 |
| - let proc_res = self.compile_test(); |
2947 |
| - self.check_if_test_should_compile(&proc_res); |
| 2943 | + fn load_compare_outputs(&self, proc_res: &ProcRes, |
| 2944 | + output_kind: TestOutput, explicit_format: bool) -> usize { |
2948 | 2945 |
|
2949 |
| - let expected_stderr = self.load_expected_output(UI_STDERR); |
2950 |
| - let expected_stdout = self.load_expected_output(UI_STDOUT); |
2951 |
| - let expected_fixed = self.load_expected_output(UI_FIXED); |
| 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); |
2952 | 2953 |
|
2953 | 2954 | let normalized_stdout =
|
2954 | 2955 | self.normalize_output(&proc_res.stdout, &self.props.normalize_stdout);
|
2955 | 2956 |
|
2956 |
| - let stderr = if explicit { |
| 2957 | + let stderr = if explicit_format { |
2957 | 2958 | proc_res.stderr.clone()
|
2958 | 2959 | } else {
|
2959 | 2960 | json::extract_rendered(&proc_res.stderr)
|
2960 | 2961 | };
|
2961 | 2962 |
|
2962 | 2963 | let normalized_stderr = self.normalize_output(&stderr, &self.props.normalize_stderr);
|
2963 |
| - |
2964 | 2964 | let mut errors = 0;
|
2965 |
| - if !self.props.dont_check_compiler_stdout { |
2966 |
| - errors += self.compare_output("stdout", &normalized_stdout, &expected_stdout); |
2967 |
| - } |
2968 |
| - if !self.props.dont_check_compiler_stderr { |
2969 |
| - 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 | + } |
2970 | 2978 | }
|
| 2979 | + errors |
| 2980 | + } |
| 2981 | + |
| 2982 | + fn run_ui_test(&self) { |
| 2983 | + // if the user specified a format in the ui test |
| 2984 | + // print the output to the stderr file, otherwise extract |
| 2985 | + // the rendered error messages from json and print them |
| 2986 | + let explicit = self |
| 2987 | + .props |
| 2988 | + .compile_flags |
| 2989 | + .iter() |
| 2990 | + .any(|s| s.contains("--error-format")); |
| 2991 | + let proc_res = self.compile_test(); |
| 2992 | + self.check_if_test_should_compile(&proc_res); |
| 2993 | + |
| 2994 | + let expected_fixed = self.load_expected_output(UI_FIXED); |
2971 | 2995 |
|
2972 | 2996 | let modes_to_prune = vec![CompareMode::Nll];
|
2973 | 2997 | self.prune_duplicate_outputs(&modes_to_prune);
|
2974 | 2998 |
|
| 2999 | + let mut errors = self.load_compare_outputs(&proc_res, TestOutput::Compile, explicit); |
| 3000 | + |
2975 | 3001 | if self.config.compare_mode.is_some() {
|
2976 | 3002 | // don't test rustfix with nll right now
|
2977 | 3003 | } else if self.config.rustfix_coverage {
|
@@ -3049,7 +3075,17 @@ impl<'test> TestCx<'test> {
|
3049 | 3075 |
|
3050 | 3076 | if self.should_run_successfully() {
|
3051 | 3077 | let proc_res = self.exec_compiled_test();
|
3052 |
| - |
| 3078 | + let run_output_errors = if self.props.check_run_results { |
| 3079 | + self.load_compare_outputs(&proc_res, TestOutput::Run, explicit) |
| 3080 | + } else { |
| 3081 | + 0 |
| 3082 | + }; |
| 3083 | + if run_output_errors > 0 { |
| 3084 | + self.fatal_proc_rec( |
| 3085 | + &format!("{} errors occured comparing run output.", run_output_errors), |
| 3086 | + &proc_res, |
| 3087 | + ); |
| 3088 | + } |
3053 | 3089 | if !proc_res.status.success() {
|
3054 | 3090 | self.fatal_proc_rec("test run failed!", &proc_res);
|
3055 | 3091 | }
|
|
0 commit comments