diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-27 22:34:56 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:14 -0300 |
| commit | 7ba54de4bd498c2a56ea3d0d43c88356759f7b1f (patch) | |
| tree | 2e661d1785ef6e74c158ca6b2e1aa96b763ec7bc /test | |
| parent | 52049344c1992850ea712e029eb5c4a88a7dfe19 (diff) | |
| download | pardes-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')
| -rw-r--r-- | test/fs_namespace.zig | 21 | ||||
| -rw-r--r-- | test/output.zig | 12 | ||||
| -rw-r--r-- | test/panes.zig | 10 | ||||
| -rw-r--r-- | test/pdf.zig | 6 |
4 files changed, 25 insertions, 24 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); diff --git a/test/output.zig b/test/output.zig index b4c018db..7c5f7f9b 100644 --- a/test/output.zig +++ b/test/output.zig @@ -438,9 +438,9 @@ test "Mini dump preserves its exact virtual snapshot and body writes detach colo const id = p.active; const before = p.panes[id].?.file.?; try std.testing.expect(before.mini != null); - try p.dumpState(); + try pardes.dump.dumpState(p); panes.File.setContent(p, &source.file.?, try p.gpa.dupe(u8, "changed\n")); - const restored = try Pardes.initFromDump(std.testing.allocator, .{ .tty_only = true }, p.dump_out.?); + const restored = try pardes.dump.initFromDump(std.testing.allocator, .{ .tty_only = true }, p.dump_out.?); defer restored.deinit(); const mini = restored.panes[restored.active].?; try std.testing.expectEqualStrings(before.content, mini.file.?.content); @@ -793,8 +793,8 @@ test "n/N skips formatted context and selects comment match locations" { try std.testing.expectEqualStrings(line[0..file.location_rows[row].location_end], selectedOutputText(result) orelse ""); try std.testing.expectEqual(available, p.freeSlot()); } - try p.dumpState(); - const restored = try Pardes.initFromDump(p.gpa, .{ .tty_only = true }, p.dump_out.?); + try pardes.dump.dumpState(p); + const restored = try pardes.dump.initFromDump(p.gpa, .{ .tty_only = true }, p.dump_out.?); defer restored.deinit(); pardes.look.armLookWalk(restored, id); const restored_result = restored.panes[id].?; @@ -1570,8 +1570,8 @@ test "stacked search and LSP results retain source tint navigation and dump owne const line = modal.lineSlice(file.content, matches[step.match]); try std.testing.expectEqualStrings(line[0..row.location_end], selectedOutputText(pane) orelse ""); } - try p.dumpState(); - const restored = try Pardes.initFromDump(p.gpa, .{ .tty_only = true }, p.dump_out.?); + try pardes.dump.dumpState(p); + const restored = try pardes.dump.initFromDump(p.gpa, .{ .tty_only = true }, p.dump_out.?); defer restored.deinit(); const restored_file = &restored.panes[id].?.file.?; try std.testing.expectEqualStrings(file.content, restored_file.content); diff --git a/test/panes.zig b/test/panes.zig index f99f9d56..1c861070 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -2039,7 +2039,7 @@ test "file history survives PDF fallback restoration and allocation failures" { var succeeded = false; for (0..256) |failure| { var failing = std.testing.FailingAllocator.init(std.testing.allocator, .{ .fail_index = failure }); - if (Pardes.initFromDump(failing.allocator(), .{ .tty_only = true }, saved)) |p| { + if (pardes.dump.initFromDump(failing.allocator(), .{ .tty_only = true }, saved)) |p| { defer p.deinit(); const pane = p.panes[0].?; try std.testing.expect(pane.file != null); @@ -2416,8 +2416,8 @@ const OutputTests = struct { neighbor_colored = neighbor_colored or style != 0; try std.testing.expect(neighbor_colored); - try p.dumpState(); - const restored = try Pardes.initFromDump(p.gpa, .{ .tty_only = true }, p.dump_out.?); + try pardes.dump.dumpState(p); + const restored = try pardes.dump.initFromDump(p.gpa, .{ .tty_only = true }, p.dump_out.?); defer restored.deinit(); const restored_source = restored.panes[0].?; const restored_id = pane.search_pane.?; @@ -2520,8 +2520,8 @@ const OutputTests = struct { try std.testing.expectEqual(.match, file.location_rows[next].kind); const wrapped = panes.Output.nextResult(file.content, file.location_rows, path, .{ .line = 99 }); try std.testing.expectEqual(@as(usize, 2), file.location_rows[wrapped].at.line); - try p.dumpState(); - const restored = try Pardes.initFromDump(p.gpa, .{ .tty_only = true }, p.dump_out.?); + try pardes.dump.dumpState(p); + const restored = try pardes.dump.initFromDump(p.gpa, .{ .tty_only = true }, p.dump_out.?); defer restored.deinit(); const restored_file = &restored.panes[pane.search_pane.?].?.file.?; try std.testing.expectEqualStrings(file.content, restored_file.content); diff --git a/test/pdf.zig b/test/pdf.zig index dde58df8..8e87dfb1 100644 --- a/test/pdf.zig +++ b/test/pdf.zig @@ -301,7 +301,7 @@ test "PDF dump fallback remains a byte-preserving file" { defer out.deinit(); try std.zon.stringify.serialize(state, .{ .whitespace = true }, &out.writer); - const restored = try Pardes.initFromDump(gpa, .{ .tty_only = true }, out.written()); + const restored = try pardes.dump.initFromDump(gpa, .{ .tty_only = true }, out.written()); defer restored.deinit(); const pane = restored.panes[0].?; try std.testing.expect(pane.file != null); @@ -921,8 +921,8 @@ test "MuPDF pane renders, navigates, searches, and round-trips its page" { @memcpy(pane.tag_tail[0..custom_tail.len], custom_tail); pane.tag_tail_len = custom_tail.len; pane.tag_init = true; - try p.dumpState(); - const restored = try 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.expect(hasPdf(restored.panes[0].?)); try std.testing.expectEqual(pane.pdf.?.page, restored.panes[0].?.pdf.?.page); |
