Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dont_check_failure_status option in the compiler test #110004

Merged
merged 1 commit into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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