diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-18 17:44:54 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-18 17:44:54 -0300 |
| commit | 41f665c986886790e474bef78928f4b0d3b05c21 (patch) | |
| tree | fe14dc9afdbcc36e42fbdcb17e7257083dda9d98 /test | |
| parent | e3e9a2d35ded6b668c2bb668845bb39d86e0412b (diff) | |
| parent | f3a38a45c00eb02f0aaaca7185e5601ab7224913 (diff) | |
| download | pardes-41f665c986886790e474bef78928f4b0d3b05c21.tar.gz pardes-41f665c986886790e474bef78928f4b0d3b05c21.zip | |
integration: addons in a client part 4 (the scroll bench's clock, a view laid out as the active one, the Shadow path deleted, address P:H on a late joiner) with the client path's round 4 and Zig 0.17.1: no conflict; on Zig 0.17.1: replicas with five clients: diverged 0, unequal 0, deltas checked/wrong 1782/0, 1769/0, 1871/0, quiet checks 582/0, 773/0, 791/0; tui core-test 819/960 (141 skipped), shell-test 995/998, behaviour-test 274/274 and its replay 20 seeds with 0 failures, pane-test 183/184; gui frame corpus 77/77 Debug and ReleaseFast against mbase171, unit-test 1592/1596, the tui build has no SDL symbol; the perf window, each of its three runs now the gated tree's: corpus2x -0.096% (spread 0.19%), corpus-snake -0.164%: the +0.77% that held this merge was the gate measuring another workspace (the helper that ignored GATE_W)
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'test')
| -rw-r--r-- | test/daemon.py | 6 | ||||
| -rw-r--r-- | test/panes.zig | 148 | ||||
| -rw-r--r-- | test/pdf_scroll_bench.zig | 6 | ||||
| -rw-r--r-- | test/replicas.zig | 2 |
4 files changed, 157 insertions, 5 deletions
diff --git a/test/daemon.py b/test/daemon.py index 051297a8..5bdf1fc4 100644 --- a/test/daemon.py +++ b/test/daemon.py @@ -649,9 +649,9 @@ def pdf_window(binary, gui_binary): """A PDF in a terminal's detached session (the pdf addon its prefix installs, `<prefix>/lib/pardes/addons/pdf.so`), a window client attached and its wheel turned over the PDF: the session's page moves, the - window's digest is the session's, and the window, which runs no addon - code, draws the session's frames of it. Skipped when the build has no - pdf.so.""" + window's digest is the session's, and the window, which runs the + addon's code itself (its state is plain: PA_PLAIN), draws its own + pages from the file. Skipped when the build has no pdf.so.""" lib = Path(binary).resolve().parent.parent / 'lib' / 'pardes' / 'addons' / 'pdf.so' if not lib.exists(): print(f'daemon: no {lib}: the PDF window case skipped') diff --git a/test/panes.zig b/test/panes.zig index fb8adc36..de9d3aea 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -3937,7 +3937,7 @@ const PdfAddon = struct { else try std.testing.expectEqualDeep(@field(s, name), @field(t, name)); } - // Its place: what its kind says, and the Shadow's copy of it. + // Its place: what its kind says, and the loaded copy of it. var here: [32]u8 = undefined; var there: [32]u8 = undefined; try std.testing.expectEqualStrings(pardes.Kind.where(s, &here), pardes.Kind.where(t, &there)); @@ -4178,6 +4178,152 @@ const PdfAddon = struct { try std.testing.expect(notch > 0 and first > at[0] and first < at[1]); try std.testing.expectApproxEqRel(notch / 4, at[2] - at[1], 0.05); } + + test "a window client the size of its session's window shows a PDF's pages where the session's window shows them, a fraction of a pixel scrolled and all" { + if (!addons.has_pdf) return error.SkipZigTest; + const R = pardes.replica; + const gpa = std.testing.allocator; + const a = try R.Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, .{ .vtable = &host_vtable }, false); + defer a.deinit(); + const win = try R.Replica.init(gpa, 2, try a.unit(0, 0), false); + defer win.deinit(); + const land = struct { + a: *R.Authority, + r: *R.Replica, + fn step(l: @This(), ev: pardes.Event) !void { + l.r.confirm(try l.a.local(ev)); + } + }{ .a = a, .r = win }; + // The session's window, and the client's of its size on a view of its own. + const window: pardes.Event = .{ .frontend = .{ .windowed = true, .native_images = true } }; + try land.step(window); + // The client has the addon (a test's replica finds no library of + // its own: it is handed the session's, loaded in this process). + var words: [64]pardes.Kind.LoadedWord = undefined; + var why: pardes.Kind.Buf(160) = .{}; + const lib = pardes.Addon.readLoaded(pdf_lib, &words, &why); + try land.step(.{ .addon = .{ .op = .load, .pane = 0, .kind = &lib } }); + const kind = a.core.kinds.n - 1; + win.core().kinds.ops[kind] = a.core.kinds.ops[kind]; + const id = try opened(a, land); + const k = try a.openView(2); + win.confirm(k.unit); + win.view = k.view; + win.confirm(try a.take(try win.input(window))); + try land.step(.tick); + // A touchpad's 0.6 of a notch in the client: its view's top a + // fraction of a pixel past a row (as a glide's half steps leave it). + const r = win.core().view().rects[id]; + win.confirm(try a.take(try win.input(.{ .mouse = .{ .button = .wheel_down, .kind = .press, .col = r.x + 4, .row = r.y + r.h - 2, .amount = 0.6 } }))); + for (0..2) |_| { + try land.step(.tick); + try jobs(a.core, land); + } + win.settle(); + try std.testing.expect(win.diverged == null); + var arena: std.heap.ArenaAllocator = .init(gpa); + defer arena.deinit(); + var at: [2][8][4]u32 = @splat(@splat(@splat(0))); + for ([_]*Pardes{ a.core, win.core() }, [_]u8{ 0, k.view }, &at) |core, view, *rows| { + core.toView(view); + var n: usize = 0; + for ((try core.render(arena.allocator())).placements.items) |pl| if (pl.pane == id and pl.raster.w > 1 and n < rows.len) { + rows[n] = if (pl.at) |x| .{ x.y, x.h, pl.src.y, pl.src.h } else .{ 0, 0, pl.src.y, pl.src.h }; + n += 1; + }; + try std.testing.expect(n > 0); + } + try std.testing.expectEqualSlices([4]u32, &at[0], &at[1]); + } + + /// A session with design.pdf open and a client on a view of its own + /// (`frontend`'s), which runs the kind as the session does: handed the + /// session's library (a test's replica finds none of its own). + fn clientOf(a: *pardes.replica.Authority, win: *pardes.replica.Replica, frontend: pardes.Event) !struct { id: usize, view: u8 } { + const land = Confirmed{ .a = a, .r = win }; + try land.step(.{ .frontend = .{ .windowed = true, .native_images = true } }); + var words: [64]pardes.Kind.LoadedWord = undefined; + var why: pardes.Kind.Buf(160) = .{}; + const lib = pardes.Addon.readLoaded(pdf_lib, &words, &why); + try land.step(.{ .addon = .{ .op = .load, .pane = 0, .kind = &lib } }); + const kind = a.core.kinds.n - 1; + win.core().kinds.ops[kind] = a.core.kinds.ops[kind]; + const id = try opened(a, land); + const k = try a.openView(2); + win.confirm(k.unit); + win.view = k.view; + win.confirm(try a.take(try win.input(frontend))); + try land.step(.tick); + try jobs(a.core, land); + return .{ .id = id, .view = k.view }; + } + + const Confirmed = struct { + a: *pardes.replica.Authority, + r: *pardes.replica.Replica, + fn step(l: @This(), ev: pardes.Event) !void { + l.r.confirm(try l.a.local(ev)); + } + }; + + test "a terminal's client shows a PDF's page as its text, the session's page's lines from its first" { + if (!addons.has_pdf) return error.SkipZigTest; + const R = pardes.replica; + const gpa = std.testing.allocator; + const a = try R.Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, .{ .vtable = &host_vtable }, false); + defer a.deinit(); + const win = try R.Replica.init(gpa, 2, try a.unit(0, 0), false); + defer win.deinit(); + const c = try clientOf(a, win, .{ .frontend = .{ .windowed = false, .native_images = false } }); + try (Confirmed{ .a = a, .r = win }).step(.tick); + try jobs(a.core, Confirmed{ .a = a, .r = win }); + // The page's text (its body) as the session reads it: its first line + // is the client pane's first row. + const text = try pardes.Kind.body(a.core.panes[c.id].?, gpa); + defer gpa.free(text); + const first = std.mem.trim(u8, text[0 .. std.mem.indexOfScalar(u8, text, '\n') orelse text.len], " "); + try std.testing.expect(first.len > 0); + var arena: std.heap.ArenaAllocator = .init(gpa); + defer arena.deinit(); + win.core().toView(c.view); + const s = try win.core().render(arena.allocator()); + const r = win.core().view().rects[c.id]; + var row: [512]u8 = undefined; + var n: usize = 0; + for (r.x..r.x + r.w) |x| { + const g = s.at(@intCast(x), r.y + win.core().panes[c.id].?.tag_rows).grapheme(); + if (n + g.len > row.len) break; + @memcpy(row[n..][0..g.len], g); + n += g.len; + } + try std.testing.expect(std.mem.indexOf(u8, row[0..n], first[0..@min(first.len, 20)]) != null); + var placed: usize = 0; + for (s.placements.items) |pl| placed += @intFromBool(pl.pane == c.id); + try std.testing.expectEqual(@as(usize, 0), placed); + } + + test "a PDF pane a client closes waits for the session's order (its kind's close is never guessed), then is gone in both" { + if (!addons.has_pdf) return error.SkipZigTest; + const R = pardes.replica; + const gpa = std.testing.allocator; + const a = try R.Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, .{ .vtable = &host_vtable }, false); + defer a.deinit(); + const win = try R.Replica.init(gpa, 2, try a.unit(0, 0), false); + defer win.deinit(); + const c = try clientOf(a, win, .{ .frontend = .{ .windowed = true, .native_images = true } }); + // The client's click in the PDF: its pane the client's own view's. + const r = win.core().view().rects[c.id]; + for ([_]pardes.Mouse.Kind{ .press, .release }) |kind| win.confirm(try a.take(try win.input(.{ .mouse = .{ .button = .left, .kind = kind, .col = r.x + 4, .row = r.y + r.h - 2 } }))); + win.settle(); + const stopped = win.stats.stopped; + const sent = try win.input(.{ .command = "Del" }); + try std.testing.expect(win.core().panes[c.id] != null); + try std.testing.expectEqual(stopped + 1, win.stats.stopped); + win.confirm(try a.take(sent)); + win.settle(); + try std.testing.expect(a.core.panes[c.id] == null and win.core().panes[c.id] == null); + try std.testing.expect(win.diverged == null); + } }; test { diff --git a/test/pdf_scroll_bench.zig b/test/pdf_scroll_bench.zig index bb4640f7..595037ae 100644 --- a/test/pdf_scroll_bench.zig +++ b/test/pdf_scroll_bench.zig @@ -277,9 +277,15 @@ fn measure(config: Config, plan: Plan) !Result { var visual: u64 = 0x7061_7264_6573_5343; var shown: u64 = 0; var total: u64 = 0; + // The core's clock a frame on at each, as a shell's loop moves it + // (its glide and a fling are on that clock). + var now: u64 = std.time.ns_per_s; + core.advance(now); for (0..plan.frames) |frame| { const button: pardes.Mouse.Button = if (plan.scenario == .fling_reverse and frame >= plan.down_frames) .wheel_up else .wheel_down; const started = nowNs(); + now += pardes.frame_ns; + core.advance(now); for (0..ticks) |_| core.update(.{ .mouse = .{ .button = button, .kind = .press, .col = rect.x + rect.w / 2, .row = rect.y + rect.h / 2, .amount = config.turn } }); _ = arena.reset(.retain_capacity); const surface = try core.render(arena.allocator()); diff --git a/test/replicas.zig b/test/replicas.zig index 8d4b2e38..aea6ef7f 100644 --- a/test/replicas.zig +++ b/test/replicas.zig @@ -1239,7 +1239,7 @@ fn push(q: *std.PriorityQueue(Msg, void, Msg.order), nn: *u64, m: Msg) !void { fn flushAll(sc: *replica.Screens, core: *pardes.Pardes, ps: []const u16, list: *std.ArrayListUnmanaged([]u8), q: *std.PriorityQueue(Msg, void, Msg.order), nn: *u64, now: u64, dl: []Link, rnd: std.Random, ow: u64, jt: u64, vs: *std.AutoHashMapUnmanaged(u64, u64), tot: *Totals) !void { for (ps, 0..) |peer, c| { list.clearRetainingCapacity(); - // No pane of a kind here: the view a Shadow is painted for is moot. + // Terminals alone cross: the view is not read. try sc.flush(core, peer, 0, list); for (list.items) |bytes| { tot.deltas += 1; |
