Skip to content

Commit 4ec6a07

Browse files
authored
Merge pull request #296 from jschwe/fix_custom_linter_compiletests
Add option to customize expected rustc exit code for compile tests
2 parents b4449b7 + 5e64f3e commit 4ec6a07

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/common.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ pub struct Config {
239239
/// as a header.
240240
pub strict_headers: bool,
241241

242+
/// Expected exit code for compile tests. Defaults to expecting `1` if unset.
243+
pub compile_test_exit_code: Option<i32>,
244+
242245
// Configuration for various run-make tests frobbing things like C compilers
243246
// or querying about various LLVM component information.
244247
pub cc: String,
@@ -464,6 +467,7 @@ impl Default for Config {
464467
quiet: false,
465468
color: ColorConfig::AutoColor,
466469
remote_test_client: None,
470+
compile_test_exit_code: None,
467471
cc: "cc".to_string(),
468472
cxx: "cxx".to_string(),
469473
cflags: "cflags".to_string(),

src/runtest.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,12 @@ impl<'test> TestCx<'test> {
229229
}
230230

231231
fn check_correct_failure_status(&self, proc_res: &ProcRes) {
232-
// The value the rust runtime returns on failure
233-
const RUST_ERR: i32 = 1;
234-
if proc_res.status.code() != Some(RUST_ERR) {
232+
// The value the rust runtime returns on normal compile failure
233+
const DEFAULT_RUST_ERR: i32 = 1;
234+
235+
let expected = self.config.compile_test_exit_code.unwrap_or(DEFAULT_RUST_ERR);
236+
237+
if proc_res.status.code() != Some(expected) {
235238
self.fatal_proc_rec(
236239
&format!("failure produced the wrong error: {}", proc_res.status),
237240
proc_res,

0 commit comments

Comments
 (0)