motiejus/zig

fork of https://codeberg.org/ziglang/zig
git clone https://git.jakstys.lt/motiejus/zig.git
Log | Tree | Refs | README | LICENSE

commit 1eddc1737c959e187070a7ddd470e8c2d22ac46d (tree)
parent a136890accfc3b269b6eaa9139bae829ef36cc6b
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Tue,  6 Jan 2026 16:21:39 -0800

std: add test coverage for Io.File.Atomic.link

Diffstat:
Mlib/std/fs/test.zig | 15+++++++++++++++
1 file changed, 15 insertions(+), 0 deletions(-)

diff --git a/lib/std/fs/test.zig b/lib/std/fs/test.zig @@ -1651,6 +1651,21 @@ test "AtomicFile" { \\ this is a test file ; + // link() succeeds with no file already present + { + var af = try ctx.dir.createFileAtomic(io, test_out_file, .{ .replace = false }); + defer af.deinit(io); + try af.file.writeStreamingAll(io, test_content); + try af.link(io); + } + // link() returns error.PathAlreadyExists if file already present + { + var af = try ctx.dir.createFileAtomic(io, test_out_file, .{ .replace = false }); + defer af.deinit(io); + try af.file.writeStreamingAll(io, test_content); + try expectError(error.PathAlreadyExists, af.link(io)); + } + // replace() succeeds if file already present { var af = try ctx.dir.createFileAtomic(io, test_out_file, .{ .replace = true }); defer af.deinit(io);