aboutsummaryrefslogtreecommitdiff
path: root/lib/std/fs
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2023-09-01 10:13:04 +0200
committerGitHub <noreply@github.com>2023-09-01 10:13:04 +0200
commit5dc2db80554d2b50075ee7e9a9ee2ddf67e25a74 (patch)
treedeadbb575daaa4822d15d7f3d43e46b19ab3945a /lib/std/fs
parent43b27d47c98e0ada00db828ddf410372c6ded66a (diff)
parent01f9cdd21a8f18941636c061a5985a040e4a4bcd (diff)
downloadzig-5dc2db80554d2b50075ee7e9a9ee2ddf67e25a74.tar.gz
zig-5dc2db80554d2b50075ee7e9a9ee2ddf67e25a74.zip
Merge pull request #17029 from squeek502/wasi-statFile-libc
Fix `Dir.statFile` for WASI when linking libc
Diffstat (limited to 'lib/std/fs')
-rw-r--r--lib/std/fs/test.zig18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/std/fs/test.zig b/lib/std/fs/test.zig
index ade3fc55ab..2c3de6b405 100644
--- a/lib/std/fs/test.zig
+++ b/lib/std/fs/test.zig
@@ -569,6 +569,24 @@ test "readAllAlloc" {
try testing.expectError(error.FileTooBig, file.readToEndAlloc(testing.allocator, write_buf.len - 1));
}
+test "Dir.statFile" {
+ // TODO: Re-enable once https://github.com/ziglang/zig/issues/17034 is solved
+ if (builtin.os.tag == .linux and builtin.link_libc and builtin.abi == .gnu) return error.SkipZigTest;
+
+ try testWithAllSupportedPathTypes(struct {
+ fn impl(ctx: *TestContext) !void {
+ const test_file_name = try ctx.transformPath("test_file");
+
+ try testing.expectError(error.FileNotFound, ctx.dir.statFile(test_file_name));
+
+ try ctx.dir.writeFile(test_file_name, "");
+
+ const stat = try ctx.dir.statFile(test_file_name);
+ try testing.expectEqual(File.Kind.file, stat.kind);
+ }
+ }.impl);
+}
+
test "directory operations on files" {
try testWithAllSupportedPathTypes(struct {
fn impl(ctx: *TestContext) !void {