graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
test: use portable clipboard failure fixtures
yxlyx3d4e852d7138
diff --git a/src/clipboard_failure_tests.zig b/src/clipboard_failure_tests.zigindex eafe6935..c64d0d72 100644--- a/src/clipboard_failure_tests.zig+++ b/src/clipboard_failure_tests.zig@@ -61,9 +61,12 @@ fn check(comptime replies: []const Reply, expected: clip.GrabAttempt) !void {Mock.path_len = 0;const io = std.testing.io;const gpa = std.testing.allocator;- // Remove a leaked fixture even when a cleanup assertion fails.- defer if (Mock.path_len != 0) std.Io.Dir.cwd().deleteFile(io, Mock.path_buf[0..Mock.path_len]) catch {};- const got = native.grabWithRunner(io, gpa, "clipboard-failure-test", Mock.run);+ var tmp = std.testing.tmpDir(.{});+ defer tmp.cleanup();+ var root_buf: [4096]u8 = undefined;+ const root_len = try tmp.dir.realPath(io, &root_buf);+ const path = try std.fs.path.join(gpa, &.{ root_buf[0..root_len], "clipboard.png" });+ const got = native.grabWithRunner(io, gpa, "clipboard-failure-test", path, Mock.run);defer if (got == .ok) got.ok.release(io, gpa);try std.testing.expectEqual(replies.len, Mock.calls);try std.testing.expectEqual(std.meta.activeTag(expected), std.meta.activeTag(got));diff --git a/src/clipboard_native.zig b/src/clipboard_native.zigindex ad665418..f99f9abf 100644--- a/src/clipboard_native.zig+++ b/src/clipboard_native.zig@@ -6,12 +6,13 @@ pub const script = @embedFile("clipboard_export.js");pub fn grab(io: std.Io, gpa: std.mem.Allocator, board: []const u8) clip.GrabAttempt {if (@import("builtin").os.tag != .macos) return .empty;- return grabWithRunner(io, gpa, board, runner.runCapped);+ const path = clip.tempPath(io, gpa, "png") orelse return .{ .failed = .extract };+ return grabWithRunner(io, gpa, board, path, runner.runCapped);}/// Same extraction path with an injected process boundary for failure tests.-pub fn grabWithRunner(io: std.Io, gpa: std.mem.Allocator, board: []const u8, run: anytype) clip.GrabAttempt {- const path = clip.tempPath(io, gpa, "png") orelse return .{ .failed = .extract };+/// Takes ownership of the gpa-allocated destination, including on failure.+pub fn grabWithRunner(io: std.Io, gpa: std.mem.Allocator, board: []const u8, path: []const u8, run: anytype) clip.GrabAttempt {var keep = false;defer if (!keep) clip.discard(io, gpa, path);// Retry only when the clipboard changed during the read. Promised flavors