You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(mutation): fail the gate when tests fail without any mutation - #15
If a package's tests fail before any mutation is applied, diffguard dropped every mutant of that package, reported them as NOT RUN (budget or cancelled) and still exited 0. The only trace was a line on stderr. Seen running locally on bor, where one miner test fails on the machine:
mutation: .../bor/miner: its instrumented tests do not pass; testing its 29 mutants one build at a time
mutation: tests fail without any mutation in .../bor/miner; its mutants were not run
Score: 97.9% (595/608 killed, 13 survived) | ... | 29 NOT RUN (budget or cancelled) [WARN]
A local exit 0 could hide a whole package, and any package with a flaky or environment-dependent test would get the same treatment in CI. The fallback also ran the full suite once more only to fail again.
Changes
New outcome baseline_failed for mutants whose tests fail without any mutation. It is excluded from the score, shown in the summary as N NOT TESTED (their tests fail without any mutation), and listed as one finding per file.
A Tier 1 or Tier 2 mutant in that state makes the section FAIL, so the run exits non-zero.
One failing test no longer costs the package its other tests. Each test is traced on its own and retried once if it fails. If the whole suite does not pass either, the failing tests are left out and named on stderr, and the rest are used. A mutant is baseline_failed only if no passing test reaches it and a left-out test does.
The one-build-at-a-time fallback, with its extra full suite run, now happens only when no test in the package passes on its own.
Behaviour to be aware of
Stricter in CI: a test that fails twice unmutated can now fail the gate where it used to pass with a warning.
A mutant that only a left-out test would have killed is reported as survived if other tests reach it.
New tests: TestSession_FailingTestIsLeftOut, TestBuildSection_BaselineFailedFailsTheGate; TestSession_FailingBaselineRunsNothing and TestSession_TestsThatDoNotCompileRunNothing now expect baseline_failed.
A package whose tests failed unmutated had all its mutants reported as
"not run (budget or cancelled)" and the run still exited 0.
Such mutants now get their own outcome, baseline_failed, which is named
in the summary and findings and fails a gating tier. A single failing
test no longer costs the package its other tests: it is retried once,
then left out and named, and only the mutants no passing test reaches
are reported as untested.
A test is already retried on its own, so the second whole-suite attempt
only repeated a failing run. Dropping it also removes the conditions no
test could tell apart.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Discarded failure traces can misclassify mutants as uncovered and let the gate pass incorrectly, while overlay runs still reject mutants covered by healthy tests due to unrelated test failures.
This PR makes baseline test failures visible to diffguard’s mutation gate, failing the run when they prevent Tier 1 or Tier 2 mutants from being tested.
Changes:
Adds a baseline_failed outcome, excluded from scores but reflected in summaries, findings, and gate severity.
Retries individually failing tests and retains passing tests when the full suite also fails.
Adds regression coverage and documents the updated behavior.
File
Description
README.md
Documents untestable mutants and baseline-failure handling.
internal/mutation/tiers.go
Counts baseline failures separately per tier.
internal/mutation/section.go
Adds baseline-failure reporting and gate severity rules.
internal/mutation/run_test.go
Tests scoring, findings, and gating for baseline failures.
internal/mutation/cache_test.go
Verifies baseline failures are not cached.
internal/lang/lang.go
Defines the new outcome and its serialized name.
internal/lang/lang_test.go
Adds outcome-name round-trip coverage.
internal/lang/goanalyzer/session.go
Classifies mutants affected by failing baseline tests.
internal/lang/goanalyzer/session_test.go
Tests mixed passing/failing tests and updates baseline expectations.
internal/lang/goanalyzer/session_prepare.go
Retries individual tests and records reachability for excluded tests.
… on the overlay path
A mutant only failing runs reach was reported as not covered when the
evidence was in the whole-suite run or in a first attempt the retry did
not repeat. Both now count.
Mutants that need a build of their own were all rejected when one test
failed, because their baseline ran the full suite. The baseline and the
mutant runs now skip the left-out tests.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Critical baseline and test-filtering defects discard healthy tests and misclassify overlay-only mutants, producing unreliable mutation scores and potentially allowing the gate to pass incorrectly.
…s all fail
A dependent package with no passing test made preparation give up on
every binary, and the fallback then rejected all of the package's
mutants. Such a binary is now kept with all of its tests left out.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
A shared baseline is incorrectly rejected when the mutated package’s tests all fail but dependent tests pass, causing mutants covered by healthy tests to be marked baseline_failed instead of tested.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Preserve healthy dependent tests when the mutated package baseline fails
When all tests in the mutated package fail but a dependent subpackage has passing tests, this rejects the entire shared baseline. Mutants covered by those healthy tests are then reported as baseline_failed instead of being tested. Retain the own binary's failed-test traces and exclusions too, and decide whether any passing baseline remains across all binaries in baselineAll before falling back.
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
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.
Problem
If a package's tests fail before any mutation is applied, diffguard dropped every mutant of that package, reported them as
NOT RUN (budget or cancelled)and still exited 0. The only trace was a line on stderr. Seen running locally on bor, where oneminertest fails on the machine:A local exit 0 could hide a whole package, and any package with a flaky or environment-dependent test would get the same treatment in CI. The fallback also ran the full suite once more only to fail again.
Changes
baseline_failedfor mutants whose tests fail without any mutation. It is excluded from the score, shown in the summary asN NOT TESTED (their tests fail without any mutation), and listed as one finding per file.baseline_failedonly if no passing test reaches it and a left-out test does.Behaviour to be aware of
Testing
make build,make testpass../diffguard .exits 0: complexity max 8, T1 90.5% (19/21), T2 100% (8/8).TestSession_FailingTestIsLeftOut,TestBuildSection_BaselineFailedFailsTheGate;TestSession_FailingBaselineRunsNothingandTestSession_TestsThatDoNotCompileRunNothingnow expectbaseline_failed.