Skip to content

Commit 35c7ef8

Browse files
committed
std.tar: fix test hanging on windows
Problem was manifested only on windows with target `-target aarch64-windows-gnu`. I was creating new files but not closing any of them. Tmp dir cleanup hangs looping in deleteTree forever.
1 parent 313f504 commit 35c7ef8

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

lib/std/tar.zig

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -894,25 +894,23 @@ test "header parse mode" {
894894
}
895895

896896
test "create file and symlink" {
897-
// With test enabled this is hanging under windows:
898-
// zig build test docs --zig-lib-dir .\lib\ -Dstatic-llvm -Dskip-non-native -Denable-symlinks-windows
899-
const builtin = @import("builtin");
900-
if (builtin.os.tag == .windows) return error.SkipZigTest;
901-
902897
var root = std.testing.tmpDir(.{});
903898
defer root.cleanup();
904899

905-
_ = try createDirAndFile(root.dir, "file1");
906-
_ = try createDirAndFile(root.dir, "a/b/c/file2");
900+
var file = try createDirAndFile(root.dir, "file1");
901+
file.close();
902+
file = try createDirAndFile(root.dir, "a/b/c/file2");
903+
file.close();
907904

908-
_ = createDirAndSymlink(root.dir, "a/b/c/file2", "symlink1") catch |err| {
905+
createDirAndSymlink(root.dir, "a/b/c/file2", "symlink1") catch |err| {
909906
// On Windows when developer mode is not enabled
910907
if (err == error.AccessDenied) return error.SkipZigTest;
911908
return err;
912909
};
913-
_ = try createDirAndSymlink(root.dir, "../../../file1", "d/e/f/symlink2");
910+
try createDirAndSymlink(root.dir, "../../../file1", "d/e/f/symlink2");
914911

915912
// Danglink symlnik, file created later
916-
_ = try createDirAndSymlink(root.dir, "../../../g/h/i/file4", "j/k/l/symlink3");
917-
_ = try createDirAndFile(root.dir, "g/h/i/file4");
913+
try createDirAndSymlink(root.dir, "../../../g/h/i/file4", "j/k/l/symlink3");
914+
file = try createDirAndFile(root.dir, "g/h/i/file4");
915+
file.close();
918916
}

0 commit comments

Comments
 (0)