summaryrefslogtreecommitdiff
path: root/test/fs_namespace.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/fs_namespace.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/fs_namespace.zig')
-rw-r--r--test/fs_namespace.zig44
1 files changed, 23 insertions, 21 deletions
diff --git a/test/fs_namespace.zig b/test/fs_namespace.zig
index 30c656ca..c68a438b 100644
--- a/test/fs_namespace.zig
+++ b/test/fs_namespace.zig
@@ -100,13 +100,14 @@ test "transactional restore preserves host capabilities and advances pane identi
try std.testing.expectEqual(@as(u32, 73), restored.pipe.seq);
try std.testing.expectEqual(p.cell_pixels, restored.cell_pixels);
try std.testing.expect(restored.native_images);
- try std.testing.expect(restored.panes[0].?.serial > p.next_serial);
- try std.testing.expect(restored.paneBySerial(pane.serial) == null);
+ // The dump's pane, its serial too; a new one is past the old session's.
+ try std.testing.expectEqual(pane.serial, restored.panes[0].?.serial);
+ try std.testing.expect(restored.next_serial >= p.next_serial);
try std.testing.expectEqual(p.screen_w, restored.screen_w);
try std.testing.expectEqual(p.screen_h, restored.screen_h);
try std.testing.expect(p.panes[0] == pane);
try std.testing.expectEqualStrings("before\n", pane.file.?.content);
- try std.testing.expectError(error.BadDumpMagic, pardes.dump.restore(
+ try std.testing.expectError(error.BadDump, pardes.dump.restore(
p,
".{ .magic = \"wrong\", .screen = .{.cols = 80, .rows = 24} }",
"test",
@@ -201,23 +202,24 @@ test "explicit OS file opens and restores keep their names and request watches"
const pane = try pardes.panes.File.open(p, opened, path, 0);
try std.testing.expectEqualStrings(path, pane.file.?.path);
try std.testing.expectEqualStrings("const disk = 1;\n", pane.file.?.content);
- const restored = p.freeSlot().?;
- const copy = try pardes.panes.File.restore(p, restored, .{
- .kind = .file,
- .tag = path,
- .body = "",
- // Unsaved text: kept (a clean pane's is read from disk).
- .file = .{ .path = path, .content = "const unsaved = 2;\n", .dirty = true },
- });
- try std.testing.expectEqualStrings(path, copy.file.?.path);
- try std.testing.expectEqualStrings("const unsaved = 2;\n", copy.file.?.content);
var watched_open = false;
- var watched_restore = false;
while (p.nextEffect()) |effect| if (effect == .watch and effect.watch.on) {
if (effect.watch.pane == opened) watched_open = true;
- if (effect.watch.pane == restored) watched_restore = true;
};
- try std.testing.expect(watched_open and watched_restore);
+ try std.testing.expect(watched_open);
+ // Unsaved, dumped and loaded: its text kept, its file watched again.
+ _ = pardes.ctlfs.pane.spliceBody(p, pane, 0, 0, "// unsaved\n").?;
+ try pardes.dump.dumpState(p);
+ const restored = try pardes.dump.initFromDump(gpa, .{ .tty_only = true }, p.dump_out.?);
+ defer restored.deinit();
+ const copy = restored.panes[opened].?;
+ try std.testing.expectEqualStrings(path, copy.file.?.path);
+ try std.testing.expectEqualStrings("// unsaved\nconst disk = 1;\n", copy.file.?.content);
+ var watched_restore = false;
+ while (restored.nextEffect()) |effect| if (effect == .watch and effect.watch.on) {
+ if (effect.watch.pane == opened) watched_restore = true;
+ };
+ try std.testing.expect(watched_restore);
}
test "virtual file opens do not request OS watches" {
@@ -308,9 +310,9 @@ test "images decode through explicit filesystem mounts, and a dump reads one on
const state = pane.image.?;
try std.testing.expectEqual(@as(usize, 1), state.iw);
try std.testing.expectEqual(@as(usize, 1), state.ih);
- // On disk, the picture is no part of the dump: Restore reads it there.
- const saved = try pardes.panes.Image.dumpPane(p, arena.allocator(), pane, "", "", 0, path, state.raw);
- try std.testing.expectEqualStrings("", saved.image.?.bytes_b64);
- const restored = try pardes.panes.Image.restore(p, p.freeSlot().?, saved);
- try std.testing.expectEqualStrings(bytes, restored.image.?.raw);
+ // The picture's bytes are in the dump: it comes back as it was shown.
+ try pardes.dump.dumpState(p);
+ const restored = try pardes.dump.initFromDump(gpa, .{ .tty_only = true }, p.dump_out.?);
+ defer restored.deinit();
+ try std.testing.expectEqualStrings(bytes, restored.panes[0].?.image.?.raw);
}