authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-14 20:48:01-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-15 14:18:20-08:00
logc4df980ac2678b45dbe6fffbc8d3d96cb28b40ea
tree23dba38975bf812d29e91b214f4e58ad7de786e0
parente70def70ece846433b7a2140291ed416a6c34f43

std.fs: fix test cases regarding error.IsDir on WASI

why were we testing for shitty behavior?

1 files changed, 2 insertions(+), 11 deletions(-)

lib/std/fs/test.zig+2-11
...@@ -827,11 +827,6 @@ test "file operations on directories" {...@@ -827,11 +827,6 @@ test "file operations on directories" {
827 const buf = try ctx.dir.readFileAlloc(io, test_dir_name, testing.allocator, .unlimited);827 const buf = try ctx.dir.readFileAlloc(io, test_dir_name, testing.allocator, .unlimited);
828 testing.allocator.free(buf);828 testing.allocator.free(buf);
829 },829 },
830 .wasi => {
831 // WASI return EBADF, which gets mapped to NotOpenForReading.
832 // See https://github.com/bytecodealliance/wasmtime/issues/1935
833 try expectError(error.NotOpenForReading, ctx.dir.readFileAlloc(io, test_dir_name, testing.allocator, .unlimited));
834 },
835 else => {830 else => {
836 try expectError(error.IsDir, ctx.dir.readFileAlloc(io, test_dir_name, testing.allocator, .unlimited));831 try expectError(error.IsDir, ctx.dir.readFileAlloc(io, test_dir_name, testing.allocator, .unlimited));
837 },832 },
...@@ -851,13 +846,9 @@ test "file operations on directories" {...@@ -851,13 +846,9 @@ test "file operations on directories" {
851 defer handle.close(io);846 defer handle.close(io);
852847
853 // Reading from the handle should fail848 // Reading from the handle should fail
854 const expected_err = switch (native_os) {
855 .wasi => error.NotOpenForReading,
856 else => error.IsDir,
857 };
858 var buf: [1]u8 = undefined;849 var buf: [1]u8 = undefined;
859 try expectError(expected_err, handle.readStreaming(io, &.{&buf}));850 try expectError(error.IsDir, handle.readStreaming(io, &.{&buf}));
860 try expectError(expected_err, handle.readPositional(io, &.{&buf}, 0));851 try expectError(error.IsDir, handle.readPositional(io, &.{&buf}, 0));
861 }852 }
862 try expectError(error.IsDir, ctx.dir.openFile(io, test_dir_name, .{ .allow_directory = false, .mode = .read_only }));853 try expectError(error.IsDir, ctx.dir.openFile(io, test_dir_name, .{ .allow_directory = false, .mode = .read_only }));
863854