Skip to content

Commit bb4cb34

Browse files
kcbannerandrewrk
authored andcommitted
test: fix "chdir smoke test" comparing paths with potentially different drive letter cases
1 parent 0a8b7ad commit bb4cb34

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/std/os/test.zig

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,14 @@ test "chdir smoke test" {
6464

6565
var new_cwd_buf: [fs.MAX_PATH_BYTES]u8 = undefined;
6666
const new_cwd = try os.getcwd(new_cwd_buf[0..]);
67-
try expect(mem.eql(u8, tmp_dir_path, new_cwd));
67+
68+
// On Windows, fs.path.resolve returns an uppercase drive letter, but the drive letter returned by getcwd may be lowercase
69+
var resolved_cwd_buf: [fs.MAX_PATH_BYTES]u8 = undefined;
70+
var resolved_cwd = path: {
71+
var allocator = std.heap.FixedBufferAllocator.init(&resolved_cwd_buf);
72+
break :path try fs.path.resolve(allocator.allocator(), &[_][]const u8{new_cwd});
73+
};
74+
try expect(mem.eql(u8, tmp_dir_path, resolved_cwd));
6875

6976
// Restore cwd because process may have other tests that do not tolerate chdir.
7077
tmp_dir.close();

0 commit comments

Comments
 (0)