Skip to content

feat: add --covered-only flag to skip uncovered lines#57

Open
danrneal wants to merge 1 commit into
avito-tech:masterfrom
danrneal:feat-covered-only-flag
Open

feat: add --covered-only flag to skip uncovered lines#57
danrneal wants to merge 1 commit into
avito-tech:masterfrom
danrneal:feat-covered-only-flag

Conversation

@danrneal
Copy link
Copy Markdown

Mutation testing provides excellent value by finding untested code paths, but generating and testing mutants on lines of code that are already known to have zero test coverage creates a lot of unnecessary noise and drastically slows down execution.

This PR introduces a --covered-only flag that automatically filters out these low-value mutations.

How it works:

  1. When the flag is provided, the tool automatically runs go test -coverprofile=... on the target packages in the background to generate a temporary coverage profile.
  2. It parses this profile into memory using the standard golang.org/x/tools/cover package.
  3. During the AST walking phase, it checks the starting line number of every potential mutation target. If the line has exactly 0 test coverage, the node is silently skipped.
  4. The temporary coverage file is automatically deleted.

The result is a significantly faster mutation run. The generated reports are also much cleaner because they only highlight genuine logic blind spots in code that the test suite actually covers.

Included in this PR:

  • A new CoverageFilter implementation in the filter package.
  • Automatic temporary coverage profile generation in main.go.
  • Unit tests for the filter logic.
  • An integration test to ensure the flag works end-to-end.
  • README documentation explaining the new feature.

This introduces a CoverageFilter that automatically generates a temporary go test coverage profile. It skips mutating any AST nodes located on lines with 0 test coverage, drastically reducing noise and improving execution speed.
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.

1 participant