build(xtask): cargo x mutants requires a scope locally; one job, nice, timeout; --all for CI; smith-bench excluded
c895253f625cf500e0aa84cf3059e9a1404f58db
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
- Parent 1: 01097b0d2fbe
There are many coding harnesses - but this one is fast
c895253f625cf500e0aa84cf3059e9a1404f58db
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
+120 / −12 text lines
new file mode 100644+34 / −0 text lines
# cargo-mutants configuration.# Runs on demand via `cargo x mutants`; never in the blocking check chain.## Split of concerns: this file owns TREE properties, identical on every# machine and in CI — bare `cargo mutants` needs no flags. Run-context# knobs (scratch dir, job count, baseline) live in the xtask step.## Correctness pairing: mutation scope and test_package cover the same# crates — every first-party crate (exclude_globs denies plugin guests,# unbuilt frontends, and xtask automation, so CLI -f scoping intersects# instead of widening: config list values APPEND to command-line lists).## cap_lints: the workspace runs -D warnings; mutant-generated unused# variables would otherwise kill every build as Unviable.cap_lints = truetest_package = [ "smith", "smith-core", "smith-ai", "smith-rpc", "smith-harness", "smith-cli", "smith-alloc",]test_tool = "nextest"profile = "mutants"additional_cargo_test_args = ["--profile=mutants"]exclude_globs = [ "plugins/**/*.rs", "smith-tui/src/**", "smith-ui/src/**", "xtask/src/**", "smith-bench/**",]+1 / −1 text lines
run "V=$PWD/target/tools/valgrind; test -x $V/bin/valgrind || (mkdir -p target/tools/src && curl -sSL https://sourceware.org/pub/valgrind/valgrind-3.25.1.tar.bz2 | tar -xj -C target/tools/src && cd target/tools/src/valgrind-3.25.1 && ./configure -q --prefix=$V >/dev/null && make -s -j$(nproc) >/dev/null && make -s install >/dev/null)"+1 / −0 text lines
+84 / −11 text lines
let jobs = std::env::var("CARGO_MUTANTS_JOBS").unwrap_or_else(|_| "1".to_string()); let mut command = Command::new("cargo-mutants"); command.env("TMPDIR", &scratch).args([ "mutants", "--jobs", &jobs, "--baseline", "skip", "--no-shuffle", ]); let all = extra.iter().any(|arg| arg == "--all"); if !all && !mutants_scoped(extra) { return fail(MUTANTS_SCOPE_HELP); } let passthrough: Vec<&OsString> = extra.iter().filter(|arg| *arg != "--all").collect(); let jobs = std::env::var("CARGO_MUTANTS_JOBS").unwrap_or_else(|_| "1".to_string()); // Lowest scheduling priority: a mutants run is a background chore and // must never starve the shell, even with one job its nextest fans out. let threads = std::env::var("NEXTEST_TEST_THREADS").unwrap_or_else(|_| { std::thread::available_parallelism() .map_or(2, |cores| (cores.get() / 3).max(2)) .to_string() }); let mut command = Command::new("nice"); command .args(["-n", "19", "cargo-mutants"]) .env("TMPDIR", &scratch) // A third of the cores per mutant's test run keeps the shell alive. .env("NEXTEST_TEST_THREADS", &threads) .args([ "mutants", "--output", "target", "--jobs", &jobs, "--baseline", "skip", "--timeout", "120", "--no-shuffle", ]);const MUTANTS_SCOPE_HELP: &str = "\cargo x mutants needs a scope: a workspace-wide run copies the tree per job and \has crashed this machine before. -f <glob> one file or directory, e.g. -f smith-core/src/session.rs -D <patch> mutants on changed lines only (jj diff --git > /tmp/d.patch) -p <crate> one crate --shard k/n one of n equal shards, e.g. --shard 0/8 -F/-E <regex> mutant-name filters --list inventory only, no build --all the whole workspace; CI only";/// Whether the passthrough arguments narrow a mutants run.fn mutants_scoped(extra: &[OsString]) -> bool { extra.iter().any(|arg| { let arg = arg.to_string_lossy(); matches!( arg.as_ref(), "-f" | "--file" | "-D" | "--in-diff" | "-p" | "--package" | "--shard" | "-F" | "--re" | "-E" | "--exclude-re" | "--list" ) || arg.starts_with("--file=") || arg.starts_with("--in-diff=") || arg.starts_with("--package=") || arg.starts_with("--shard=") || arg.starts_with("--re=") || arg.starts_with("--exclude-re=") })} #[test] fn mutants_refuse_to_run_unscoped() { let scoped = |args: &[&str]| { let args: Vec<std::ffi::OsString> = args.iter().map(std::ffi::OsString::from).collect(); super::mutants_scoped(&args) }; assert!(scoped(&["-f", "smith-core/src/session.rs"])); assert!(scoped(&["--shard=0/8"])); assert!(scoped(&["-D", "/tmp/d.patch", "-j2"])); assert!(scoped(&["--list"])); assert!(!scoped(&[])); assert!(!scoped(&["-j4", "--baseline", "run"])); }