summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-03 17:25:14 -0300
committerGabriel Schneider <[email protected]>2026-11-03 17:25:22 -0300
commit289d0f1e5d46bea014dbcfe671d84ac09bebe247 (patch)
tree2e1f639b7bb4c455ffecf30c42be1a3f4b232f87 /test
parent5e778c87a33688c0079c916023d9c337dc944a69 (diff)
downloadpardes-289d0f1e5d46bea014dbcfe671d84ac09bebe247.tar.gz
pardes-289d0f1e5d46bea014dbcfe671d84ac09bebe247.zip
test: three more of src/ninep/ctl.zig's tests through the 9P tree alone (test/behaviour/look_and_exec, columns_and_tags): look and exec reading back what the last command touched (a Tty made through a pane's ctl, a ctl write that makes nothing, a closed pane never a look's answer), a # line running as nothing at every exec and ctl (/index and /log unchanged), a refused Delcol changing no pane, layout or focus; each checked to fail against a break: a look answering a closed pane, a long # line run, a refused Delcol opening its +Unsaved
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test')
-rw-r--r--test/behaviour/columns_and_tags.zig23
-rw-r--r--test/behaviour/look_and_exec.zig36
2 files changed, 59 insertions, 0 deletions
diff --git a/test/behaviour/columns_and_tags.zig b/test/behaviour/columns_and_tags.zig
index 71cff4b2..fa3baf48 100644
--- a/test/behaviour/columns_and_tags.zig
+++ b/test/behaviour/columns_and_tags.zig
@@ -42,3 +42,26 @@ test "columns-and-tags: a tag write refuses NUL and the other control characters
try std.testing.expectEqual(@as(u16, 22), try s.refused(tag, " \x7f"));
}
}
+
+test "columns-and-tags: a refused Delcol changes nothing: no pane, no focus" {
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ try s.write("/ctl", "Newcol\n");
+ const made = try s.newPane();
+ try s.write(s.at("/pane/{d}/name", .{made}), "/tmp/pardes-delcol-refused.txt\n");
+ try s.write(s.at("/pane/{d}/body", .{made}), "edit\n");
+ // Its column, /index's last field.
+ const col = col: {
+ var rows = std.mem.tokenizeScalar(u8, try s.read("/index"), '\n');
+ while (rows.next()) |row| if (std.mem.startsWith(u8, row, s.at("{d} ", .{made}))) break :col row[std.mem.lastIndexOfScalar(u8, row, ' ').? + 1 ..];
+ return error.NotListed;
+ };
+ const index = try s.read("/index");
+ const layout = try s.read("/layout");
+ const focus = try s.read("/focus");
+ try std.testing.expect(try s.refused(s.at("/col/{s}/ctl", .{col}), "Delcol\n") != 0);
+ try s.expect("/index", index);
+ try s.expect("/layout", layout);
+ try s.expect("/focus", focus);
+ try std.testing.expect(std.mem.indexOf(u8, try s.read("/log"), "unsaved ") != null);
+}
diff --git a/test/behaviour/look_and_exec.zig b/test/behaviour/look_and_exec.zig
index f9b49ae0..f3b94a3f 100644
--- a/test/behaviour/look_and_exec.zig
+++ b/test/behaviour/look_and_exec.zig
@@ -125,3 +125,39 @@ test "look-and-exec: exec runs a builtin at the pane, and look and exec read bac
try std.testing.expect(try listed(&s, n) and !try listed(&s, made));
try s.expect("/exec", s.at("{d}\n", .{made}));
}
+
+test "look-and-exec: look and exec read back what the last command touched, a ctl write's too" {
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ const n = try s.focused();
+ try s.write("/exec", "Msg first\n");
+ try s.expect("/exec", s.at("{d}\n", .{n}));
+ // A pane made through ctl is what both read next, not the Msg's pane.
+ try s.write(s.at("/pane/{d}/ctl", .{n}), "Tty\n");
+ const made = try s.focused();
+ try std.testing.expect(made != n);
+ try s.expect("/exec", s.at("{d}\n", .{made}));
+ try s.expect("/look", s.at("{d}\n", .{made}));
+ // A ctl write that makes nothing names the pane it ran at.
+ try s.write("/ctl", "Verbose off\n");
+ try s.expect("/exec", s.at("{d}\n", .{made}));
+ // Closed, it is no pane to go to: a fresh read of look is empty.
+ try s.write(s.at("/pane/{d}/ctl", .{made}), "Del\n");
+ try std.testing.expect(!try listed(&s, made));
+ try s.expect("/look", "");
+}
+
+test "look-and-exec: a line starting with # runs as nothing at an exec or a ctl, silently" {
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ const n = try s.focused();
+ // The setup's own announcements are made by the first write.
+ try s.write("/ctl", "# settle\n");
+ const index = try s.read("/index");
+ const log = try s.read("/log");
+ const col = std.mem.sliceTo(try s.read("/layout"), ' ');
+ for ([_][]const u8{ "/exec", s.at("/pane/{d}/exec", .{n}), "/ctl", s.at("/pane/{d}/ctl", .{n}), s.at("/col/{s}/ctl", .{col}) }) |path|
+ try s.write(path, "# Platform: tty\n # indented too\n");
+ try s.expect("/index", index);
+ try s.expect("/log", log);
+}