╭──────────╮ │← previous│ ╰──────────╯ ╭ changed ───────╮ │src/test/net.zig│ ╰────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ 96 - const priv_key_file = try std.Io.Dir.cwd().createFile(io, temp_dir_name ++ "/key", .{});│ │ 96 + const priv_key_path = try std.fs.path.join(allocator, &.{ temp_path, "key" }); │ │ 97 + defer allocator.free(priv_key_path); │ │ 98 + const priv_key_file = try std.Io.Dir.cwd().createFile(io, priv_key_path, .{}); │ │ 99 defer priv_key_file.close(io); │ │100 try priv_key_file.writeStreamingAll(io, │ │101 \\-----BEGIN OPENSSH PRIVATE KEY----- │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────╮ │114 │ │115 // seed the admin event store so the server can resolve <owner>/<repo> paths│ │116 // and authenticate pushes from the dev key above │ │115 - try setupAdmin(io, allocator, temp_dir_name); │ │117 + try setupAdmin(io, allocator, temp_path); │ │118 │ │119 const cwd_path = try std.process.currentPathAlloc(io, allocator); │ │120 defer allocator.free(cwd_path); │ ╰─────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │125 const ssh_listen_arg = std.fmt.comptimePrint("127.0.0.1:{}", .{port + 1}); │ │126 │ │127 const process = try std.process.spawn(io, .{ │ │126 - .argv = &.{ haxy_path, "serve", "--http-listen", http_listen_arg, "--ssh-listen", ssh_listen_arg, "--data-dir", temp_dir_name },│ │128 + .argv = &.{ haxy_path, "serve", "--http-listen", http_listen_arg, "--ssh-listen", ssh_listen_arg, "--data-dir", temp_path }, │ │129 .stdin = .ignore, │ │130 .stdout = .ignore, │ │131 .stderr = .ignore, │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────╮ │151 io: std.Io, │ │152 allocator: std.mem.Allocator, │ │153 ) !void { │ │152 - const temp_dir_name = "temp-testnet-fetch"; │ │153 - │ │154 // create the temp dir │ │155 - const cwd = std.Io.Dir.cwd(); │ │156 - var temp_dir_or_err = cwd.openDir(io, temp_dir_name, .{}); │ │157 - if (temp_dir_or_err) |*temp_dir| { │ │158 - temp_dir.close(io); │ │159 - try cwd.deleteTree(io, temp_dir_name); │ │160 - } else |_| {} │ │161 - var temp_dir = try cwd.createDirPathOpen(io, temp_dir_name, .{}); │ │162 - defer cwd.deleteTree(io, temp_dir_name) catch {}; │ │163 - defer temp_dir.close(io); │ │155 + var temp = std.testing.tmpDir(.{}); │ │156 + defer temp.cleanup(); │ │157 + const temp_path = try temp.dir.realPathFileAlloc(io, ".", allocator); │ │158 + defer allocator.free(temp_path); │ │159 │ │160 // init server │ │166 - var server_process = try runServer(io, allocator, temp_dir_name, port);│ │161 + var server_process = try runServer(io, allocator, temp_path, port); │ │162 defer _ = server_process.kill(io); │ │163 │ │164 // register the repo under admin and locate its on-disk directory │ ╰────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │170 - const server_path = (try repoOnDiskPath(io, allocator, temp_dir_name, "testrepo", true)).?; │ │165 + const server_path = (try repoOnDiskPath(io, allocator, temp_path, "testrepo", true)).?; │ │166 defer allocator.free(server_path); │ │167 │ │168 var server_repo = try rp.Repo(.xit, .{ .is_test = true }).init(io, allocator, .{ .bare = true, .path = server_path });│ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │182 // add a tag │ │183 _ = try server_repo.addTag(io, allocator, .{ .name = "1.0.0", .message = "hi" }); │ │184 │ │190 - const cwd_path = try std.process.currentPathAlloc(io, allocator); │ │191 - defer allocator.free(cwd_path); │ │192 - │ │193 - const client_path = try std.fs.path.join(allocator, &.{ cwd_path, temp_dir_name, "client" }); │ │185 + const client_path = try std.fs.path.join(allocator, &.{ temp_path, "client" }); │ │186 defer allocator.free(client_path); │ │187 │ │188 var client_repo = try rp.Repo(repo_kind, .{ .is_test = true }).init(io, allocator, .{ .path = client_path });│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────╮ │210 .file => false, │ │211 .wire => |wire_kind| .ssh == wire_kind, │ │212 }; │ │221 - const ssh_cmd_maybe = try sshCommand(is_ssh, allocator, cwd_path, temp_dir_name, port);│ │213 + const ssh_cmd_maybe = try sshCommand(is_ssh, allocator, temp_path, port); │ │214 defer if (ssh_cmd_maybe) |ssh_cmd| allocator.free(ssh_cmd); │ │215 │ │216 try client_repo.fetch( │ ╰────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │227 │ │228 // make sure fetch was successful │ │229 { │ │238 - const hello_txt = try temp_dir.openFile(io, "client/hello.txt", .{}); │ │230 + const hello_txt = try temp.dir.openFile(io, "client/hello.txt", .{}); │ │231 defer hello_txt.close(io); │ │232 │ │233 try std.testing.expect(null != try client_repo.readRef(io, .{ .kind = .tag, .name = "1.0.0" }));│ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────╮ │254 │ │255 // make sure fetch was successful │ │256 { │ │265 - const goodbye_txt = try temp_dir.openFile(io, "client/goodbye.txt", .{}); │ │257 + const goodbye_txt = try temp.dir.openFile(io, "client/goodbye.txt", .{}); │ │258 defer goodbye_txt.close(io); │ │259 │ │260 const oid_master = (try client_repo.readRef(io, .{ .kind = .head, .name = "master" })).?;│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────╮ │269 io: std.Io, │ │270 allocator: std.mem.Allocator, │ │271 ) !void { │ │280 - const temp_dir_name = "temp-testnet-push"; │ │281 - │ │272 // create the temp dir │ │283 - const cwd = std.Io.Dir.cwd(); │ │284 - var temp_dir_or_err = cwd.openDir(io, temp_dir_name, .{}); │ │285 - if (temp_dir_or_err) |*temp_dir| { │ │286 - temp_dir.close(io); │ │287 - try cwd.deleteTree(io, temp_dir_name); │ │288 - } else |_| {} │ │289 - var temp_dir = try cwd.createDirPathOpen(io, temp_dir_name, .{}); │ │290 - defer cwd.deleteTree(io, temp_dir_name) catch {}; │ │291 - defer temp_dir.close(io); │ │273 + var temp = std.testing.tmpDir(.{}); │ │274 + defer temp.cleanup(); │ │275 + const temp_path = try temp.dir.realPathFileAlloc(io, ".", allocator); │ │276 + defer allocator.free(temp_path); │ │277 │ │278 // init server │ │294 - var server_process = try runServer(io, allocator, temp_dir_name, port);│ │279 + var server_process = try runServer(io, allocator, temp_path, port); │ │280 defer _ = server_process.kill(io); │ │281 │ │282 // register the repo under admin and locate its on-disk directory │ ╰────────────────────────────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯