authorgravatar for igor.anic@gmail.comIgor Anić <igor.anic@gmail.com> 2024-03-09 13:23:07+01:00
committergravatar for igor.anic@gmail.comIgor Anić <igor.anic@gmail.com> 2024-03-11 12:24:11+01:00
loga9e7abda204300bd13ce08721bf13801817dd6ab
tree6f3132611f0aca616ceee6c9466cb36489bd37d6
parent8ec990d6d71174fbc3961fa11d4a74d6ec81f58a

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 files changed, 9 insertions(+), 11 deletions(-)

lib/std/tar.zig+9-11
......@@ -896,25 +896,23 @@ test "header parse mode" {
896896}
897897
898898test "create file and symlink" {
899 // With test enabled this is hanging under windows:
900 // zig build test docs --zig-lib-dir .\lib\ -Dstatic-llvm -Dskip-non-native -Denable-symlinks-windows
901 const builtin = @import("builtin");
902 if (builtin.os.tag == .windows) return error.SkipZigTest;
903
904899 var root = std.testing.tmpDir(.{});
905900 defer root.cleanup();
906901
907 _ = try createDirAndFile(root.dir, "file1");
908 _ = try createDirAndFile(root.dir, "a/b/c/file2");
902 var file = try createDirAndFile(root.dir, "file1");
903 file.close();
904 file = try createDirAndFile(root.dir, "a/b/c/file2");
905 file.close();
909906
910 _ = createDirAndSymlink(root.dir, "a/b/c/file2", "symlink1") catch |err| {
907 createDirAndSymlink(root.dir, "a/b/c/file2", "symlink1") catch |err| {
911908 // On Windows when developer mode is not enabled
912909 if (err == error.AccessDenied) return error.SkipZigTest;
913910 return err;
914911 };
915 _ = try createDirAndSymlink(root.dir, "../../../file1", "d/e/f/symlink2");
912 try createDirAndSymlink(root.dir, "../../../file1", "d/e/f/symlink2");
916913
917914 // Danglink symlnik, file created later
918 _ = try createDirAndSymlink(root.dir, "../../../g/h/i/file4", "j/k/l/symlink3");
919 _ = try createDirAndFile(root.dir, "g/h/i/file4");
915 try createDirAndSymlink(root.dir, "../../../g/h/i/file4", "j/k/l/symlink3");
916 file = try createDirAndFile(root.dir, "g/h/i/file4");
917 file.close();
920918}