summaryrefslogtreecommitdiff
path: root/build/snap.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-07-28 13:21:42 -0300
committerGabriel Schneider <[email protected]>2026-08-01 15:02:07 -0300
commit0b5ad7a30ba9e7c6eedcb426be294bd94219310f (patch)
tree1a991acfb2a14f25ece19e13e65915dbbb48c7fc /build/snap.zig
parent95202b9b22751c86f100aae9ff1c64e535dcbd70 (diff)
downloadpardes-0b5ad7a30ba9e7c6eedcb426be294bd94219310f.tar.gz
pardes-0b5ad7a30ba9e7c6eedcb426be294bd94219310f.zip
build.zig runners and testing improvements
Diffstat (limited to 'build/snap.zig')
-rw-r--r--build/snap.zig70
1 files changed, 70 insertions, 0 deletions
diff --git a/build/snap.zig b/build/snap.zig
new file mode 100644
index 00000000..a721f483
--- /dev/null
+++ b/build/snap.zig
@@ -0,0 +1,70 @@
+//! Build-time wiring for the two snapshot suites — the `snap` step (scripted
+//! pty traces diffed against test/snapshots/*.golden) and the `web-snap` step
+//! (the same idea driven through headless Chromium). Kept out of build.zig so
+//! the test harness's plumbing is not tangled with the shell/platform build.
+//!
+//! Both steps forward `-- <args>` to their runner: `--update` regenerates
+//! goldens, `--jobs=N` / `--idle=MS` tune the tty runner's parallelism.
+
+const std = @import("std");
+
+/// TTY parity suite: pardes-snap forks the real binary in a pty per script.
+/// The runner handles its own locking and fan-out, so this is just a run step.
+pub fn addTty(b: *std.Build, opts: struct {
+ exe: *std.Build.Step.Compile,
+ target: std.Build.ResolvedTarget,
+ optimize: std.builtin.OptimizeMode,
+ ghostty_vt: ?*std.Build.Module,
+}) 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);
+ switch (opts.target.result.os.tag) {
+ .freebsd, .netbsd, .openbsd => snap.root_module.linkSystemLibrary("util", .{}),
+ else => {},
+ }
+ b.installArtifact(snap);
+ const run_snap = b.addRunArtifact(snap);
+ run_snap.addArtifactArg(opts.exe);
+ if (b.args) |args| run_snap.addArgs(args);
+ // scripts fork children and drive real ptys: never cached, never "up to date"
+ run_snap.has_side_effects = true;
+ b.step("snap", "run the snapshot parity suite (-- --update regenerates goldens)").dependOn(&run_snap.step);
+}
+
+/// Browser regression suite: make an isolated web build from the real TTY dump
+/// captured after running `git ls-files '*.zig'`, with the Zig-only tree-sitter
+/// tier. The dependency-free CDP harness then drives its .snap script through
+/// real Chromium touch events. This recursive build selects `web`, not
+/// `web-snap`, so it bottoms out after one level.
+pub fn addWeb(b: *std.Build) void {
+ const build_web_snap = b.addSystemCommand(&.{
+ b.graph.zig_exe,
+ "build",
+ "web",
+ "-Dplatform=web",
+ "-Dtarget=wasm32-emscripten",
+ "-Dtree-sitter=zig",
+ "-Ddump=test/web-snapshots/source-list.dump.zon",
+ "-p",
+ "zig-out/web-snap-test",
+ });
+ build_web_snap.setCwd(b.path("."));
+ const run_web_snap = b.addSystemCommand(&.{
+ "node",
+ "test/web_snapshot.mjs",
+ "zig-out/web-snap-test/web",
+ "test/web-snapshots/source-list.snap",
+ });
+ run_web_snap.setCwd(b.path("."));
+ run_web_snap.step.dependOn(&build_web_snap.step);
+ if (b.args) |args| run_web_snap.addArgs(args);
+ b.step("web-snap", "run browser touch/LOOK snapshots (-- --update regenerates goldens)").dependOn(&run_web_snap.step);
+}