Commit 7e542e788c

Ryan Liptak <squeek502@hotmail.com>
2023-08-12 02:48:25
fs tests: Add a 'non-cwd .. parent' test
1 parent 3f9294c
Changed files (1)
lib
std
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;