╭──────────╮ │← previous│ ╰──────────╯ ╭ changed ───────╮ │src/test/net.zig│ ╰────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────╮ │884 io: std.Io, │ │885 allocator: std.mem.Allocator, │ │886 ) !void { │ │923 - const temp_dir_name = "temp-testnet-push-events"; │ │924 - │ │887 // create the temp dir │ │926 - const cwd = std.Io.Dir.cwd(); │ │927 - var temp_dir_or_err = cwd.openDir(io, temp_dir_name, .{}); │ │928 - if (temp_dir_or_err) |*temp_dir| { │ │929 - temp_dir.close(io); │ │930 - try cwd.deleteTree(io, temp_dir_name); │ │931 - } else |_| {} │ │932 - var temp_dir = try cwd.createDirPathOpen(io, temp_dir_name, .{}); │ │933 - defer cwd.deleteTree(io, temp_dir_name) catch {}; │ │934 - defer temp_dir.close(io); │ │888 + var temp = std.testing.tmpDir(.{}); │ │889 + defer temp.cleanup(); │ │890 + const temp_path = try temp.dir.realPathFileAlloc(io, ".", allocator); │ │891 + defer allocator.free(temp_path); │ │892 │ │893 // init server │ │937 - var server_process = try runServer(io, allocator, temp_dir_name, port);│ │894 + var server_process = try runServer(io, allocator, temp_path, port); │ │895 defer _ = server_process.kill(io); │ │896 │ │897 // register the repo under admin and locate its on-disk directory │ ╰────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────╮ │941 - const server_path = (try repoOnDiskPath(io, allocator, temp_dir_name, "testrepo", true)).?;│ │898 + const server_path = (try repoOnDiskPath(io, allocator, temp_path, "testrepo", true)).?; │ │899 defer allocator.free(server_path); │ │900 │ │901 const repo_opts: rp.RepoOpts(.xit) = .{ .is_test = true }; │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │903 var server_repo = try ServerRepo.init(io, allocator, .{ .bare = true, .path = server_path }); │ │904 defer server_repo.deinit(io, allocator); │ │905 │ │949 - const cwd_path = try std.process.currentPathAlloc(io, allocator); │ │950 - defer allocator.free(cwd_path); │ │951 - │ │952 - const client_path = try std.fs.path.join(allocator, &.{ cwd_path, temp_dir_name, "client" }); │ │906 + const client_path = try std.fs.path.join(allocator, &.{ temp_path, "client" }); │ │907 defer allocator.free(client_path); │ │908 │ │909 var client_repo = try rp.Repo(repo_kind, .{ .is_test = true }).init(io, allocator, .{ .path = client_path });│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────╮ │921 .file => false, │ │922 .wire => |wire_kind| .ssh == wire_kind, │ │923 }; │ │970 - const ssh_cmd_maybe = try sshCommand(is_ssh, allocator, cwd_path, temp_dir_name, port);│ │924 + const ssh_cmd_maybe = try sshCommand(is_ssh, allocator, temp_path, port); │ │925 defer if (ssh_cmd_maybe) |ssh_cmd| allocator.free(ssh_cmd); │ │926 │ │927 var arena = std.heap.ArenaAllocator.init(allocator); │ ╰────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1027 io: std.Io, │ │1028 allocator: std.mem.Allocator, │ │1029 ) !void { │ │1076 - const temp_dir_name = "temp-testnet-clone"; │ │1077 - │ │1030 // create the temp dir │ │1079 - const cwd = std.Io.Dir.cwd(); │ │1080 - var temp_dir_or_err = cwd.openDir(io, temp_dir_name, .{}); │ │1081 - if (temp_dir_or_err) |*temp_dir| { │ │1082 - temp_dir.close(io); │ │1083 - try cwd.deleteTree(io, temp_dir_name); │ │1084 - } else |_| {} │ │1085 - var temp_dir = try cwd.createDirPathOpen(io, temp_dir_name, .{}); │ │1086 - defer cwd.deleteTree(io, temp_dir_name) catch {}; │ │1087 - defer temp_dir.close(io); │ │1031 + var temp = std.testing.tmpDir(.{}); │ │1032 + defer temp.cleanup(); │ │1033 + const temp_path = try temp.dir.realPathFileAlloc(io, ".", allocator); │ │1034 + defer allocator.free(temp_path); │ │1035 │ │1036 // init server │ │1090 - var server_process = try runServer(io, allocator, temp_dir_name, port); │ │1037 + var server_process = try runServer(io, allocator, temp_path, port); │ │1038 defer _ = server_process.kill(io); │ │1092 - │ │1093 - const cwd_path = try std.process.currentPathAlloc(io, allocator); │ │1094 - defer allocator.free(cwd_path); │ │1039 │ │1096 - const temp_path = try std.fs.path.join(allocator, &.{ cwd_path, temp_dir_name }); │ │1097 - defer allocator.free(temp_path); │ │1098 - │ │1040 // register the repo under admin and locate its on-disk directory │ │1100 - const server_path = (try repoOnDiskPath(io, allocator, temp_dir_name, "testrepo", true)).?;│ │1041 + const server_path = (try repoOnDiskPath(io, allocator, temp_path, "testrepo", true)).?; │ │1042 defer allocator.free(server_path); │ │1043 │ │1044 // init server repo with default branch name as main │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1067 defer export_file.close(io); │ │1068 } │ │1069 │ │1129 - const client_path = try std.fs.path.join(allocator, &.{ cwd_path, temp_dir_name, "client" });│ │1070 + const client_path = try std.fs.path.join(allocator, &.{ temp_path, "client" }); │ │1071 defer allocator.free(client_path); │ │1072 │ │1073 // get remote url │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1080 }; │ │1081 │ │1082 if (shell_out_to_git) { │ │1142 - const priv_key_path = try std.fs.path.join(allocator, &.{ cwd_path, temp_dir_name, "key" }); │ │1083 + const priv_key_path = try std.fs.path.join(allocator, &.{ temp_path, "key" }); │ │1084 defer allocator.free(priv_key_path); │ │1085 const ssh_config_arg = try std.fmt.allocPrint(allocator, "core.sshCommand=ssh -p {} -o BatchMode=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o IdentityFile={s}", .{ port + 1, priv_key_path });│ │1086 defer allocator.free(ssh_config_arg); │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────╮ │1104 │ │1105 // make sure shallow clone was successful │ │1106 { │ │1166 - const hello_txt = try temp_dir.openFile(io, "client/hello.txt", .{});│ │1107 + const hello_txt = try temp.dir.openFile(io, "client/hello.txt", .{});│ │1108 hello_txt.close(io); │ │1109 } │ │1110 │ ╰───────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────╮ │1131 │ │1132 // make sure unshallow pull was successful │ │1133 { │ │1193 - const extra_txt = try temp_dir.openFile(io, "client/extra.txt", .{});│ │1134 + const extra_txt = try temp.dir.openFile(io, "client/extra.txt", .{});│ │1135 extra_txt.close(io); │ │1136 } │ │1137 │ ╰───────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────╮ │1138 // delete client and clone again with --shallow-since│ │1198 - try cwd.deleteTree(io, temp_dir_name ++ "/client"); │ │1139 + try temp.dir.deleteTree(io, "client"); │ │1140 │ │1141 { │ │1142 var process = try std.process.spawn(io, .{ │ ╰───────────────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯