Repository navigation
fix: the mutation report runs Stryker for real and stays short - #180
Merged
Merged
Conversation
Stryker's Vitest runner switches no mutant on under Vitest 5, and its sandbox loses imports from outside the web directory, so a project whose code imports its contract ran a fraction of its tests and every mutant read as survived. Stryker now mutates only the changed lines, one changed file at a time, in place, with the command runner running vitest related on that file. The comment lists survivors up to 30, counts unreached mutants per file instead of listing each, and leaves out generated code. Closes #167
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Closes #167. The mutation report had two problems: it printed every mutant, and Stryker never really ran.
Why Stryker read as "did not finish". On identity it ran 60 of 427 tests, and almost every mutant "survived". There were two causes:
src/app/contract.tsimports../../../openapi/v1/openapi.yaml?raw. Stryker copies onlyweb/, so every spec that loads the app failed to import, and the Vitest runner dropped those files without a word.inject()delivers the active mutant to the setup file. Mutants still never activate: 237 of 241 "survive" onformat.ts, a file its tests cover fully.The fix.
scripts/changed_ranges.pyturnsgit diff -U0intofile:start-endranges, as gremlins--diffalready does for Go.pnpm exec vitest related --run <file>. The command runner switches a mutant on through the environment, and in place the outside imports resolve.format.ts, the command runner killed 225 of 241 mutants over the whole file. Limited to the 22 mutants on chore(main): release 0.15.1 #96's changed lines, all were caught, in 1.5 minutes.clear-textreporter is gone, so the job log no longer prints every mutant.A shorter comment.
Code generated,auto-generatedorDO NOT EDIT, read against--go-rootand--web-root.--strykertakes one report per run.stryker_workedtrusts a run that killed or timed out mutants even without coverage, as the command runner reports. A run that switched nothing on still reads as not finished.A caller no longer needs
@stryker-mutator/vitest-runner, only@stryker-mutator/coreand Vitest.Testing
changed_ranges.pyandmutation_report.pyare both at 100% line and branch coverage, with a new CI step for the former.jq-written config, Stryker, report.