const std = @import("std"); 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, cloud9: *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); const ninep_options = b.addOptions(); ninep_options.addOption(bool, "quic", false); 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.addOptions("9p_options", ninep_options); ninep_client.addImport("cloud9", opts.cloud9); snap.root_module.addImport("9p_io", ninep_client); 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, }), }); const run_snap = b.addRunArtifact(snap); run_snap.addArtifactArg(opts.exe); run_snap.addPrefixedFileArg("--lspmock=", lspmock.getEmittedBin()); 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; const snap_step = b.step("snap", "run the snapshot parity suite (-- --update regenerates goldens)"); snap_step.dependOn(&run_snap.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); } pub fn addWeb(b: *std.Build) void { const driver_test = b.addSystemCommand(&.{ "node", "--test", "test/web_driver_test.mjs" }); driver_test.setCwd(b.path(".")); driver_test.has_side_effects = true; b.step("web-driver-test", "test browser driver deadlines and cleanup").dependOn(&driver_test.step); const build_web_snap = b.addSystemCommand(&.{ b.graph.zig_exe, "build", "web", "-Dplatform=web", "-Dtarget=wasm32-freestanding", "-Dtree-sitter=zig", "-Ddump=test/web-snapshots/touch.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/touch.mjs", }); run_web_snap.setCwd(b.path(".")); run_web_snap.step.dependOn(&build_web_snap.step); run_web_snap.step.dependOn(&driver_test.step); run_web_snap.has_side_effects = true; if (b.args) |args| run_web_snap.addArgs(args); b.step("web-snap", "run browser highlighting, touch, Look, resize and scroll checks").dependOn(&run_web_snap.step); b.step("web-e2e", "run the Chrome-driven DOM end-to-end suite").dependOn(&run_web_snap.step); }