test(mutation): make anchors resilient and stale-anchor failures self-explaining - #55
Merged
Merged
Conversation
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.
Makes the mutation contract's anchors survive honest edits, and makes a detached anchor say so.
Why
mutation-contract.mjslocates each of its 67 mutants by exact string match. Any legitimate edit toan anchored line silently detaches the mutant, and the contract then fails with:
which reads like a safety regression rather than a stale anchor. This happened on #53: widening
REPLAY_SAFE_OPERATIONSto include the read-onlychildren/statusoperations — a correct change —broke the build, and the message gave no hint that the fix was a one-line anchor update.
Changes
RegExp, withtoas a replacement string or a function of the match.Literal anchors still work and remain correct for pinned logic (a comparison, a call), where a
change to the line genuinely should force someone to re-examine the mutant. Use a RegExp when the
line carries a value that legitimately grows.
REPLAY_SAFE_OPERATIONSis re-anchored on its declaration rather than its members, so the setcan gain read-only operations without detaching the mutant. Verified against the current form, the
pre-feat: add noInterruptOnUserMessage and noContinueWhileChildrenActive options #53 form that broke, a hypothetical future widening, and reformatted spacing — all resolve to
exactly one match and still inject
prompt.anchor rather than a failed property, say the guarded property is unverified until fixed, and point
at the RegExp remedy. The >1 case gets its own distinct message.
loudly. Previously that would run the test against unmutated source and "pass" for the wrong
reason — the mutant is supposed to make the test fail.
Checks
npm run test:mutation— 67/67 critical mutants killed.The stale-anchor path was verified by deliberately detaching an anchor and reading the output, then
restoring and re-running to confirm 67/67.