Tighten the platform and spawn-failure assertions
Utils::platform passed against any non-empty string and sh never
exercised the path where the command fails to spawn, so mutants
survived both.
Assisted-by: Claude Opus 5 via Claude Code
diff --git a/.cargo/mutants.toml b/.cargo/mutants.toml
index df6901c..f44584c 100644
--- a/.cargo/mutants.toml
+++ b/.cargo/mutants.toml
@@ -1,2 +1,16 @@
# Excludes for cargo-mutants — equivalent or unreachable mutations.
# Add entries as false positives are discovered.
+
+exclude_re = [
+ # Unimplemented stubs. Nothing calls upgrade or remove yet, so replacing
+ # the todo!() with Ok(()) cannot be observed. Drop these when either is
+ # implemented — the same point the cov-excl markers in assertions.rs go.
+ "AssertionType::upgrade",
+ "AssertionType::remove",
+
+ # BrewBundle's status and install exist twice, split on
+ # #[cfg(target_os = "macos")]. cargo-mutants cannot tell which half is
+ # compiled, so it always reports the inactive one as missed.
+ "impl AssertionType for BrewBundle<R>>::status",
+ "impl AssertionType for BrewBundle<R>>::install",
+]
diff --git a/frork-cli/src/utils.rs b/frork-cli/src/utils.rs
index 89fb389..c0ea184 100644
--- a/frork-cli/src/utils.rs
+++ b/frork-cli/src/utils.rs
@@ -470,6 +470,39 @@ mod tests {
assert!(error.to_string().contains("not found in PATH"));
}
+ /// `uname -s`, lowercased — what `Utils::platform` is expected to report.
+ #[cfg(target_os = "macos")]
+ fn expected_platform() -> &'static str {
+ "darwin"
+ }
+
+ #[cfg(not(target_os = "macos"))]
+ fn expected_platform() -> &'static str {
+ "linux"
+ }
+
+ #[test]
+ fn test_platform() {
+ assert_eq!(Utils::platform().unwrap(), expected_platform());
+ }
+
+ #[test]
+ fn test_sh_reports_minus_one_when_the_command_cannot_spawn() {
+ let lua = mlua::Lua::new();
+ let utils_table = Utils {}.into_lua(&lua).unwrap();
+ lua.globals().set("utils", utils_table).unwrap();
+
+ // A missing binary fails to spawn, which is distinct from running and
+ // exiting non-zero: `sh` reports nil and the -1 sentinel.
+ let (stdout, exit_code): (Option<String>, i32) = lua
+ .load(r#"return utils.sh("frork-does-not-exist")"#)
+ .eval()
+ .unwrap();
+
+ assert_eq!(stdout, None);
+ assert_eq!(exit_code, -1);
+ }
+
#[test]
fn test_utils_lua_bindings() {
let lua = mlua::Lua::new();
@@ -498,7 +531,7 @@ mod tests {
assert_eq!(chomped, "line");
let platform: String = lua.load(r#"return utils.platform"#).eval().unwrap();
- assert!(!platform.is_empty());
+ assert_eq!(platform, expected_platform());
lua.load(r#"utils["assert-bin"]("sh")"#).exec().unwrap();