authorgravatar for samy2014@free.frsamy007 <samy2014@free.fr> 2024-07-28 14:13:58+02:00
committergravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2026-03-10 00:10:49-07:00
loga5dd6444c39e3852962a3b1a74d832ca9fdadd32
tree30e02d0e1b482a37c95a8539d6feb04cdb749f48
parent416ef983c40cf96b522fd976b8fbaf82eaf63906

Add test for calling statFile on a symlink


1 files changed, 22 insertions(+), 0 deletions(-)

lib/std/fs/test.zig+22
......@@ -298,6 +298,28 @@ test "File.stat on a File that is a symlink returns Kind.sym_link" {
298298 }.impl);
299299}
300300
301test "Dir.statFile on a symlink" {
302 const io = testing.io;
303
304 try testWithAllSupportedPathTypes(struct {
305 fn impl(ctx: *TestContext) !void {
306 const dir_target_path = try ctx.transformPath("test_file");
307 try ctx.dir.writeFile(io, .{
308 .sub_path = dir_target_path,
309 .data = "Some test content",
310 });
311
312 try setupSymlink(io, ctx.dir, dir_target_path, "symlink", .{});
313
314 const file_stat = try ctx.dir.statFile(io, "test_file", .{ .follow_symlinks = false });
315 try testing.expectEqual(File.Kind.file, file_stat.kind);
316
317 const link_stat = try ctx.dir.statFile(io, "symlink", .{ .follow_symlinks = false });
318 try testing.expectEqual(File.Kind.sym_link, link_stat.kind);
319 }
320 }.impl);
321}
322
301323test "openDir" {
302324 const io = testing.io;
303325