From 174e031985db910b4907ba324d6fd12c67898a5a Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sun, 8 Nov 2026 23:49:04 -0300 Subject: tests: monkey and replay are modes of the T1 runner and snapshot.zig goes: behaviour-test runs test/monkey9p.zig bare (its smoke), `-- --monkey ` drives an in-process session with test/monkey.zig's input (keys, leader bursts, the mouse, tiny resizes, over /kbdin, /mousein and Session.resize) hunting panics and hangs, `-- --replay` records each seed's sessions as a tape in memory and replays it (tape.replayBytes, replayMain's loop: three replicas and the dump), and `process-test -- --replay` records and replays the tty cases' real sessions as `zig build replay` did (with the addons it lacked, so images passes); the snap, snap-driver-test, monkey, monkey-test (it no longer compiled), replay and monkey-session steps, pardes-snap and build/snap.zig (now build/process.zig) go; checked: a counter outside the core bumped at the 40th update diverges every T1 seed and 89 of 103 old tapes, one bumped on terminal output diverges no T1 seed but 69 tty cases and 70 old tapes (why the tty replay stays), a panic on a window under 5x5 is found by the T1 monkey (seeds 1 8 17 20) and the old one (seed 13) Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- build/process.zig | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 build/process.zig (limited to 'build/process.zig') diff --git a/build/process.zig b/build/process.zig new file mode 100644 index 00000000..bec37d65 --- /dev/null +++ b/build/process.zig @@ -0,0 +1,87 @@ +const std = @import("std"); + +/// The process tests (test/process_test.zig): real sessions over their +/// sockets, and the tty's own cases each in a pty of its own +/// (test/tty.zig), on the runner they share (test/process.zig); and the +/// window's own, run in full when asked. +pub fn add(b: *std.Build, opts: struct { + exe: *std.Build.Step.Compile, + /// The addons the build made (image, pdf), which every session loads: + /// each `--addon=`, linked into its data directory's addons. + addons: []const *std.Build.Step.Compile, + target: std.Build.ResolvedTarget, + optimize: std.builtin.OptimizeMode, + ghostty_vt: ?*std.Build.Module, + cloud9: *std.Build.Module, + /// The build is the window's (-Dplatform=gui): the process tests drive it. + gui: bool = false, +}) void { + const ninep_client = b.createModule(.{ + .target = opts.target, + .optimize = opts.optimize, + .root_source_file = b.path("src/9p_io.zig"), + .link_libc = true, + }); + ninep_client.addImport("cloud9", opts.cloud9); + // The language server a tty case's `.rs` files speak to. + const lspmock = b.addExecutable(.{ + .name = "pardes-lspmock", + .root_module = b.createModule(.{ + .target = opts.target, + .optimize = opts.optimize, + .root_source_file = b.path("test/lspmock.zig"), + .link_libc = true, + }), + }); + const process_test = b.addExecutable(.{ + .name = "pardes-process-test", + .root_module = b.createModule(.{ + .target = opts.target, + .optimize = opts.optimize, + .root_source_file = b.path("test/process_test.zig"), + .link_libc = true, + }), + }); + if (opts.ghostty_vt) |vt| process_test.root_module.addImport("ghostty-vt", vt); + process_test.root_module.addImport("9p_io", ninep_client); + process_test.root_module.addImport("cloud9", opts.cloud9); + switch (opts.target.result.os.tag) { + .freebsd, .netbsd, .openbsd => process_test.root_module.linkSystemLibrary("util", .{}), + else => {}, + } + const run_process_test = b.addRunArtifact(process_test); + run_process_test.addArtifactArg(opts.exe); + for (opts.addons) |a| run_process_test.addPrefixedFileArg("--addon=", a.getEmittedBin()); + run_process_test.addPrefixedFileArg("--lspmock=", lspmock.getEmittedBin()); + run_process_test.addArg(if (opts.gui) "--backend=gui" else "--backend=tui"); + run_process_test.addPassthruArgs(); + // The tty cases' goldens are test/snapshots/'s, from the build root. + run_process_test.setCwd(b.path(".")); + run_process_test.has_side_effects = true; + b.step("process-test", "run the process tests: real sessions over their sockets, the tty's in a pty each (-- [--update] [filter])").dependOn(&run_process_test.step); + // The window's own, run in full when asked (test/process/window.zig): + // the monkey over every Motion, and the frames against + // this machine's goldens (PARDES_GUI_GOLDEN=update rewrites them). + const monkey_gui_step = b.step("monkey-gui", "random input to the hidden window across the effect settings (-Dplatform=gui; PARDES_GUI_MONKEY_SEED, _STEPS)"); + const gui_golden_step = b.step("gui-golden", "the hidden window's scenes against test/gui-goldens.txt, this machine's (-Dplatform=gui; PARDES_GUI_GOLDEN=update rewrites)"); + if (opts.gui) { + const run_monkey_gui = b.addRunArtifact(process_test); + run_monkey_gui.addArtifactArg(opts.exe); + for (opts.addons) |a| run_monkey_gui.addPrefixedFileArg("--addon=", a.getEmittedBin()); + run_monkey_gui.addArgs(&.{ "--backend=gui", "window: a monkey" }); + run_monkey_gui.setEnvironmentVariable("PARDES_GUI_MONKEY", "all"); + run_monkey_gui.has_side_effects = true; + monkey_gui_step.dependOn(&run_monkey_gui.step); + const run_gui_golden = b.addRunArtifact(process_test); + run_gui_golden.addArtifactArg(opts.exe); + for (opts.addons) |a| run_gui_golden.addPrefixedFileArg("--addon=", a.getEmittedBin()); + run_gui_golden.addArgs(&.{ "--backend=gui", "window: its scenes" }); + run_gui_golden.setEnvironmentVariable("PARDES_GUI_GOLDEN", b.graph.environ_map.get("PARDES_GUI_GOLDEN") orelse "check"); + run_gui_golden.setCwd(b.path(".")); + run_gui_golden.has_side_effects = true; + gui_golden_step.dependOn(&run_gui_golden.step); + } else { + monkey_gui_step.dependOn(&b.addFail("monkey-gui needs -Dplatform=gui").step); + gui_golden_step.dependOn(&b.addFail("gui-golden needs -Dplatform=gui").step); + } +} -- cgit v1.3