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=`, 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. 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)"); 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); } else { monkey_gui_step.dependOn(&b.addFail("monkey-gui needs -Dplatform=gui").step); } }