summaryrefslogtreecommitdiff
path: root/test/behaviour
diff options
context:
space:
mode:
Diffstat (limited to 'test/behaviour')
-rw-r--r--test/behaviour/mouse.zig6
-rw-r--r--test/behaviour/panes.zig4
-rw-r--r--test/behaviour/root_ctl.zig38
-rw-r--r--test/behaviour/tags.zig20
4 files changed, 52 insertions, 16 deletions
diff --git a/test/behaviour/mouse.zig b/test/behaviour/mouse.zig
index e64e3ef9..951ab493 100644
--- a/test/behaviour/mouse.zig
+++ b/test/behaviour/mouse.zig
@@ -26,8 +26,8 @@ test "mouse: a double-click selects a word, a line, a bracketed or quoted text,
try s.expect(sel, "");
}
// In the tag too: what it selected is what a yank takes.
- try s.click("Collapse Del", "Collapse D".len, 1);
- try s.click("Collapse Del", "Collapse D".len, 1);
+ try s.click("Follow Del", "Follow D".len, 1);
+ try s.click("Follow Del", "Follow D".len, 1);
try s.keys("\x1by:ggP");
try s.expect(s.at("/pane/{d}/body", .{n}), "Delcall foo_bar(a, b)\nsay \"hi there\"\n");
}
@@ -157,7 +157,7 @@ test "mouse: a click on either half of a wide character lands before it, in the
// Typed past the tag's words, a two-byte λ goes in and one backspace
// takes it out whole.
const tag = try s.read(s.at("/pane/{d}/tag", .{n}));
- try s.click("Collapse Del", "Collapse Del".len + 1, 1);
+ try s.click("Follow Del", "Follow Del".len + 1, 1);
const caret = (try s.cursor()).?;
// A clicked tag is in normal mode: `i` types at the caret.
try s.keys("iλ");
diff --git a/test/behaviour/panes.zig b/test/behaviour/panes.zig
index 12be354a..b42cab76 100644
--- a/test/behaviour/panes.zig
+++ b/test/behaviour/panes.zig
@@ -238,8 +238,8 @@ test "panes: Collapse keeps the text and folds the pane to its tag, and again re
for ([_][]const u8{
try s.read(s.at("/pane/{d}/tag", .{n})),
try s.read(s.at("/pane/{d}/tag", .{try s.newPane()})),
- try t.read(t.at("/pane/{d}/tag", .{try t.focused()})),
- }) |tag| try std.testing.expect(std.mem.endsWith(u8, tag, " Collapse Del"));
+ }) |tag| try std.testing.expect(std.mem.endsWith(u8, tag, " Collapse Follow Del"));
+ try std.testing.expect(std.mem.endsWith(u8, try t.read(t.at("/pane/{d}/tag", .{try t.focused()})), " Collapse Del"));
try s.write(s.at("/pane/{d}/ctl", .{try s.focused()}), "Del\n");
const ctl = s.at("/pane/{d}/ctl", .{n});
try s.write(ctl, "Collapse\n");
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");
+}
diff --git a/test/behaviour/tags.zig b/test/behaviour/tags.zig
index 8d04f8ad..395b63c8 100644
--- a/test/behaviour/tags.zig
+++ b/test/behaviour/tags.zig
@@ -1,5 +1,3 @@
-
-
const std = @import("std");
const Session = @import("session").Session;
@@ -41,9 +39,9 @@ test "tags: ms and md edit a tag's own text, and the text the edit made is read
defer s.deinit();
const n = try s.focused();
try s.keys(":miwms(");
- try std.testing.expectEqualStrings("/test.txt (Save) Term Collapse Del", try tag(&s, n));
+ try std.testing.expectEqualStrings("/test.txt (Save) Term Collapse Follow Del", try tag(&s, n));
try s.keys("md(");
- try std.testing.expectEqualStrings("/test.txt Save Term Collapse Del", try tag(&s, n));
+ try std.testing.expectEqualStrings("/test.txt Save Term Collapse Follow Del", try tag(&s, n));
}
test "tags: the keyboard reaches a tag's path, which it can select and yank but not edit" {
@@ -66,7 +64,7 @@ test "tags: the keyboard reaches a tag's path, which it can select and yank but
try s.expect(s.at("/pane/{d}/name", .{n}), "/test.txt\n");
// After the path, the text is the tag's own to edit.
try s.keys(":A!\x1b");
- try std.testing.expectEqualStrings("/test.txt Save Term Collapse Del!", try tag(&s, n));
+ try std.testing.expectEqualStrings("/test.txt Save Term Collapse Follow Del!", try tag(&s, n));
// What it yanked was the path.
try s.keys(":P");
try s.expect(s.at("/pane/{d}/body", .{n}), "/test.txtbody\n");
@@ -182,7 +180,7 @@ test "tags: a tag's normal mode is the body's: motions stay in the tag and inser
try s.keys(window ++ "h\n");
try std.testing.expectEqual(first, try s.focused());
try s.keys(":i\u{F018}hjklHJKL:");
- try std.testing.expectEqualStrings("/test.txt Save Term Collapse DelhjklHJKL:", try tag(&s, first));
+ try std.testing.expectEqualStrings("/test.txt Save Term Collapse Follow DelhjklHJKL:", try tag(&s, first));
try std.testing.expect(std.mem.endsWith(u8, try s.read(s.at("/pane/{d}/ctl", .{first})), " mode:normal "));
try s.expect(s.at("/pane/{d}/body", .{first}), "body\n");
try std.testing.expectEqual(first, try s.focused());
@@ -194,7 +192,7 @@ test "tags: a tag with a newline in it is as tall as its lines, and each line is
const n = try s.focused();
// Insert mode in a tag is a body's: Enter is a new line.
try s.keys(":A\nSecond");
- try std.testing.expectEqualStrings("/test.txt Save Term Collapse Del\nSecond", try tag(&s, n));
+ try std.testing.expectEqualStrings("/test.txt Save Term Collapse Follow Del\nSecond", try tag(&s, n));
const x, const y = try s.where("/test.txt");
try std.testing.expectEqual(.{ x, y + 1 }, try s.where("Second"));
// The caret is on the second line, after what was typed.
@@ -208,7 +206,7 @@ test "tags: a tag with a newline in it is as tall as its lines, and each line is
try std.testing.expectEqual(.{ x + 2, y + 1 }, (try s.cursor()).?);
// A clicked tag is in normal mode: `i` types where it was clicked.
try s.keys("iX");
- try std.testing.expectEqualStrings("/test.txt Save Term Collapse Del\nSeXcond", try tag(&s, n));
+ try std.testing.expectEqualStrings("/test.txt Save Term Collapse Follow Del\nSeXcond", try tag(&s, n));
try s.expect(s.at("/pane/{d}/body", .{n}), "body\n");
}
@@ -302,12 +300,12 @@ test "tags: a name drafted in the tag commits with Enter, cancels with two Escs,
try clickPathEnd(&s, path);
try s.keys("\x15/new name.zig");
try s.expect(name, s.at("{s}\n", .{path}));
- _ = try s.where("/new name.zig Save Term Collapse Del JumpTrail");
+ _ = try s.where("/new name.zig Save Term Collapse Follow Del JumpTrail");
try s.expect(s.at("/pane/{d}/body", .{n}), "original body\n");
// Esc keeps the draft pending; a second drops it.
try s.keys(if (commit) "\n" else "\x1b\x1b");
try s.expect(name, if (commit) "/new name.zig\n" else "/test.txt\n");
- try std.testing.expectEqualStrings(s.at("{s} Save Term Collapse Del JumpTrail", .{if (commit) "/new name.zig" else "/test.txt"}), try tag(&s, n));
+ try std.testing.expectEqualStrings(s.at("{s} Save Term Collapse Follow Del JumpTrail", .{if (commit) "/new name.zig" else "/test.txt"}), try tag(&s, n));
// The keyboard is the body's again.
try std.testing.expect((try s.cursor()).?[1] != (try s.where("Save Term"))[1]);
}
@@ -358,7 +356,7 @@ test "tags: middle clicking Save commits the drafted name before saving" {
try s.keys("\x15/renamed.txt");
try s.click("Save Term", 0, 2);
try s.expect(s.at("/pane/{d}/name", .{n}), "/renamed.txt\n");
- try std.testing.expectEqualStrings("/renamed.txt Save Term Collapse Del", try tag(&s, n));
+ try std.testing.expectEqualStrings("/renamed.txt Save Term Collapse Follow Del", try tag(&s, n));
try s.expect(s.at("/pane/{d}/body", .{n}), "untouched\n");
try std.testing.expectEqual(@as(usize, 1), s.saved);
}