summaryrefslogtreecommitdiff
path: root/test/behaviour/root_ctl.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-09 23:15:39 -0300
committerGabriel Schneider <[email protected]>2026-11-09 23:15:53 -0300
commit0b4cfd4b416d03ef64ccd908dfee810c6a498569 (patch)
tree83da4851e30b4dd0e788b66f0024d5b55eaee421 /test/behaviour/root_ctl.zig
parent7e6fc8c9f62bc3dc08e24856cc647fa0adefb32c (diff)
downloadpardes-0b4cfd4b416d03ef64ccd908dfee810c6a498569.tar.gz
pardes-0b4cfd4b416d03ef64ccd908dfee810c6a498569.zip
a session's end leaves a slim dump and History lists them, the tags gain Follow, History and the window's Fonts: every way out (Exit, the last pane's Del, the host's quit) runs Pardes.endSession, which puts a dump of the session in the state file under the usual label before quitting, slim by the dump's own means (dumpJoin's slim_terminals, and Store's slim-file swap now a Slim struct: no undo, a clean file's text read from its file again by revivePane, a terminal a size for a new shell), none for a session of shells alone; the dump's image carries the panes' names, which /dumps rows end with; the History builtin (SPC f h) lists the state file's dumps in a +History pane and a look at a row is a Restore of its label; the default tags: Follow after Collapse on text panes, History before Debug on the workspace row, Fonts after Themes in a window's view alone (tagline.topbarDefault picks the row per view; both rows are known defaults to the docs and tutor tests); the tty goldens re-recorded (the new words; a narrow pane's tag wraps to a second row, so its body rows shift), builtins JSON regenerated
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/behaviour/root_ctl.zig')
-rw-r--r--test/behaviour/root_ctl.zig38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/behaviour/root_ctl.zig b/test/behaviour/root_ctl.zig
index c1dad7e1..1fa67206 100644
--- a/test/behaviour/root_ctl.zig
+++ b/test/behaviour/root_ctl.zig
@@ -263,3 +263,41 @@ test "root-ctl: a Dump killed in the middle leaves the one before it whole, and
try s.write("/ctl", "Dump\n");
try std.testing.expectEqual(@as(usize, 2), (try labels(&s)).len);
}
+
+test "root-ctl: a session's end leaves a slim dump the next session's History lists with the panes' names, a look at its row restores the file pane, and a session of shells alone leaves none" {
+ var tmp = std.testing.tmpDir(.{});
+ defer tmp.cleanup();
+ var dir_buf: [std.fs.max_path_bytes]u8 = undefined;
+ const dir = dir_buf[0..try tmp.dir.realPath(std.testing.io, &dir_buf)];
+ try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "a.txt", .data = "kept on disk\n" });
+ // A session of a shell alone: nothing to come back to.
+ {
+ var s = try Session.initShared(std.testing.allocator, dir);
+ defer s.deinit();
+ try s.write("/ctl", "Exit\n");
+ }
+ {
+ var s = try Session.initShared(std.testing.allocator, dir);
+ defer s.deinit();
+ try std.testing.expectEqualStrings("", try s.read("/dumps"));
+ _ = try s.lookFile(s.at("{s}/a.txt", .{dir}));
+ try s.write("/ctl", "Exit\n");
+ }
+ var s = try Session.initShared(std.testing.allocator, dir);
+ defer s.deinit();
+ // One dump, its row ending with the file's name; slim: a clean file's
+ // text is not in it (the session's own maps are a few hundred KB, so
+ // the size says nothing: Restore reads the file again below).
+ const listed = try labels(&s);
+ try std.testing.expectEqual(@as(usize, 1), listed.len);
+ try std.testing.expect(std.mem.endsWith(u8, std.mem.trimEnd(u8, try s.read("/dumps"), "\n"), s.at(" {s}/a.txt", .{dir})));
+ try s.write("/exec", "History\n");
+ const hist = std.mem.trimEnd(u8, try s.read("/exec"), "\n");
+ const body = try s.read(s.at("/pane/{s}/body", .{hist}));
+ try std.testing.expect(std.mem.startsWith(u8, body, listed[0]));
+ try std.testing.expect(has(body, "a.txt"));
+ // A look at the row: the dump restored, the file pane back with its text.
+ try s.write(s.at("/pane/{s}/look", .{hist}), body[0..std.mem.indexOfScalar(u8, body, '\n').?]);
+ try std.testing.expect(has(try s.read("/log"), s.at("restore {s}\n", .{listed[0]})));
+ try s.expect(s.at("/pane/{d}/body", .{try s.lookFile(s.at("{s}/a.txt", .{dir}))}), "kept on disk\n");
+}