Skip to content

Commit

Permalink
fix test to restore cwd after chdir
Browse files Browse the repository at this point in the history
- `../zig-cache/tmp` is no longer created by subsequent test(s)
  • Loading branch information
mikdusan committed May 7, 2021
1 parent 530e67c commit 84d5cc3
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/std/os/test.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 84d5cc3

Please sign in to comment.