summaryrefslogtreecommitdiff
path: root/test/image_harness.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-01 13:46:44 -0300
committerGabriel Schneider <[email protected]>2026-09-01 13:57:41 -0300
commitcce6b18a49870086982f9a0e1fda90ed170b9fba (patch)
treee5ce990d0a1d43503375d891bc51f283e0a1c215 /test/image_harness.zig
parentae9325a5cb128d0d952afb8f9feaaca68e5e37a2 (diff)
downloadpardes-cce6b18a49870086982f9a0e1fda90ed170b9fba.tar.gz
pardes-cce6b18a49870086982f9a0e1fda90ed170b9fba.zip
macos: one tagline rule for both hosts, a kqueue beside the inotify, and effects that compile
Three things this shell had its own copy of, and in each case the fix is that it stops having one. **The tagline band.** A pane tag draws at `gui_tagline_font_percent` of the body face and the band it sits on shrinks with it, while the grid row stays body-sized — so something has to decide where the shorter band sits in the taller row. This shell decided by centring, always, which is precisely the case `config.gui_topbar_pane_border_px` exists to prevent: the topbar's unused half-band meets the first pane tag's unused half-band and the window background shows through the seam. The strip is as wide as the bands are short — on a 20-pixel cell, 4 physical pixels at the default 82%, 10 at 50%, 14 at 30% — so it grew as the tagline face shrank and read as "the tagline is wrong on the mac" rather than as one missing rule. The rule is `pardes.taglineBandOffset` in the core now and both pixel hosts call it: row zero bottom-aligned, the first pane-tag row top-aligned, the two joined by `gui_topbar_pane_border_px` in the theme's scrollbar-track colour, every row between centred, and a `Tagbottom` band on the final row flush with the window edge — with the sub-cell strip beneath it painted in that band's own colour, because the core grid holds only whole cells and a window is any height it likes. `pardes_tagline_band_offset`, `pardes_topbar_pane_border_px` and `pardes_topbar_pane_border_rgb` carry it over the C ABI as PHYSICAL pixels: the host multiplies its points by the backing scale going in and divides coming out, which is the snapping `Metrics` already does for the cell, and is what keeps a one-pixel rule one pixel instead of a two-pixel smear. **The watch.** `file_watch.zig` was one mark/reconcile transaction over `inotify`, so the tty shell, the SDL window and the detached daemon all watched nothing off Linux: an edit made outside pardes never reached the pane, and a PDF replaced on disk kept rendering the old inode. It is the same transaction over two kernels now — `init`, `wait`, `stop`, `drain`, `markDir` and `unmarkDir` are still the whole of it, and the hosts wait on a kqueue and poll it exactly as they did the old descriptor. A macOS mark is TWO filters, because a kqueue directory filter reports its entries changing and never a write to a file already inside it: the parent mark follows rename-over saves, `markFile` catches in-place writes, and `remarkFile` re-arms the file filter once a rename has moved the inode. That is the same pair the AppKit host's DispatchSources already used for the same reason. Directory marks are deduplicated here by device and inode, because each `EVFILT_VNODE` filter needs a descriptor of its own and inotify did that deduplication itself; `stop` and `drain` wake through the one `EVFILT_USER` filter, since a kqueue cannot simply be read the way an inotify descriptor can. **The effects.** The three `crt.ci.metal` entry points are `extern "C" [[stitchable]]`. `CIKernel.kernels(withMetalString:)` compiles that source at runtime, looks for stitchable functions, and rejects the WHOLE source with "cannot find a valid stitchable Metal function in the source" when it finds none — so `ScenePostprocessor.init?` returned nil and every scene effect and panel transition silently degraded to the plain CoreText draw. The `effect_sources.zig` test pins the exact spelling of all three, and `draw-effect` in the e2e suite catches the degradation rather than the spelling. Beside them, the offscreen harness owes the core a PRESENTATION. Its window is borderless and never ordered front, so AppKit runs no display cycle and `pardes_frame_presented` — whose only caller is `draw(_:)` — never fired. The core holds pointer gestures inert while a layout mutation has not reached a backend, which for an unpresenting harness is the rest of the script: the first pane a script opened silently killed every later click, drag and Look. So `readFrame` presents what it just rendered, into a bitmap nobody reads. `PARDES_CHROME` also looks under `/Applications`, where a browser's executable lives inside an application bundle and never on `PATH`. The macOS goldens are regenerated; docs/macos.md, config.md, detached.md, web.md and the design PDF follow.
Diffstat (limited to 'test/image_harness.zig')
-rw-r--r--test/image_harness.zig51
1 files changed, 27 insertions, 24 deletions
diff --git a/test/image_harness.zig b/test/image_harness.zig
index 21ec706e..1141d81f 100644
--- a/test/image_harness.zig
+++ b/test/image_harness.zig
@@ -231,8 +231,11 @@ fn runKitty(arena: std.mem.Allocator, exe: [:0]const u8, base: [:0]const u8) !vo
var h = try eh.Harness.initArgs(gpa, exe, 12, 30, image_path);
defer h.deinit();
- try h.pump(150);
- try h.expectRawContains("\x1b_Gi=1,a=q\x1b\\", "app did not issue the Kitty graphics capability query");
+ try h.expectRawWaitFor(
+ "\x1b_Gi=1,a=q\x1b\\",
+ 5000,
+ "app did not issue the Kitty graphics capability query",
+ );
// APC says graphics is present; DA1 is the last capability response and
// closes the asynchronous handshake. Arrow-up is an ordinary queued event
@@ -278,8 +281,11 @@ fn runKittyPdf(arena: std.mem.Allocator, exe: [:0]const u8, base: [:0]const u8)
var h = try eh.Harness.initArgs(gpa, exe, 16, 40, pdf_path);
defer h.deinit();
- try h.pump(150);
- try h.expectRawContains("\x1b_Gi=1,a=q\x1b\\", "app did not issue the Kitty graphics capability query");
+ try h.expectRawWaitFor(
+ "\x1b_Gi=1,a=q\x1b\\",
+ 5000,
+ "app did not issue the Kitty graphics capability query",
+ );
try h.send("\x1b_Gi=1;OK\x1b\\\x1b[?1;2c\x1b[A");
const transmit = "\x1b_Gf=32,s=96,v=64,i=";
@@ -514,27 +520,24 @@ fn runGui(arena: std.mem.Allocator, exe: [:0]const u8, base: [:0]const u8) !void
var h = try eh.Harness.initArgs(gpa, exe, 10, 20, image_path);
defer h.deinit();
- try h.pump(1200);
-
- const capture = readFile(gpa, capture_path) catch |err| {
- std.debug.print("SDL image harness produced no capture ({t}); raw child output: {s}\n", .{ err, h.raw.items });
- return err;
- };
- defer gpa.free(capture);
- const pixels = ppmPixels(capture) orelse return error.BadCapture;
- var exact: usize = 0;
- var i: usize = 0;
- while (i + 2 < pixels.len) : (i += 3) {
- if (std.mem.eql(u8, pixels[i .. i + 3], &fixture_rgb)) exact += 1;
- }
// The source contributes 512 aligned pixels. Leave ample room for driver
// filtering while still excluding glyph-art fallback and incidental UI
// colors.
- if (exact < 200) {
- std.debug.print("SDL image harness found only {d} native-color pixels in the GPU capture\n", .{exact});
- return error.NativePixelsMissing;
- }
- std.debug.print("native image harness ok: SDL GPU capture ({d} source pixels)\n", .{exact});
+ //
+ // WAIT for the capture rather than budget a fixed startup and read once.
+ // The first frame lands when the GPU device is ready, and on a host whose
+ // only SPIR-V backend is vulkan-on-MoltenVK that is ~0.7s idle and past
+ // 1.9s under load — a 1200ms budget made this arm fail with an unwritten
+ // latest.ppm while the device was still coming up. Same deadline the PDF
+ // arm below already gives its first capture.
+ const bounds = waitForCaptureBounds(&h, capture_path, fixture_rgb, 200, 5000) catch |err| {
+ std.debug.print(
+ "SDL image harness produced no usable capture ({t}); raw child output: {s}\n",
+ .{ err, h.raw.items },
+ );
+ return err;
+ };
+ std.debug.print("native image harness ok: SDL GPU capture ({d} source pixels)\n", .{bounds.count});
}
fn runGuiPdf(arena: std.mem.Allocator, exe: [:0]const u8, base: [:0]const u8) !void {
@@ -681,8 +684,8 @@ fn waitForCaptureBounds(
} else |_| {}
_ = try h.pumpOnce(50);
}
- std.debug.print("SDL PDF harness found only {d} pixels of color {any}\n", .{ best, color });
- return error.PdfPageColorMissing;
+ std.debug.print("SDL harness found only {d} pixels of color {any}\n", .{ best, color });
+ return error.CaptureColorMissing;
}
fn expectThemeGap(