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