Skip to content

Commit fd5fc00

Browse files
committed
Tweak realpathat tests
1 parent 043da82 commit fd5fc00

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

lib/std/os/test.zig

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -276,16 +276,17 @@ test "realpathat" {
276276
var buf2: [fs.MAX_PATH_BYTES]u8 = undefined;
277277
const cwd_realpathat = try os.realpathat(cwd.fd, "", &buf2);
278278
testing.expect(mem.eql(u8, cwd_path, cwd_realpathat));
279-
const cwd_realpathat2 = try os.realpathat(cwd.fd, ".", &buf2); // shouldn't change a thing
280-
testing.expect(mem.eql(u8, cwd_path, cwd_realpathat2));
281279

282280
// Now, open an actual Dir{"."} since on Unix `realpathat` behaves
283281
// in a special way when `fd` equals `cwd.fd`
284-
const dir = try cwd.openDir(".", .{});
285-
const cwd_realpathat3 = try os.realpathat(dir.fd, "", &buf2);
286-
testing.expect(mem.eql(u8, cwd_path, cwd_realpathat3));
287-
const cwd_realpathat4 = try os.realpathat(dir.fd, ".", &buf2); // shouldn't change a thing
288-
testing.expect(mem.eql(u8, cwd_path, cwd_realpathat4));
282+
var dir = try cwd.openDir(".", .{});
283+
defer dir.close();
284+
285+
const cwd_realpathat2 = try os.realpathat(dir.fd, "", &buf2);
286+
testing.expect(mem.eql(u8, cwd_path, cwd_realpathat2));
287+
288+
// Finally, try getting a path for something that doesn't exist
289+
testing.expectError(error.FileNotFound, os.realpathat(dir.fd, "definitely_bogus_does_not_exist1234", &buf2));
289290
}
290291

291292
test "sigaltstack" {

0 commit comments

Comments
 (0)