From b700878eb23aae3cf228e4ef7d2a74d2fa79358e Mon Sep 17 00:00:00 2001 From: Hameer Abbasi Date: Sat, 6 Feb 2021 06:33:07 +0000 Subject: [PATCH] Add option to emit compiler stderr per bitwidth. See rust-lang/compiler-team#365 --- src/tools/compiletest/src/header.rs | 11 +++++++++++ src/tools/compiletest/src/runtest.rs | 7 ++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 2eba91fd1f4cf..429a8c98cd57c 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -333,6 +333,8 @@ pub struct TestProps { pub assembly_output: Option, // If true, the test is expected to ICE pub should_ice: bool, + // If true, the stderr is expected to be different across bit-widths. + pub stderr_per_bitwidth: bool, } impl TestProps { @@ -372,6 +374,7 @@ impl TestProps { rustfix_only_machine_applicable: false, assembly_output: None, should_ice: false, + stderr_per_bitwidth: false, } } @@ -538,6 +541,10 @@ impl TestProps { if self.assembly_output.is_none() { self.assembly_output = config.parse_assembly_output(ln); } + + if !self.stderr_per_bitwidth { + self.stderr_per_bitwidth = config.parse_stderr_per_bitwidth(ln); + } }); } @@ -774,6 +781,10 @@ impl Config { self.parse_name_directive(line, "ignore-pass") } + fn parse_stderr_per_bitwidth(&self, line: &str) -> bool { + self.parse_name_directive(line, "stderr-per-bitwidth") + } + fn parse_assembly_output(&self, line: &str) -> Option { self.parse_name_value_directive(line, "assembly-output").map(|r| r.trim().to_string()) } diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 52aed57fc76af..1ec32184d9898 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -3124,7 +3124,12 @@ impl<'test> TestCx<'test> { errors += self.compare_output("stdout", &normalized_stdout, &expected_stdout); } if !self.props.dont_check_compiler_stderr { - errors += self.compare_output("stderr", &normalized_stderr, &expected_stderr); + let kind = if self.props.stderr_per_bitwidth { + format!("{}bit.stderr", get_pointer_width(&self.config.target)) + } else { + String::from("stderr") + }; + errors += self.compare_output(&kind, &normalized_stderr, &expected_stderr); } } TestOutput::Run => {