Skip to content

Commit

Permalink
Merge pull request #296 from jschwe/fix_custom_linter_compiletests
Browse files Browse the repository at this point in the history
Add option to customize expected rustc exit code for compile tests
  • Loading branch information
Manishearth authored Dec 10, 2024
2 parents b4449b7 + 5e64f3e commit 4ec6a07
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ pub struct Config {
/// as a header.
pub strict_headers: bool,

/// Expected exit code for compile tests. Defaults to expecting `1` if unset.
pub compile_test_exit_code: Option<i32>,

// Configuration for various run-make tests frobbing things like C compilers
// or querying about various LLVM component information.
pub cc: String,
Expand Down Expand Up @@ -464,6 +467,7 @@ impl Default for Config {
quiet: false,
color: ColorConfig::AutoColor,
remote_test_client: None,
compile_test_exit_code: None,
cc: "cc".to_string(),
cxx: "cxx".to_string(),
cflags: "cflags".to_string(),
Expand Down
9 changes: 6 additions & 3 deletions src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,12 @@ impl<'test> TestCx<'test> {
}

fn check_correct_failure_status(&self, proc_res: &ProcRes) {
// The value the rust runtime returns on failure
const RUST_ERR: i32 = 1;
if proc_res.status.code() != Some(RUST_ERR) {
// The value the rust runtime returns on normal compile failure
const DEFAULT_RUST_ERR: i32 = 1;

let expected = self.config.compile_test_exit_code.unwrap_or(DEFAULT_RUST_ERR);

if proc_res.status.code() != Some(expected) {
self.fatal_proc_rec(
&format!("failure produced the wrong error: {}", proc_res.status),
proc_res,
Expand Down

0 comments on commit 4ec6a07

Please sign in to comment.