diff options
Diffstat (limited to 'build/process.zig')
| -rw-r--r-- | build/process.zig | 87 |
1 files changed, 87 insertions, 0 deletions
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=<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 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); + } +} |
