Skip to content

Commit 480865d

Browse files
authored
Rollup merge of rust-lang#81817 - hameerabbasi:mcp-635, r=oli-obk
Add option to emit compiler stderr per bitwidth. See rust-lang/compiler-team#365 r? `@oli-obk`
2 parents b263981 + b700878 commit 480865d

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/tools/compiletest/src/header.rs

+11
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,8 @@ pub struct TestProps {
333333
pub assembly_output: Option<String>,
334334
// If true, the test is expected to ICE
335335
pub should_ice: bool,
336+
// If true, the stderr is expected to be different across bit-widths.
337+
pub stderr_per_bitwidth: bool,
336338
}
337339

338340
impl TestProps {
@@ -372,6 +374,7 @@ impl TestProps {
372374
rustfix_only_machine_applicable: false,
373375
assembly_output: None,
374376
should_ice: false,
377+
stderr_per_bitwidth: false,
375378
}
376379
}
377380

@@ -538,6 +541,10 @@ impl TestProps {
538541
if self.assembly_output.is_none() {
539542
self.assembly_output = config.parse_assembly_output(ln);
540543
}
544+
545+
if !self.stderr_per_bitwidth {
546+
self.stderr_per_bitwidth = config.parse_stderr_per_bitwidth(ln);
547+
}
541548
});
542549
}
543550

@@ -774,6 +781,10 @@ impl Config {
774781
self.parse_name_directive(line, "ignore-pass")
775782
}
776783

784+
fn parse_stderr_per_bitwidth(&self, line: &str) -> bool {
785+
self.parse_name_directive(line, "stderr-per-bitwidth")
786+
}
787+
777788
fn parse_assembly_output(&self, line: &str) -> Option<String> {
778789
self.parse_name_value_directive(line, "assembly-output").map(|r| r.trim().to_string())
779790
}

src/tools/compiletest/src/runtest.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -3124,7 +3124,12 @@ impl<'test> TestCx<'test> {
31243124
errors += self.compare_output("stdout", &normalized_stdout, &expected_stdout);
31253125
}
31263126
if !self.props.dont_check_compiler_stderr {
3127-
errors += self.compare_output("stderr", &normalized_stderr, &expected_stderr);
3127+
let kind = if self.props.stderr_per_bitwidth {
3128+
format!("{}bit.stderr", get_pointer_width(&self.config.target))
3129+
} else {
3130+
String::from("stderr")
3131+
};
3132+
errors += self.compare_output(&kind, &normalized_stderr, &expected_stderr);
31283133
}
31293134
}
31303135
TestOutput::Run => {

0 commit comments

Comments
 (0)