Skip to content

Commit ff56138

Browse files
committed
std/fs/test.zig: Add statFile() tests of dangling symlink
Create a dangling symlink and check that statFile works with it.
1 parent d35bdc8 commit ff56138

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/std/fs/test.zig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,19 @@ test "Dir.statFile" {
661661
}.impl);
662662
}
663663

664+
test "statFile on dangling symlink" {
665+
try testWithAllSupportedPathTypes(struct {
666+
fn impl(ctx: *TestContext) !void {
667+
const symlink_name = try ctx.transformPath("dangling-symlink");
668+
const symlink_target = "." ++ fs.path.sep_str ++ "doesnotexist";
669+
670+
try setupSymlink(ctx.dir, symlink_target, symlink_name, .{});
671+
672+
try std.testing.expectError(error.FileNotFound, ctx.dir.statFile(symlink_name));
673+
}
674+
}.impl);
675+
}
676+
664677
test "directory operations on files" {
665678
try testWithAllSupportedPathTypes(struct {
666679
fn impl(ctx: *TestContext) !void {

0 commit comments

Comments
 (0)