use std::path::PathBuf;
use testing_conventions::mutation::measure_rust;
fn crate_dir(name: &str) -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("tests/fixtures/unit_mutation/rust")
.join(name)
}
#[test]
fn killed_reports_no_survivors() {
let survivors = measure_rust(&crate_dir("killed"), &[], None).expect("cargo-mutants runs");
assert!(
survivors.is_empty(),
"every mutant should be caught; got {survivors:?}"
);
}
#[test]
fn survivors_are_reported() {
let survivors = measure_rust(&crate_dir("survivors"), &[], None).expect("cargo-mutants runs");
assert!(
!survivors.is_empty(),
"the assertion-light suite should leave survivors"
);
assert!(
survivors.iter().all(|m| m.file == "src/lib.rs"),
"every survivor is in src/lib.rs; got {survivors:?}"
);
}
#[test]
fn a_mutation_exemption_drops_the_survivors() {
let exempt = vec!["src/lib.rs".to_string()];
let survivors =
measure_rust(&crate_dir("survivors"), &exempt, None).expect("cargo-mutants runs");
assert!(
survivors.is_empty(),
"the exemption should drop every survivor; got {survivors:?}"
);
}