Skip to content

Limit mutation checks to per commit diffs - #21

Open
Mshehu5 wants to merge 2 commits into
fungi-protocol:mainfrom
Mshehu5:mut
Open

Mshehu5 wants to merge 2 commits into
fungi-protocol:mainfrom
Mshehu5:mut

Conversation

@Mshehu5

@Mshehu5 Mshehu5 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Closes #17
This PR makes mutation testing faster by passing each commit’s first-parent diff to cargo-mutants, limiting mutations to code changed by that commit. Compatible checks remain batched while mutation checks run separately with their commit-specific Nix input.
CI now runs a quick validation stage before the complete suite avoiding expensive checks when basic tests or linting already fail. It also reuses the successful Nextest result instead of repeating the mutation baseline run.

@bc1cindy bc1cindy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

ACK e78d932

@yuval-block yuval-block left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this says it limits mutants to --in-diff but actually does a bunch of things, please split into separate commits or ideally separate PRs

Comment thread flake.nix Outdated
Comment thread nix/validate-commits.sh Outdated
@Mshehu5

Mshehu5 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

PR now focuses on mutant diff and also nextest baseline those are what were dicussed in #17 other changes have been removed Also PR has been updated to suggested changes

@yuval-block

Copy link
Copy Markdown
Collaborator

@Mshehu5 please remind me what we decided a few weeks ago about rewriting validate commits in python or rust

Comment thread nix/checks.nix
cargo mutants --in-place --test-tool nextest
test -f "$NEXTEST_BASELINE/nextest-run.zip"
cargo mutants --in-place --test-tool nextest --baseline=skip \
--in-diff ${pkgs.lib.escapeShellArg inputs.mutants-diff}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The un-overridden mutants-diff input — locked in flake.lock as a tarball of file:/dev/null — evaluates to an empty store directory, which cargo mutants --in-diff cannot parse.
Building checks.<system>.mutants outside validate-commits.sh, e.g. via the Justfile check-all recipe (nix flake check), now fails with Failed to read diff file: Is a directory.

Comment thread nix/validate-commits.sh
tmpdir=$(mktemp -d)
trap 'rm -rf "$tmpdir"' EXIT
commit_has_mutants_diff() {
git grep -q --fixed-strings mutants-diff "$1" -- flake.nix 2>/dev/null

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flake.nix pathspec in commit_has_mutants_diff is relative to the CWD, so from any subdirectory the grep misses the top-level flake and silently returns false.
Those commits then build checks.*.mutants without --override-input mutants-diff, so the per-commit parent diff never reaches the check.

@oakagent oakagent left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is 19 commits behind its base main — newest: 70c2a54 ('Merge pull request #2 from fungi-protocol/scurbber-crate'), which also touches nix/checks.nix, modified here.
A rebase onto main should land first; withholding the line-level review until then.

Comment thread nix/validate-commits.sh
local diff_file="$tmpdir/$hash.diff"
if [ ! -e "$diff_file" ]; then
if parent=$(git rev-parse "$hash^1" 2>/dev/null); then
git diff --no-ext-diff "$parent" "$hash" >"$diff_file"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

git diff --no-ext-diff "$parent" "$hash" inherits the invoking user's diff.* configuration, so the diff handed to cargo mutants --in-diff can carry ANSI color (color.ui=always), custom path prefixes (diff.srcPrefix/diff.dstPrefix), or textconv-transformed content (git-diff applies textconv by default even for tree-to-tree diffs);
cargo-mutants then silently selects zero mutants ("No mutants to filter", exit 0) or aborts with a parse error / "Diff content doesn't match source file", so the per-commit mutant gate passes vacuously or fails spuriously depending on local git config (diff.mnemonicPrefix itself only affects index/worktree diffs, not this tree-to-tree form).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

make mutants job diff aware

5 participants