summaryrefslogtreecommitdiff
path: root/test/snapshot.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-29 17:01:35 -0300
committerGabriel Schneider <[email protected]>2026-10-29 21:13:33 -0300
commit70de5ec5ff3dad01afcc45244ad5e5a481486da6 (patch)
treecd4b723dcc2cfd94c4ba2361c134927b0e2df60b /test/snapshot.zig
parent349790339897466f323ff28748916aa48aa344f7 (diff)
downloadpardes-70de5ec5ff3dad01afcc45244ad5e5a481486da6.tar.gz
pardes-70de5ec5ff3dad01afcc45244ad5e5a481486da6.zip
dump: one walker dump of the whole session, by name across builds, for Restore, -l, Handover and the store; dump.zig's hand-written schema gone
A dump is walk.zig's walk of the core with a table of every type it reaches (fields, enum and union names, number widths), read back by name; terminals are ghostty's snapshot (screens, history, kitty images); a failed load frees what it made. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'test/snapshot.zig')
-rw-r--r--test/snapshot.zig9
1 files changed, 8 insertions, 1 deletions
diff --git a/test/snapshot.zig b/test/snapshot.zig
index 8a0583e3..030733d0 100644
--- a/test/snapshot.zig
+++ b/test/snapshot.zig
@@ -94,6 +94,10 @@ var record_dir: ?[]const u8 = null;
/// --tape=DIR: each session records its tape there (PARDES_RECORD, src/tape.zig)
/// and the script fails unless every tape replays without diverging.
var tape_dir: ?[]const u8 = null;
+/// --dump (with --tape): each replay also loads the session's dump at its
+/// end, which must be the same session and dump to the same bytes
+/// (PARDES_REPLAY_DUMP, src/tape.zig).
+var dump_check = false;
const gpa = std.heap.page_allocator;
pub fn main(init: std.process.Init) !void {
@@ -133,6 +137,8 @@ pub fn main(init: std.process.Init) !void {
record_dir = try absPath(arena, orig_cwd, a["--record=".len..]);
} else if (std.mem.startsWith(u8, a, "--tape=")) {
tape_dir = try absPath(arena, orig_cwd, a["--tape=".len..]);
+ } else if (std.mem.eql(u8, a, "--dump")) {
+ dump_check = true;
} else if (std.mem.startsWith(u8, a, "--jobs=")) {
jobs = @max(1, try std.fmt.parseInt(usize, a["--jobs=".len..], 10));
} else if (exe == null) {
@@ -159,6 +165,7 @@ pub fn main(init: std.process.Init) !void {
std.mem.startsWith(u8, a, "--lspmock=") or
std.mem.startsWith(u8, a, "--record=") or
std.mem.startsWith(u8, a, "--tape=") or
+ std.mem.eql(u8, a, "--dump") or
std.mem.startsWith(u8, a, "--jobs=")) continue;
if (!saw_exe) {
saw_exe = true;
@@ -527,7 +534,7 @@ fn replayTapes(arena: std.mem.Allocator, exe_z: [:0]const u8, stem: []const u8)
const pid = entry.name[stem.len..][0 .. entry.name.len - stem.len - ".tape".len];
if (pid.len < 2 or pid[0] != '-' or std.mem.indexOfNone(u8, pid[1..], "0123456789") != null) continue;
tapes += 1;
- const cmd = std.fmt.allocPrintSentinel(arena, "PARDES_RECORD= PARDES_REPLAY='{s}/{s}' timeout 300 '{s}' > '{s}/{s}.replay' 2>&1", .{ dir, entry.name, exe_z, dir, entry.name }, 0) catch return "out of memory";
+ const cmd = std.fmt.allocPrintSentinel(arena, "PARDES_RECORD= PARDES_REPLAY='{s}/{s}' {s}timeout 300 '{s}' > '{s}/{s}.replay' 2>&1", .{ dir, entry.name, if (dump_check) "PARDES_REPLAY_DUMP=1 " else "", exe_z, dir, entry.name }, 0) catch return "out of memory";
if (system(cmd) != 0) {
const why_path = std.fmt.allocPrint(arena, "{s}/{s}.replay", .{ dir, entry.name }) catch return "out of memory";
return readFileAlloc(arena, why_path) catch "the replay failed and said nothing";