authorgravatar for igor.anic@gmail.comIgor Anić <igor.anic@gmail.com> 2024-03-03 10:58:16+01:00
committergravatar for igor.anic@gmail.comIgor Anić <igor.anic@gmail.com> 2024-03-11 12:24:11+01:00
log8cc35a0255cae7728cfadfbe625986dc7c509def
tree819048b7e3b7790873c04a50c6bd39de7d8e0f7d
parent67336ca8c64a4c6d9f7304b6319776c64044660a

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 files changed, 12 insertions(+), 1 deletions(-)

lib/std/tar/test.zig+12-1
......@@ -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
549fn 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}