fix: correct Windows path scrubbing regex in snapshot tests#4647
Merged
fix: correct Windows path scrubbing regex in snapshot tests#4647
Conversation
The regex for scrubbing Windows file paths was incorrectly using `\\\\` (matching two literal backslashes) instead of `\\` (matching one literal backslash). In a verbatim string (`@"..."`), `\\` represents a single literal backslash, which is what Windows paths like `C:\Users\` contain. This caused Windows CI failures in TUnit.Core.SourceGenerator.Tests on .NET Framework 4.7.2 because file paths in generated code were not being scrubbed correctly, leading to snapshot test mismatches. Changed from: @"[A-Za-z]:\\\\[^""\s,)]+" Changed to: @"[A-Za-z]:\\[^""\s,)]+" This ensures Windows paths are properly replaced with "PATH_SCRUBBED" in snapshot tests, making them platform-independent.
Contributor
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. This is a clean bug fix that correctly addresses the Windows path scrubbing issue. The regex pattern change from |
This was referenced Feb 5, 2026
This was referenced Feb 11, 2026
Open
Chore(deps): Bump TUnit.Assertions from 1.12.111 to 1.15.0
code-of-chaos/cs_code-of_chaos-testing#91
Open
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.
Problem
Windows CI was failing on .NET Framework 4.7.2 in
TUnit.Core.SourceGenerator.Tests, specifically theBasicTests.Test()method and other snapshot tests.Root Cause
The regex pattern used to scrub Windows file paths in snapshot tests was incorrect:
@"[A-Za-z]:\\\\[^""\s,)]+"In a C# verbatim string (
@"..."),\\represents one literal backslash. The pattern\\\\therefore matches two literal backslashes, but Windows paths likeC:\Users\...only contain single backslashes between path segments.This meant file paths weren't being scrubbed on Windows, causing snapshot mismatches when the actual output contained machine-specific paths.
Solution
Fixed the regex to correctly match single backslashes:
@"[A-Za-z]:\\[^""\s,)]+"Now Windows paths are properly replaced with
"PATH_SCRUBBED"in snapshot tests, making them platform-independent.Testing
Fixes the Windows CI failures observed in recent runs.