summaryrefslogtreecommitdiff
path: root/test/fs_namespace.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-27 22:34:56 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:14 -0300
commit7ba54de4bd498c2a56ea3d0d43c88356759f7b1f (patch)
tree2e661d1785ef6e74c158ca6b2e1aa96b763ec7bc /test/fs_namespace.zig
parent52049344c1992850ea712e029eb5c4a88a7dfe19 (diff)
downloadpardes-7ba54de4bd498c2a56ea3d0d43c88356759f7b1f.tar.gz
pardes-7ba54de4bd498c2a56ea3d0d43c88356759f7b1f.zip
Move saving and loading a whole editor out of pardes.zig into dump.zig
Pure move, no behaviour change (acme keeps dump and load in rows.c): dumpState, restore, initFromDump and initDump go verbatim to the end of dump.zig, after the dump format they read and write. Inside dump.zig the moved code's `dump.` prefix drops, so `Pane` there is the dump record; the one editor pane it names is spelled `pardes.panes.Pane`, and its other `panes.X` references become `pardes.panes.X` because dump.zig's own tests use `panes` as a local name. The methods become free functions taking `p: *Pardes`: `p.dumpState()` becomes `dump.dumpState(p)`, `core.restore(bytes)` becomes `dump.restore(core, bytes)` and `Pardes.initFromDump(..)` becomes `dump.initFromDump(..)`, in pardes.zig, the shells, layout.zig, Terminal.zig, builtins.zig and the tests (38 receiver rewrites plus the initFromDump calls). The tag-tail restore helpers stay with the tag code. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'test/fs_namespace.zig')
-rw-r--r--test/fs_namespace.zig21
1 files changed, 11 insertions, 10 deletions
diff --git a/test/fs_namespace.zig b/test/fs_namespace.zig
index 470615c9..ffdc084c 100644
--- a/test/fs_namespace.zig
+++ b/test/fs_namespace.zig
@@ -40,8 +40,8 @@ test "mounts survive dumps without borrowing inputs or silently overriding a sav
file.file.?.revision = 3;
gpa.free(file.file.?.path);
file.file.?.path = try gpa.dupe(u8, "/n/peer/os/file.txt");
- try p.dumpState();
- const restored = try pardes.Pardes.initFromDump(gpa, .{}, p.dump_out.?);
+ try pardes.dump.dumpState(p);
+ const restored = try pardes.dump.initFromDump(gpa, .{}, p.dump_out.?);
defer restored.deinit();
try std.testing.expectEqual(@as(usize, 1), restored.fs.mounts.items.len);
try std.testing.expectEqualStrings("peer", restored.fs.mounts.items[0].name);
@@ -50,13 +50,13 @@ test "mounts survive dumps without borrowing inputs or silently overriding a sav
try std.testing.expectEqualStrings("saved remote body\n", restored.panes[0].?.file.?.content);
try std.testing.expect(restored.panes[0].?.file.?.revision != restored.panes[0].?.file.?.saved_revision);
try std.testing.expectError(error.MountInUse, filesystem.unmount(restored, "peer"));
- const same = try pardes.Pardes.initFromDump(gpa, .{ .mounts = &.{.{ .name = "peer", .dial = "/tmp/peer.sock" }} }, p.dump_out.?);
+ const same = try pardes.dump.initFromDump(gpa, .{ .mounts = &.{.{ .name = "peer", .dial = "/tmp/peer.sock" }} }, p.dump_out.?);
defer same.deinit();
try std.testing.expectEqual(@as(usize, 1), same.fs.mounts.items.len);
- try std.testing.expectError(error.MountConflict, pardes.Pardes.initFromDump(gpa, .{
+ try std.testing.expectError(error.MountConflict, pardes.dump.initFromDump(gpa, .{
.mounts = &.{.{ .name = "peer", .dial = "/tmp/different.sock" }},
}, p.dump_out.?));
- const added = try pardes.Pardes.initFromDump(gpa, .{ .mounts = &.{.{ .name = "other", .dial = "/tmp/other.sock" }} }, p.dump_out.?);
+ const added = try pardes.dump.initFromDump(gpa, .{ .mounts = &.{.{ .name = "other", .dial = "/tmp/other.sock" }} }, p.dump_out.?);
defer added.deinit();
try std.testing.expectEqual(@as(usize, 2), added.fs.mounts.items.len);
}
@@ -69,8 +69,8 @@ test "removed startup mounts are not resurrected by dump restore" {
});
defer p.deinit();
try filesystem.unmount(p, "peer");
- try p.dumpState();
- const restored = try pardes.Pardes.initFromDump(gpa, p.opts, p.dump_out.?);
+ try pardes.dump.dumpState(p);
+ const restored = try pardes.dump.initFromDump(gpa, p.opts, p.dump_out.?);
defer restored.deinit();
try std.testing.expectEqual(@as(usize, 0), restored.fs.mounts.items.len);
}
@@ -87,8 +87,8 @@ test "transactional restore preserves host capabilities and advances pane identi
p.fs.socket_path = "/tmp/session.sock";
p.fs.tcp_address = .{ .ip4 = .loopback(5640) };
p.fs.quic_address = .{ .ip6 = .loopback(5641) };
- try p.dumpState();
- const restored = try p.restore(p.dump_out.?);
+ try pardes.dump.dumpState(p);
+ const restored = try pardes.dump.restore(p, p.dump_out.?);
defer restored.deinit();
try std.testing.expectEqual(@as(u32, 41), restored.lsp_seq);
try std.testing.expectEqual(@as(u32, 73), restored.pipe_seq);
@@ -100,7 +100,8 @@ test "transactional restore preserves host capabilities and advances pane identi
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, p.restore(
+ try std.testing.expectError(error.BadDumpMagic, pardes.dump.restore(
+ p,
".{ .magic = \"wrong\", .screen = .{.cols = 80, .rows = 24} }",
));
try std.testing.expect(p.panes[0] == pane);