summaryrefslogtreecommitdiff
path: root/build/snap.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-08 23:49:04 -0300
committerGabriel Schneider <[email protected]>2026-11-09 01:28:28 -0300
commit174e031985db910b4907ba324d6fd12c67898a5a (patch)
tree5bcb0dbc1dbab457fcf4a4b95572a1631bb3ade1 /build/snap.zig
parent21277ffc6b08f458eb9a1210a3818e40b14293d2 (diff)
downloadpardes-174e031985db910b4907ba324d6fd12c67898a5a.tar.gz
pardes-174e031985db910b4907ba324d6fd12c67898a5a.zip
tests: monkey and replay are modes of the T1 runner and snapshot.zig goes: behaviour-test runs test/monkey9p.zig bare (its smoke), `-- --monkey <seeds>` 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 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'build/snap.zig')
-rw-r--r--build/snap.zig168
1 files changed, 0 insertions, 168 deletions
diff --git a/build/snap.zig b/build/snap.zig
deleted file mode 100644
index e7f4069c..00000000
--- a/build/snap.zig
+++ /dev/null
@@ -1,168 +0,0 @@
-const std = @import("std");
-
-pub fn addTty(b: *std.Build, opts: struct {
- exe: *std.Build.Step.Compile,
- /// The addons the build made (image, pdf), which every session loads:
- /// each `--addon=<lib>`, 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 snap = b.addExecutable(.{
- .name = "pardes-snap",
- .root_module = b.createModule(.{
- .target = opts.target,
- .optimize = opts.optimize,
- .root_source_file = b.path("test/snapshot.zig"),
- .link_libc = true,
- }),
- });
- if (opts.ghostty_vt) |vt| snap.root_module.addImport("ghostty-vt", vt);
- 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);
- snap.root_module.addImport("9p_io", ninep_client);
- snap.root_module.addImport("cloud9", opts.cloud9);
- switch (opts.target.result.os.tag) {
- .freebsd, .netbsd, .openbsd => snap.root_module.linkSystemLibrary("util", .{}),
- else => {},
- }
- 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,
- }),
- });
- // The process tests (test/process_test.zig): real sessions over their
- // sockets, on the runner the snap scripts share (test/process.zig).
- 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);
- }
- const run_snap = b.addRunArtifact(snap);
- run_snap.addArtifactArg(opts.exe);
- run_snap.addPrefixedFileArg("--lspmock=", lspmock.getEmittedBin());
- for (opts.addons) |a| run_snap.addPrefixedFileArg("--addon=", a.getEmittedBin());
- run_snap.addPassthruArgs();
- // scripts fork children and drive real ptys: never cached, never "up to date"
- run_snap.has_side_effects = true;
- const snap_step = b.step("snap", "run the snapshot parity suite (-- --update regenerates goldens)");
- snap_step.dependOn(&run_snap.step);
- // Random scripts through pardes-snap, hunting panics (test/monkey.zig):
- // not a gate, it is slow and random over seeds; a seed replays.
- const monkey = b.addExecutable(.{
- .name = "pardes-monkey",
- .root_module = b.createModule(.{
- .target = opts.target,
- .optimize = opts.optimize,
- .root_source_file = b.path("test/monkey.zig"),
- .link_libc = true,
- }),
- });
- const run_monkey = b.addRunArtifact(monkey);
- run_monkey.addArtifactArg(snap);
- run_monkey.addArtifactArg(opts.exe);
- run_monkey.addPassthruArgs();
- run_monkey.has_side_effects = true;
- b.step("monkey", "random snapshot scripts hunting panics (-- <seeds> [steps] [--from=N] [--out=DIR])").dependOn(&run_monkey.step);
- // The replay-divergence gate (src/tape.zig, docs/next-daemon.md): every
- // snapshot script and `replay-seeds` monkey seeds with each session's
- // tape recorded, each replayed into two replicas at different
- // addresses and one that never draws, every digest checked; and at each
- // session's end its dump loaded, which must be that session, digest for
- // digest, and dump again to the same bytes (phase 2).
- const tapes = ".zig-cache/tapes";
- const run_replay = b.addRunArtifact(snap);
- run_replay.addArtifactArg(opts.exe);
- run_replay.addPrefixedFileArg("--lspmock=", lspmock.getEmittedBin());
- run_replay.addArgs(&.{ "--tape=" ++ tapes, "--dump" });
- // Each script's tape replayed by another build too: a window's build
- // replaying a terminal's sessions, as its replica of one does.
- if (b.option([]const u8, "replay-with", "another build of pardes `zig build replay` replays every script's tape with too (a pardes-gui, say)")) |other|
- run_replay.addArg(b.fmt("--replay-with={s}", .{other}));
- run_replay.setCwd(b.path("."));
- run_replay.has_side_effects = true;
- const seeds = b.option(u32, "replay-seeds", "monkey seeds `zig build replay` records and replays (default 20)") orelse 20;
- const run_monkey_replay = b.addRunArtifact(monkey);
- run_monkey_replay.addArtifactArg(snap);
- run_monkey_replay.addArtifactArg(opts.exe);
- run_monkey_replay.addArgs(&.{ b.fmt("{d}", .{seeds}), "70", "--tape=" ++ tapes ++ "/monkey", "--dump", "--out=" ++ tapes ++ "/monkey" });
- run_monkey_replay.setCwd(b.path("."));
- run_monkey_replay.has_side_effects = true;
- // One pardes-snap run at a time (its lock): the scripts, then the seeds.
- run_monkey_replay.step.dependOn(&run_replay.step);
- // The same seeds with three terminals on the session, each a view of
- // it, typed into in turn (views.zig).
- const run_views_replay = b.addRunArtifact(monkey);
- run_views_replay.addArtifactArg(snap);
- run_views_replay.addArtifactArg(opts.exe);
- run_views_replay.addArgs(&.{ b.fmt("{d}", .{seeds}), "70", "--views=3", "--tape=" ++ tapes ++ "/monkey-views", "--dump", "--out=" ++ tapes ++ "/monkey-views" });
- run_views_replay.setCwd(b.path("."));
- run_views_replay.has_side_effects = true;
- run_views_replay.step.dependOn(&run_monkey_replay.step);
- b.step("replay", "record every snapshot script's and -Dreplay-seeds monkey seeds' tapes (one terminal and three) and require each to replay without diverging, and each session's dump to load to its digest").dependOn(&run_views_replay.step);
- const monkey_tests = b.addTest(.{ .root_module = monkey.root_module });
- b.step("monkey-test", "test the monkey's generator and panic detector").dependOn(&b.addRunArtifact(monkey_tests).step);
- const run_driver_test = b.addRunArtifact(snap);
- run_driver_test.addArg("--self-test");
- run_driver_test.has_side_effects = true;
- b.step("snap-driver-test", "test snapshot retry evidence and failure reporting").dependOn(&run_driver_test.step);
-}