Anchor a retire to the snapshot it was sent for - #784
Merged
Conversation
Set and Append locate the call by content, and say why: the same literal is just as likely to sit in another test, in a comment, or in the verify call on the same line, so rewriting whichever call the hint lands on leaves the wrong snapshot changed. Remove had exactly that problem with none of the protection - it took the nearest call to the recorded line and deleted it, ignoring the anchor entirely. The recorded line stops being true as soon as anything above it is edited, which is the ordinary state of a source file between a test run and a retire. So a stale hint retired the snapshot in the test next door and reported Applied, and the snapshot that should have gone was still there. TryFindAnchoredCall matches on the expected argument the way the Set path does, by expression where there is one and by parsed value otherwise, and falls back to nearest-to-the-hint only when no anchor was sent at all - which is what a producer whose language withholds CallerArgumentExpression and sends no value either can offer. An anchor that matches nothing is now reported rather than resolved to something else.
…nores-anchor # Conflicts: # src/DiffEngine.Tests/InlinePatcherTests.cs
…nores-anchor # Conflicts: # src/DiffEngine.Tests/InlinePatcherTests.cs
…nores-anchor # Conflicts: # src/DiffEngine.Tests/InlinePatcherTests.cs
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.
Set and Append locate the call by content, and say why: the same literal is just
as likely to sit in another test, in a comment, or in the verify call on the
same line, so rewriting whichever call the hint lands on leaves the wrong
snapshot changed. Remove had exactly that problem with none of the protection -
it took the nearest call to the recorded line and deleted it, ignoring the
anchor entirely.
The recorded line stops being true as soon as anything above it is edited, which
is the ordinary state of a source file between a test run and a retire. So a
stale hint retired the snapshot in the test next door and reported Applied, and
the snapshot that should have gone was still there.
TryFindAnchoredCall matches on the expected argument the way the Set path does,
by expression where there is one and by parsed value otherwise, and falls back
to nearest-to-the-hint only when no anchor was sent at all - which is what a
producer whose language withholds CallerArgumentExpression and sends no value
either can offer. An anchor that matches nothing is now reported rather than
resolved to something else.