1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
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());
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" });
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);
}
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",
"-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;
run_web_snap.addPassthruArgs();
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);
}
|