Skip to content

fix(mutation): propagate collection errors - #11

Open
kriss39 wants to merge 2 commits into
0xPolygon:mainfrom
kriss39:test/mutation-error-propagation
Open

kriss39 wants to merge 2 commits into
0xPolygon:mainfrom
kriss39:test/mutation-error-propagation

Conversation

@kriss39

@kriss39 kriss39 commented Sep 8, 2026

Copy link
Copy Markdown

Summary

Mutation collection currently swallows errors from both annotation scanning and mutant generation. If every changed file hits one of those errors, Analyze sees zero mutants and reports PASS with No mutants generated from changed code.

This change propagates those collection errors instead, preserving the distinction between a genuine zero-mutant result and a failed mutation analysis.

Problem

collectMutants currently handles errors from both collection stages by continuing to the next file:

if err != nil {
    continue
}

If collection fails for all relevant files, the resulting mutant list is empty and Analyze reports the mutation section as passing.

This makes these two states indistinguishable:

  • mutation analysis completed successfully and found no applicable mutants
  • mutation collection failed and therefore produced no mutants

Change

  • Change collectMutants to return ([]Mutant, error).
  • Propagate annotation-scanner errors with the affected file path.
  • Propagate mutant-generator errors with the affected file path.
  • Return collection errors from Analyze.
  • Add regression coverage for both scanner and generator failures.

Tests

The regression test injects deterministic failures through a fake lang.Language implementation and verifies that Analyze returns an error wrapping the original cause.

Before the fix, these cases are silently converted into a successful zero-mutant result.

After the fix, the original errors are propagated.

Design note

This PR uses fail-fast propagation because reporting PASS loses the distinction between "no applicable mutants" and "mutation collection failed."

If partial-results or warning behavior is preferred for individual file failures, I am happy to adjust the reporting policy while preserving that distinction.

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