Skip to content

Commit e2aff68

Browse files
committed
Test warning about unexpected nextest exit codes
Should fix a coverage gap in src/cargo.rs
1 parent 4f24b13 commit e2aff68

File tree

2 files changed

+59
-2
lines changed

2 files changed

+59
-2
lines changed

src/cargo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ use crate::Result;
2424

2525
// Allowed nextest codes (those will be considered a mutation caught / ignored without a warning)
2626
const NEXTEST_ALLOWED_CODES: &[i32] = &[
27-
NextestExitCode::TEST_RUN_FAILED,
2827
NextestExitCode::NO_TESTS_RUN,
28+
NextestExitCode::TEST_RUN_FAILED,
2929
NextestExitCode::BUILD_FAILED,
3030
];
3131

tests/nextest.rs

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
// Copyright 2024 Martin Pool
1+
// Copyright 2024-2025 Martin Pool
22

33
//! Integration tests for cargo mutants calling nextest.
44
5+
use std::fs::{create_dir, write};
6+
57
use predicates::prelude::*;
8+
use tempfile::TempDir;
69

710
mod util;
811
use util::{copy_of_testdata, run};
@@ -27,3 +30,57 @@ fn test_with_nextest_on_small_tree() {
2730
String::from_utf8_lossy(&assert.get_output().stdout)
2831
);
2932
}
33+
34+
#[test]
35+
fn unexpected_nextest_error_code_causes_a_warning() {
36+
let temp = TempDir::new().unwrap();
37+
let path = temp.path();
38+
write(
39+
path.join("Cargo.toml"),
40+
r#"[package]
41+
name = "cargo-mutants-test"
42+
version = "0.1.0"
43+
publish = false
44+
"#,
45+
)
46+
.unwrap();
47+
create_dir(path.join("src")).unwrap();
48+
write(
49+
path.join("src/main.rs"),
50+
r#"fn main() {
51+
println!("{}", 1 + 2);
52+
}"#,
53+
)
54+
.unwrap();
55+
create_dir(path.join(".config")).unwrap();
56+
write(
57+
path.join(".config/nextest.toml"),
58+
r#"nextest-version = { required = "9999.0.0" }"#,
59+
)
60+
.unwrap();
61+
62+
let assert = run()
63+
.args([
64+
"mutants",
65+
"--test-tool",
66+
"nextest",
67+
"-vV",
68+
"--no-shuffle",
69+
"-Ldebug",
70+
])
71+
.arg("-d")
72+
.arg(temp.path())
73+
.assert()
74+
.stderr(predicates::str::contains(
75+
"nextest process exited with unexpected code (allowed: [4, 100, 101]) code=92",
76+
))
77+
.code(4); // CLEAN_TESTS_FAILED
78+
println!(
79+
"stdout:\n{}",
80+
String::from_utf8_lossy(&assert.get_output().stdout)
81+
);
82+
println!(
83+
"stderr:\n{}",
84+
String::from_utf8_lossy(&assert.get_output().stderr)
85+
);
86+
}

0 commit comments

Comments
 (0)