Repository navigation
fix(mutation): propagate collection errors - #11
Conversation
|
@cffls would you have a moment to look at this one when you can? Collection errors from the mutation step were dropped instead of returned, so a failed collection looked like a clean run. The change propagates them and adds a test. It is mergeable against main as of today (after #12), and I can rebase it if you prefer. |
cffls
left a comment
There was a problem hiding this comment.
Nit: internal/mutation/mutation_test.go is gofmt-clean on main but not on this branch. The fields in the test table struct (scannerErr / generatorErr) and the one-line methods on analysisErrorLanguage need realigning. Could you run gofmt -w internal/mutation/mutation_test.go (or gofumpt)? CI has no gofmt gate, so it won't flag this.
|
Thanks, ran |
|
@kriss39 could you please sign your commits? The PR could only be merged with signed commits. |
05c9e32 to
5f98126
Compare
|
Signed now, all three commits show as verified. Contents are unchanged, and the gofmt fix is already in the last commit. |
|
Thanks @kriss39 ! The PR is merged. |
Summary
Mutation collection currently swallows errors from both annotation scanning and mutant generation. If every changed file hits one of those errors,
Analyzesees zero mutants and reportsPASSwithNo 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
collectMutantscurrently handles errors from both collection stages by continuing to the next file:If collection fails for all relevant files, the resulting mutant list is empty and
Analyzereports the mutation section as passing.This makes these two states indistinguishable:
Change
collectMutantsto return([]Mutant, error).Analyze.Tests
The regression test injects deterministic failures through a fake
lang.Languageimplementation and verifies thatAnalyzereturns 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
PASSloses 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.