Skip to content

fix(mutation): fail the gate when tests fail without any mutation - #15

Open
kamuikatsurgi wants to merge 1 commit into
mainfrom
kamuikatsurgi/surface-failing-baseline
Open

kamuikatsurgi wants to merge 1 commit into
mainfrom
kamuikatsurgi/surface-failing-baseline

Conversation

@kamuikatsurgi

Copy link
Copy Markdown
Member

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 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.

Testing

  • make build, make test pass.
  • ./diffguard . exits 0: complexity max 8, T1 90.5% (19/21), T2 100% (8/8).
  • New tests: TestSession_FailingTestIsLeftOut, TestBuildSection_BaselineFailedFailsTheGate; TestSession_FailingBaselineRunsNothing and TestSession_TestsThatDoNotCompileRunNothing now expect baseline_failed.
  • Not yet run against bor itself.

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.
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