Skip to content

Commit ded0483

Browse files
committed
add dont_check_failure_status option in the compiler test
1 parent c1d3610 commit ded0483

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/tools/compiletest/src/header.rs

+10
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ pub struct TestProps {
150150
pub normalize_stdout: Vec<(String, String)>,
151151
pub normalize_stderr: Vec<(String, String)>,
152152
pub failure_status: i32,
153+
// For UI tests, allows compiler to exit with arbitrary failure status
154+
pub dont_check_failure_status: bool,
153155
// Whether or not `rustfix` should apply the `CodeSuggestion`s of this test and compile the
154156
// resulting Rust code.
155157
pub run_rustfix: bool,
@@ -192,6 +194,7 @@ mod directives {
192194
pub const CHECK_TEST_LINE_NUMBERS_MATCH: &'static str = "check-test-line-numbers-match";
193195
pub const IGNORE_PASS: &'static str = "ignore-pass";
194196
pub const FAILURE_STATUS: &'static str = "failure-status";
197+
pub const DONT_CHECK_FAILURE_STATUS: &'static str = "dont-check-failure-status";
195198
pub const RUN_RUSTFIX: &'static str = "run-rustfix";
196199
pub const RUSTFIX_ONLY_MACHINE_APPLICABLE: &'static str = "rustfix-only-machine-applicable";
197200
pub const ASSEMBLY_OUTPUT: &'static str = "assembly-output";
@@ -239,6 +242,7 @@ impl TestProps {
239242
normalize_stdout: vec![],
240243
normalize_stderr: vec![],
241244
failure_status: -1,
245+
dont_check_failure_status: false,
242246
run_rustfix: false,
243247
rustfix_only_machine_applicable: false,
244248
assembly_output: None,
@@ -401,6 +405,12 @@ impl TestProps {
401405
self.failure_status = code;
402406
}
403407

408+
config.set_name_directive(
409+
ln,
410+
DONT_CHECK_FAILURE_STATUS,
411+
&mut self.dont_check_failure_status,
412+
);
413+
404414
config.set_name_directive(ln, RUN_RUSTFIX, &mut self.run_rustfix);
405415
config.set_name_directive(
406416
ln,

src/tools/compiletest/src/runtest.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,9 @@ impl<'test> TestCx<'test> {
309309
);
310310
}
311311

312-
self.check_correct_failure_status(proc_res);
312+
if !self.props.dont_check_failure_status {
313+
self.check_correct_failure_status(proc_res);
314+
}
313315
}
314316
}
315317

tests/ui/recursion/issue-95134.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// build-fail
22
// known-bug: #95134
33
// compile-flags: -Copt-level=0
4-
// failure-status: 101
4+
// dont-check-failure-status
55
// dont-check-compiler-stderr
66

77
pub fn encode_num<Writer: ExampleWriter>(n: u32, mut writer: Writer) -> Result<(), Writer::Error> {

0 commit comments

Comments
 (0)