aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorIgor Anić <igor.anic@gmail.com>2024-03-03 10:58:16 +0100
committerIgor Anić <igor.anic@gmail.com>2024-03-11 12:24:11 +0100
commit8cc35a0255cae7728cfadfbe625986dc7c509def (patch)
tree819048b7e3b7790873c04a50c6bd39de7d8e0f7d /lib
parent67336ca8c64a4c6d9f7304b6319776c64044660a (diff)
downloadzig-8cc35a0255cae7728cfadfbe625986dc7c509def.tar.gz
zig-8cc35a0255cae7728cfadfbe625986dc7c509def.zip
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/std/tar/test.zig13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/std/tar/test.zig b/lib/std/tar/test.zig
index bea7bb1aa4..6d9788de07 100644
--- a/lib/std/tar/test.zig
+++ b/lib/std/tar/test.zig
@@ -539,5 +539,16 @@ test "pipeToFileSystem" {
try testing.expect((try root.dir.statFile("b/symlink")).kind == .file); // statFile follows symlink
var buf: [32]u8 = undefined;
- try testing.expectEqualSlices(u8, "../a/file", try root.dir.readLink("b/symlink", &buf));
+ try testing.expectEqualSlices(
+ u8,
+ "../a/file",
+ normalizePath(try root.dir.readLink("b/symlink", &buf)),
+ );
+}
+
+fn normalizePath(bytes: []u8) []u8 {
+ const canonical_sep = std.fs.path.sep_posix;
+ if (std.fs.path.sep == canonical_sep) return bytes;
+ std.mem.replaceScalar(u8, bytes, std.fs.path.sep, canonical_sep);
+ return bytes;
}