build(xtask): cargo x mutants on demand with disk-backed scratch and nextest mutants profile
a17c74e0d65cef854f077d68a38bdb5a77b62b8a
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
- Parent 1: cb32232d36bc
There are many coding harnesses - but this one is fast
a17c74e0d65cef854f077d68a38bdb5a77b62b8a
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
+69 / −2 text lines
+8 / −0 text lines
+7 / −0 text lines
+54 / −2 text lines
"usage: cargo x <check|lint|fmt|test|doc|arch|audit|bootstrap>\n", "usage: cargo x <check|lint|fmt|test|doc|arch|mutants|audit|bootstrap>\n",const MUTANTS_VERSION: &str = "27.1.0"; Some("mutants") => cargo_mutants(),/// Mutation testing runs on demand, never in the blocking check chain.////// Scratch lives under `target/mutants-tmp` on disk: the system tmpfs is/// 16G of RAM and tree copies would crawl the machine. Jobs stay low for/// the same reason. The baseline test run is skipped because `cargo x/// check` owns test verification.fn cargo_mutants() -> ExitCode { let installed = tool_present_bin("cargo-mutants", MUTANTS_VERSION, || { cargo(&[ "binstall", "--no-confirm", &format!("cargo-mutants@{MUTANTS_VERSION}"), ]) }); if installed != ExitCode::SUCCESS { return installed; } let scratch = target_dir().join("mutants-tmp"); if std::fs::create_dir_all(&scratch).is_err() { return fail("cannot create target/mutants-tmp\n"); } match Command::new("cargo") .env("TMPDIR", &scratch) .args([ "mutants", "--jobs", "4", "--baseline", "skip", "--no-shuffle", ]) .status() { Ok(status) if status.success() => ExitCode::SUCCESS, Ok(status) => fail(&format!("cargo mutants exited with {status}\n")), Err(error) => fail(&format!("failed to run cargo mutants: {error}\n")), }} install_mutants,