Skip to content

Commit 6866757

Browse files
committed
fix: normalize vitest RUN line path on Windows for stable snap tests
On Windows CI, vitest outputs short path names (e.g., RUNNER~1) in the RUN line that don't match the cwd passed to the normalizer. Add a fallback regex to replace Windows absolute paths in vitest RUN lines with <cwd>.
1 parent 41497be commit 6866757

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

packages/tools/src/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ export function replaceUnstableOutput(output: string, cwd?: string) {
4040
// Pattern: backslash between alphanumeric/dot/underscore/hyphen chars
4141
output = output.replaceAll(/([a-zA-Z0-9._-])\\([a-zA-Z0-9._-])/g, '$1/$2');
4242
}
43+
// Normalize vitest RUN line: path may not match cwd on Windows due to short path names (RUNNER~1).
44+
// Format: " RUN /path" or " RUN v1.0.0 /path"
45+
output = output.replaceAll(/( RUN (?:v\S+ )?)(?!<cwd>)[A-Za-z]:[\\/]\S+/g, '$1<cwd>');
46+
4347
return (
4448
output
4549
// semver version

0 commit comments

Comments
 (0)