From a5dd6444c39e3852962a3b1a74d832ca9fdadd32 Mon Sep 17 00:00:00 2001 From: samy007 Date: Sun, 28 Jul 2024 14:13:58 +0200 Subject: [PATCH] Add test for calling statFile on a symlink --- lib/std/fs/test.zig | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/std/fs/test.zig b/lib/std/fs/test.zig index 3201b35166de4c9e119f119bd28f839308aaf419..52b0df581fbcb4b8d8674425489826d86dce0c2a 100644 --- a/lib/std/fs/test.zig +++ b/lib/std/fs/test.zig @@ -298,6 +298,28 @@ test "File.stat on a File that is a symlink returns Kind.sym_link" { }.impl); } +test "Dir.statFile on a symlink" { + const io = testing.io; + + try testWithAllSupportedPathTypes(struct { + fn impl(ctx: *TestContext) !void { + const dir_target_path = try ctx.transformPath("test_file"); + try ctx.dir.writeFile(io, .{ + .sub_path = dir_target_path, + .data = "Some test content", + }); + + try setupSymlink(io, ctx.dir, dir_target_path, "symlink", .{}); + + const file_stat = try ctx.dir.statFile(io, "test_file", .{ .follow_symlinks = false }); + try testing.expectEqual(File.Kind.file, file_stat.kind); + + const link_stat = try ctx.dir.statFile(io, "symlink", .{ .follow_symlinks = false }); + try testing.expectEqual(File.Kind.sym_link, link_stat.kind); + } + }.impl); +} + test "openDir" { const io = testing.io; -- 2.54.0