From 84d5cc31c560749eda1e36b7bc9e6cf542eee550 Mon Sep 17 00:00:00 2001 From: Michael Dusan Date: Thu, 6 May 2021 12:53:48 -0400 Subject: [PATCH] fix test to restore cwd after chdir - `../zig-cache/tmp` is no longer created by subsequent test(s) --- lib/std/os/test.zig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/std/os/test.zig b/lib/std/os/test.zig index f0f0a7c98812..16521d7e27ff 100644 --- a/lib/std/os/test.zig +++ b/lib/std/os/test.zig @@ -43,6 +43,8 @@ test "chdir smoke test" { // Next, change current working directory to one level above const parent = fs.path.dirname(old_cwd) orelse unreachable; // old_cwd should be absolute try os.chdir(parent); + // Restore cwd because process may have other tests that do not tolerate chdir. + defer os.chdir(old_cwd) catch unreachable; var new_cwd_buf: [fs.MAX_PATH_BYTES]u8 = undefined; const new_cwd = try os.getcwd(new_cwd_buf[0..]); expect(mem.eql(u8, parent, new_cwd));