Skip to content

Commit

Permalink
add dont_check_failure_status option in the compiler test
Browse files Browse the repository at this point in the history
  • Loading branch information
SparrowLii committed Apr 6, 2023
1 parent c1d3610 commit ded0483
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ pub struct TestProps {
pub normalize_stdout: Vec<(String, String)>,
pub normalize_stderr: Vec<(String, String)>,
pub failure_status: i32,
// For UI tests, allows compiler to exit with arbitrary failure status
pub dont_check_failure_status: bool,
// Whether or not `rustfix` should apply the `CodeSuggestion`s of this test and compile the
// resulting Rust code.
pub run_rustfix: bool,
Expand Down Expand Up @@ -192,6 +194,7 @@ mod directives {
pub const CHECK_TEST_LINE_NUMBERS_MATCH: &'static str = "check-test-line-numbers-match";
pub const IGNORE_PASS: &'static str = "ignore-pass";
pub const FAILURE_STATUS: &'static str = "failure-status";
pub const DONT_CHECK_FAILURE_STATUS: &'static str = "dont-check-failure-status";
pub const RUN_RUSTFIX: &'static str = "run-rustfix";
pub const RUSTFIX_ONLY_MACHINE_APPLICABLE: &'static str = "rustfix-only-machine-applicable";
pub const ASSEMBLY_OUTPUT: &'static str = "assembly-output";
Expand Down Expand Up @@ -239,6 +242,7 @@ impl TestProps {
normalize_stdout: vec![],
normalize_stderr: vec![],
failure_status: -1,
dont_check_failure_status: false,
run_rustfix: false,
rustfix_only_machine_applicable: false,
assembly_output: None,
Expand Down Expand Up @@ -401,6 +405,12 @@ impl TestProps {
self.failure_status = code;
}

config.set_name_directive(
ln,
DONT_CHECK_FAILURE_STATUS,
&mut self.dont_check_failure_status,
);

config.set_name_directive(ln, RUN_RUSTFIX, &mut self.run_rustfix);
config.set_name_directive(
ln,
Expand Down
4 changes: 3 additions & 1 deletion src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,9 @@ impl<'test> TestCx<'test> {
);
}

self.check_correct_failure_status(proc_res);
if !self.props.dont_check_failure_status {
self.check_correct_failure_status(proc_res);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/recursion/issue-95134.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// build-fail
// known-bug: #95134
// compile-flags: -Copt-level=0
// failure-status: 101
// dont-check-failure-status
// dont-check-compiler-stderr

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

0 comments on commit ded0483

Please sign in to comment.