commit 4cf7dc22fa6796d231397ee38a54536d4e94f5bc (tree)
parent b4831403c929d429c7710d5004ec32fd0dfbd0a4
Author: Ryan Liptak <squeek502@hotmail.com>
Date: Wed, 7 Jan 2026 20:47:08 -0800
Expand the errors that act as "sym links can't be created" on Windows
Previously, the errors that are now mapped to AccessDenied, PermissionDenied, and FileSystem were all mapped to AccessDenied.
Diffstat:
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/lib/std/fs/test.zig b/lib/std/fs/test.zig
@@ -182,20 +182,21 @@ fn testWithPathTypeIfSupported(comptime path_type: PathType, comptime path_sep:
}
// For use in test setup. If the symlink creation fails on Windows with
-// AccessDenied, then make the test failure silent (it is not a Zig failure).
+// AccessDenied/PermissionDenied/FileSystem, then make the test failure silent (it is not a Zig failure).
fn setupSymlink(io: Io, dir: Dir, target: []const u8, link: []const u8, flags: SymLinkFlags) !void {
return dir.symLink(io, target, link, flags) catch |err| switch (err) {
- // Symlink requires admin privileges on windows, so this test can legitimately fail.
- error.AccessDenied => if (native_os == .windows) return error.SkipZigTest else return err,
+ // On Windows, symlinks require admin privileges and the underlying filesystem must support symlinks
+ error.AccessDenied, error.PermissionDenied, error.FileSystem => if (native_os == .windows) return error.SkipZigTest else return err,
else => return err,
};
}
// For use in test setup. If the symlink creation fails on Windows with
-// AccessDenied, then make the test failure silent (it is not a Zig failure).
+// AccessDeniedPermissionDenied/FileSystem, then make the test failure silent (it is not a Zig failure).
fn setupSymlinkAbsolute(io: Io, target: []const u8, link: []const u8, flags: SymLinkFlags) !void {
return Dir.symLinkAbsolute(io, target, link, flags) catch |err| switch (err) {
- error.AccessDenied => if (native_os == .windows) return error.SkipZigTest else return err,
+ // On Windows, symlinks require admin privileges and the underlying filesystem must support symlinks
+ error.AccessDenied, error.PermissionDenied, error.FileSystem => if (native_os == .windows) return error.SkipZigTest else return err,
else => return err,
};
}
@@ -2373,13 +2374,7 @@ test "readlinkat" {
try tmp.dir.writeFile(io, .{ .sub_path = "file.txt", .data = "nonsense" });
// create a symbolic link
- tmp.dir.symLink(io, "file.txt", "link", .{}) catch |err| switch (err) {
- error.AccessDenied => {
- // Symlink requires admin privileges on windows, so this test can legitimately fail.
- if (native_os == .windows) return error.SkipZigTest;
- },
- else => |e| return e,
- };
+ try setupSymlink(io, tmp.dir, "file.txt", "link", .{});
// read the link
var buffer: [Dir.max_path_bytes]u8 = undefined;