From 78019452f7caf5badc1fac2fe11fbac19449792f Mon Sep 17 00:00:00 2001 From: Ryan Liptak Date: Sun, 23 May 2021 16:35:31 -0700 Subject: [PATCH] Add updateFile to . and .. fs tests --- lib/std/fs/test.zig | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/std/fs/test.zig b/lib/std/fs/test.zig index 413646ca98..27dd48240d 100644 --- a/lib/std/fs/test.zig +++ b/lib/std/fs/test.zig @@ -954,6 +954,10 @@ test ". and .. in fs.Dir functions" { renamed_file.close(); try tmp.dir.deleteFile("./subdir/../rename"); + try tmp.dir.writeFile("./subdir/../update", "something"); + const prev_status = try tmp.dir.updateFile("./subdir/../file", tmp.dir, "./subdir/../update", .{}); + try testing.expectEqual(fs.PrevStatus.stale, prev_status); + try tmp.dir.deleteDir("./subdir"); } @@ -991,5 +995,12 @@ test ". and .. in absolute functions" { renamed_file.close(); try fs.deleteFileAbsolute(renamed_file_path); + const update_file_path = try fs.path.join(allocator, &[_][]const u8{ subdir_path, "../update" }); + const update_file = try fs.createFileAbsolute(update_file_path, .{}); + try update_file.writeAll("something"); + update_file.close(); + const prev_status = try fs.updateFileAbsolute(created_file_path, update_file_path, .{}); + try testing.expectEqual(fs.PrevStatus.stale, prev_status); + try fs.deleteDirAbsolute(subdir_path); }