summaryrefslogtreecommitdiff
path: root/test/behaviour/root_ctl.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/behaviour/root_ctl.zig')
-rw-r--r--test/behaviour/root_ctl.zig56
1 files changed, 56 insertions, 0 deletions
diff --git a/test/behaviour/root_ctl.zig b/test/behaviour/root_ctl.zig
index 90838d90..12f2b56a 100644
--- a/test/behaviour/root_ctl.zig
+++ b/test/behaviour/root_ctl.zig
@@ -85,3 +85,59 @@ test "root-ctl: the root ctl reads the settings as a write takes them, and takes
try std.testing.expect(std.mem.startsWith(u8, s.said, "Mount x: /tmp/pardes-no-such-sock-zz: no such socket"));
try std.testing.expect(has(try s.read("/ctl"), "Verbose on\n"));
}
+
+test "root-ctl: Kill with a name and nothing running says so and does not fail, as bare Kill does" {
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ try s.write("/ctl", "Kill zzz\n");
+ try std.testing.expect(has(try s.read("/log"), "Kill: nothing running"));
+}
+
+test "root-ctl: a bad Tab width and a bad Incl directory are refused invalid, changing nothing" {
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ const before = try s.read("/ctl");
+ // Bare, Incl lists its directories.
+ try s.write("/ctl", "Incl\n");
+ const listed = try lastIncl(&s);
+ for ([_][]const u8{ "Tab 0\n", "Tab 17\n", "Tab x\n" }) |line| {
+ try std.testing.expectEqual(@as(u16, 22), try s.refused("/ctl", line));
+ // Run from a pane, as a tag click runs it: said invalid too.
+ try std.testing.expectEqual(@as(u16, 22), try s.refused(s.at("/pane/{d}/exec", .{try s.focused()}), line));
+ try std.testing.expect(has(s.said, "invalid tab width"));
+ }
+ try s.expect("/ctl", before);
+ try std.testing.expectEqual(@as(u16, 22), try s.refused("/ctl", "Incl rel/dir\n"));
+ try std.testing.expectEqual(@as(u16, 22), try s.refused("/ctl", "Incl - /usr/include\n"));
+ try std.testing.expectEqual(@as(u16, 2), try s.refused("/ctl", "Incl /tmp/pardes-surely-no-such-dir\n"));
+ // The same list again: none taken.
+ try s.write("/ctl", "Incl\n");
+ try std.testing.expectEqual(@as(usize, 2), std.mem.count(u8, try s.read("/log"), listed));
+ // Bare Tab on the root ctl says the width, as from a pane.
+ try s.write("/ctl", "Tab\n");
+}
+
+/// The log's one `msg - Incl:` record, whole.
+fn lastIncl(s: *Session) ![]const u8 {
+ const log = try s.read("/log");
+ const at = std.mem.indexOf(u8, log, "\nmsg - Incl:") orelse return error.NoIncl;
+ return log[at .. std.mem.indexOfScalarPos(u8, log, at + 1, '\n').? + 1];
+}
+
+test "root-ctl: Joincol with no column to the right and Theme with no such theme say so; a theme's name is any case" {
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ try std.testing.expect(try s.refused("/ctl", "Joincol\n") != 0);
+ try std.testing.expect(std.mem.startsWith(u8, s.said, "Joincol: no column to the right"));
+ try std.testing.expectEqual(@as(u16, 22), try s.refused("/ctl", "Theme drak\n"));
+ try std.testing.expect(std.mem.startsWith(u8, s.said, "bad value in control message; like it: "));
+ try std.testing.expect(has(s.said, ": dr"));
+ try std.testing.expect(std.mem.endsWith(u8, s.said, "\"drak\""));
+ // Within the 128 bytes an Rerror carries, the quoted line kept.
+ try std.testing.expect(s.said.len <= 128);
+ // A click on the word says it in the log.
+ _ = try s.refused(s.at("/pane/{d}/exec", .{try s.focused()}), "Theme drak\n");
+ try std.testing.expect(has(try s.read("/log"), "no theme \"drak\""));
+ try s.write("/ctl", "Theme DRACULA\n");
+ try std.testing.expect(has(try s.read("/ctl"), "\nTheme dracula\n"));
+}