zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 7e542e788c335b33a2c19f3ec1b453777cad901a (tree)
parent 3f9294c73501f55bcba1fe8b5da1ad2f2b0af9e5
Author: Ryan Liptak <squeek502@hotmail.com>
Date:   Fri, 11 Aug 2023 17:48:25 -0700

fs tests: Add a 'non-cwd .. parent' test

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

diff --git a/lib/std/fs/test.zig b/lib/std/fs/test.zig @@ -101,6 +101,27 @@ test "openDir cwd parent .." { defer dir.close(); } +test "openDir non-cwd parent .." { + if (builtin.os.tag == .wasi) return error.SkipZigTest; + + var tmp = tmpDir(.{}); + defer tmp.cleanup(); + + var subdir = try tmp.dir.makeOpenPath("subdir", .{}); + defer subdir.close(); + + var dir = try subdir.openDir("..", .{}); + defer dir.close(); + + const expected_path = try tmp.dir.realpathAlloc(testing.allocator, "."); + defer testing.allocator.free(expected_path); + + const actual_path = try dir.realpathAlloc(testing.allocator, "."); + defer testing.allocator.free(actual_path); + + try testing.expectEqualStrings(expected_path, actual_path); +} + test "readLinkAbsolute" { if (builtin.os.tag == .wasi) return error.SkipZigTest;