Skip to content

Commit 5e7b816

Browse files
committed
std.tar: fix path testing on windows
Fixing ci error: error: 'tar.test.test.pipeToFileSystem' failed: slices differ. first difference occurs at index 2 (0x2) ============ expected this output: ============= len: 9 (0x9) 2E 2E 2F 61 2F 66 69 6C 65 ../a/file ============= instead found this: ============== len: 9 (0x9) 2E 2E 5C 61 5C 66 69 6C 65 ..\a\file After #19136 dir.symlink changes path separtors to \ on windows.
1 parent dc57471 commit 5e7b816

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/std/tar/test.zig

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,5 +539,16 @@ test "pipeToFileSystem" {
539539
try testing.expect((try root.dir.statFile("b/symlink")).kind == .file); // statFile follows symlink
540540

541541
var buf: [32]u8 = undefined;
542-
try testing.expectEqualSlices(u8, "../a/file", try root.dir.readLink("b/symlink", &buf));
542+
try testing.expectEqualSlices(
543+
u8,
544+
"../a/file",
545+
normalizePath(try root.dir.readLink("b/symlink", &buf)),
546+
);
547+
}
548+
549+
fn normalizePath(bytes: []u8) []u8 {
550+
const canonical_sep = std.fs.path.sep_posix;
551+
if (std.fs.path.sep == canonical_sep) return bytes;
552+
std.mem.replaceScalar(u8, bytes, std.fs.path.sep, canonical_sep);
553+
return bytes;
543554
}

0 commit comments

Comments
 (0)