feat: add -diff flag to restrict mutations to changed lines#26
Merged
Conversation
Add a -diff flag that accepts a git ref (e.g., origin/main) and filters mutation points to only lines changed relative to that ref. This makes mutest practical for CI pipelines where a global kill-rate threshold is hard to set — instead, enforce that new/changed code is well-tested. Internally uses `git diff --unified=0 <ref>...HEAD -- '*.go'` to identify changed lines, then filters the discovered mutation points by file path and line number.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
-diff <git-ref>flag that filters mutation points to only lines changed relative to the given ref, usinggit diff --unified=0 <ref>...HEADdiff/package with git diff parsing and mutation point filtering, with comprehensive unit tests (15 test cases)mutestCI job that runs mutation testing on pull requests with-diff origin/main -threshold 100Test plan
go test ./... -racepassesgo vet ./...passesgo run . -diff HEAD~1 -dry-run ./...correctly filters to changed lines onlygo run . -diff HEAD~1 ./...runs and reports results for changed lines only