╭ changed ───────────────╮ │src/test/event/patch.zig│ ╰────────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │67 test "patch event conflicts, stacking, and gc" { │ │68 const io = std.testing.io; │ │69 const allocator = std.testing.allocator; │ │70 - const temp_dir_name = "temp-event-patch"; │ │71 - const cwd = std.Io.Dir.cwd(); │ │70 │ │71 // create the temp dir │ │74 - if (cwd.openDir(io, temp_dir_name, .{})) |dir_value| { │ │75 - var dir = dir_value; │ │76 - dir.close(io); │ │77 - try cwd.deleteTree(io, temp_dir_name); │ │78 - } else |_| {} │ │79 - var temp_dir = try cwd.createDirPathOpen(io, temp_dir_name, .{}); │ │80 - defer cwd.deleteTree(io, temp_dir_name) catch {}; │ │81 - defer temp_dir.close(io); │ │72 + var temp = std.testing.tmpDir(.{}); │ │73 + defer temp.cleanup(); │ │74 + const temp_path = try temp.dir.realPathFileAlloc(io, ".", allocator); │ │75 + defer allocator.free(temp_path); │ │76 │ │83 - const cwd_path = try std.process.currentPathAlloc(io, allocator); │ │84 - defer allocator.free(cwd_path); │ │85 - const upstream_path = try std.fs.path.join(allocator, &.{ cwd_path, temp_dir_name, "upstream" });│ │77 + const upstream_path = try std.fs.path.join(allocator, &.{ temp_path, "upstream" }); │ │78 defer allocator.free(upstream_path); │ │87 - const target_path = try std.fs.path.join(allocator, &.{ cwd_path, temp_dir_name, "target" }); │ │79 + const target_path = try std.fs.path.join(allocator, &.{ temp_path, "target" }); │ │80 defer allocator.free(target_path); │ │89 - const source_path = try std.fs.path.join(allocator, &.{ cwd_path, temp_dir_name, "source" }); │ │81 + const source_path = try std.fs.path.join(allocator, &.{ temp_path, "source" }); │ │82 defer allocator.free(source_path); │ │83 │ │84 // │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────╮ │480 } │ │481 │ │482 test "patch lifecycle" { │ │491 - try patchLifecycle("temp-patch-lifecycle-squash", .squash); │ │492 - try patchLifecycle("temp-patch-lifecycle-source", .source); │ │483 + try patchLifecycle(.squash); │ │484 + try patchLifecycle(.source); │ │485 } │ │486 │ │495 -fn patchLifecycle(temp_dir_name: []const u8, merge_revision: pch.MergeRevision) !void {│ │487 +fn patchLifecycle(merge_revision: pch.MergeRevision) !void { │ │488 const io = std.testing.io; │ │489 const allocator = std.testing.allocator; │ │498 - const cwd = std.Io.Dir.cwd(); │ │490 │ │500 - if (cwd.openDir(io, temp_dir_name, .{})) |dir_value| { │ │501 - var dir = dir_value; │ │502 - dir.close(io); │ │503 - try cwd.deleteTree(io, temp_dir_name); │ │504 - } else |_| {} │ │505 - var temp_dir = try cwd.createDirPathOpen(io, temp_dir_name, .{}); │ │506 - defer cwd.deleteTree(io, temp_dir_name) catch {}; │ │507 - defer temp_dir.close(io); │ │491 + var temp = std.testing.tmpDir(.{}); │ │492 + defer temp.cleanup(); │ │493 + const temp_path = try temp.dir.realPathFileAlloc(io, ".", allocator); │ │494 + defer allocator.free(temp_path); │ │495 │ │509 - const cwd_path = try std.process.currentPathAlloc(io, allocator); │ │510 - defer allocator.free(cwd_path); │ │511 - const root = try std.fs.path.join(allocator, &.{ cwd_path, temp_dir_name }); │ │512 - defer allocator.free(root); │ │513 - const repos_dir = try std.fs.path.join(allocator, &.{ root, "repos" }); │ │496 + const repos_dir = try std.fs.path.join(allocator, &.{ temp_path, "repos" }); │ │497 defer allocator.free(repos_dir); │ │515 - const admin_path = try std.fs.path.join(allocator, &.{ root, "admin" }); │ │498 + const admin_path = try std.fs.path.join(allocator, &.{ temp_path, "admin" }); │ │499 defer allocator.free(admin_path); │ │517 - const upstream_path = try std.fs.path.join(allocator, &.{ root, "upstream" }); │ │500 + const upstream_path = try std.fs.path.join(allocator, &.{ temp_path, "upstream" });│ │501 defer allocator.free(upstream_path); │ │519 - const source_path = try std.fs.path.join(allocator, &.{ root, "source" }); │ │502 + const source_path = try std.fs.path.join(allocator, &.{ temp_path, "source" }); │ │503 defer allocator.free(source_path); │ │504 │ │505 var prng = std.Random.DefaultPrng.init(std.testing.random_seed); │ ╰────────────────────────────────────────────────────────────────────────────────────────────╯