diff options
Diffstat (limited to 'build/snap.zig')
| -rw-r--r-- | build/snap.zig | 168 |
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); -} |
