summaryrefslogtreecommitdiff
path: root/test/snapshot.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/snapshot.zig')
-rw-r--r--test/snapshot.zig17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/snapshot.zig b/test/snapshot.zig
index 7f8c4f21..5dc2e6e9 100644
--- a/test/snapshot.zig
+++ b/test/snapshot.zig
@@ -79,6 +79,9 @@ const SNAP_BASE = "/tmp/pardes-snap";
var trace_stable = false;
/// set for the serial re-run pass; children widen their probes (see beCareful)
var careful = false;
+/// abs path of the deterministic mock language server the build handed over
+/// (--lspmock=); null leaves the protocol client fully disabled for the run
+var lspmock_bin: ?[:0]const u8 = null;
const gpa = std.heap.page_allocator;
pub fn main(init: std.process.Init) !void {
@@ -102,11 +105,14 @@ pub fn main(init: std.process.Init) !void {
const cpus = std.Thread.getCpuCount() catch 4;
var jobs: usize = cpus + cpus / 4;
var script_count: usize = 0;
+ var lspmock: ?[]const u8 = null;
for (args[1..]) |a| {
if (std.mem.eql(u8, a, "--update")) {
update = true;
} else if (std.mem.eql(u8, a, "--trace-stable")) {
trace_stable = true;
+ } else if (std.mem.startsWith(u8, a, "--lspmock=")) {
+ lspmock = try absPath(arena, orig_cwd, a["--lspmock=".len..]);
} else if (std.mem.startsWith(u8, a, "--jobs=")) {
jobs = @max(1, try std.fmt.parseInt(usize, a["--jobs=".len..], 10));
} else if (exe == null) {
@@ -129,6 +135,7 @@ pub fn main(init: std.process.Init) !void {
for (args[1..]) |a| {
if (std.mem.eql(u8, a, "--update") or
std.mem.eql(u8, a, "--trace-stable") or
+ std.mem.startsWith(u8, a, "--lspmock=") or
std.mem.startsWith(u8, a, "--jobs=")) continue;
if (!saw_exe) {
saw_exe = true;
@@ -139,6 +146,7 @@ pub fn main(init: std.process.Init) !void {
}
if (exe == null) fatal("usage: pardes-snap <exe> [scripts...] [--update] [--jobs=N]", .{});
const exe_z = try arena.dupeZ(u8, exe.?);
+ lspmock_bin = if (lspmock) |p| try arena.dupeZ(u8, p) else null;
if (scripts.len == 0) {
scripts = try listSnaps(arena, try absPath(arena, orig_cwd, "test/snapshots"));
@@ -389,6 +397,15 @@ fn runScript(arena: std.mem.Allocator, exe_z: [:0]const u8, script_path: []const
// views' durations (lsp_zls.zig hideTime) and the transient message row's
// time of day (message.zig stamp)
_ = setenv("PARDES_NOTIME", "1", 1);
+ // The protocol client must be HERMETIC under the harness: `.rs` files
+ // speak to the deterministic mock when the build handed one over, and
+ // every other spec is disabled outright — a script that opened a stray
+ // `.c` or `.ts` file must never spawn whatever clangd this machine has.
+ _ = setenv("PARDES_LSP_RS", lspmock_bin orelse "", 1);
+ _ = setenv("PARDES_LSP_C", "", 1);
+ _ = setenv("PARDES_LSP_GO", "", 1);
+ _ = setenv("PARDES_LSP_TS", "", 1);
+ _ = setenv("PARDES_LSP_PY", "", 1);
// Pin the dump path: live runs use a timestamped file under the user data
// dir (dump.outPath), which would make the dump/load/restore goldens
// nondeterministic. Per-SCRIPT, not one shared /tmp/pardes-dump.zon: four