Pair snapshots via Verify's received map, with a name based fallback - #8
Merged
Conversation
The tool never runs on a build server, so citing that as a reason the received map is absent was misleading. The cases that actually apply are a Verify older than 31.27.0, and an obj directory that is not under the working directory or has been removed since the test run.
patriksvensson
approved these changes
Jul 22, 2026
Member
|
Looks good to me! |
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.
Accepting a snapshot means moving a
.received.file over the.verified.file it belongs to, so the tool has to work out which verified file each received file maps to. It was reconstructing the verified name from the received name, which is not reliable, because the two names legitimately diverge on two independent axes:UniqueFor*the test asked for, which may be nothing, the runtime, or the runtime and version.IgnoreParameters/IgnoreParametersForVerified/IgnoreConstructorParameterskeep parameters in the received name but drop them from the verified name.Both can apply at once, and neither is a reversible transform:
Read the pairing instead of deriving it
Verify 31.27.0 records which verified file each received file belongs to, into the
objdirectory of the test project. This adds a reference toVerify.ExceptionParsingand reads those records viaReceivedMaps, so the pairing is exact rather than guessed.For the records to be found, the working directory has to contain
obj, which holds when running from a project or repository root.The name based fallback, hardened
Records are not always available. They do not exist for snapshots produced by a Verify older than 31.27.0, and they are not found when the working directory does not contain
obj, for example when-wpoints at a snapshot directory below it, or whenobjhas been removed since the test run. So the name based approach remains as a fallback, and has been reworked.It previously generated candidate verified names and probed for them. It now enumerates the verified files that actually exist alongside the received file and ranks them by how specifically the received name reduces to each. That is strictly safer, since only files that exist are ever considered, and it additionally handles:
#name/#indexmulti target files, which the previous runtime handling missed.Networkingand similar, which the previousStartsWith(".Net")check mistook for a runtimeMatches are delimiter bounded, so
Foocan never be paired withFooBar, and every candidate must exist on disk, so a bad guess cannot clobber an unrelated snapshot.Two cases the fallback still cannot resolve, both only reachable without a record:
Integration tests
Adds
Verify.Terminal.IntegrationTests, which runs real Verify to produce received files and then runs the realSnapshotFinderover them, rather than asserting against hand written names. It is multi targeted on purpose, so it exercises the multi targeting naming.The suite pins the assumptions this tool makes about Verify's naming, so a future Verify that changes naming fails these tests rather than silently misbehaving. It covers all the sensible uniqueness combinations (plain,
UniqueForRuntime,UniqueForRuntimeAndVersion,UniqueForArchitecture,UniqueForOSPlatform,UniqueForAssemblyConfiguration, parameters, ignored parameters), and runs each against both the map and the fallback, asserting both reach the same verified file.Where the two paths differ, they are asserted as a pair, which is what demonstrates the map's value:
WithoutMap_CannotBePlacednext toWithMap_IsPlaced.Verify's build server detection is forced off in the harness, since no records are written on a build server, which would otherwise make these pass locally and fail on CI.
Also
SnapshotFinderTestsreworked for the new matching, including cases that must not pair.SnapshotFinderno longer takesIFileSystem, since matching is now done against globbed results.(rerouted)marker shown byreview.