summaryrefslogtreecommitdiff
path: root/src/ninep/pty.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/ninep/pty.zig')
-rw-r--r--src/ninep/pty.zig29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/ninep/pty.zig b/src/ninep/pty.zig
index 0a55df94..50d14624 100644
--- a/src/ninep/pty.zig
+++ b/src/ninep/pty.zig
@@ -849,6 +849,35 @@ test "a run's answer says cut when its output's start is gone, and reads a bound
try testing.expectEqualStrings("error out of memory\n", sh.answered(p, node, h, into));
}
+test "a terminal's ctl counts its body, and a new directory is a rename in the log" {
+ const gpa = testing.allocator;
+ const p = try withTerm(gpa);
+ defer p.deinit();
+ const serial = serialOf(p);
+ p.update(.{ .output = .{ .pane = 0, .bytes = "some history\r\nmore" } });
+ while (p.nextEffect()) |_| {}
+ const opened = call(p, .{ .tag = 1, .op = .open, .node = Node.of(serial, .body) });
+ const body_len = call(p, .{ .tag = 2, .op = .read, .node = Node.of(serial, .body), .handle = opened.reply.handle, .size = 1 << 16 }).bytes.len;
+ _ = call(p, .{ .tag = 3, .op = .release, .node = Node.of(serial, .body), .handle = opened.reply.handle });
+ try testing.expect(body_len > 0);
+ var fields = std.mem.tokenizeScalar(u8, rd(p, Node.of(serial, .ctl), 0, 4096).bytes, ' ');
+ _ = fields.next();
+ _ = fields.next();
+ try testing.expectEqual(body_len, try std.fmt.parseInt(usize, fields.next().?, 10));
+
+ const log = @intFromEnum(tree.TopFile.log);
+ const f = call(p, .{ .tag = 4, .op = .open, .node = log }).reply.handle;
+ const frozen = call(p, .{ .tag = 5, .op = .read, .node = log, .handle = f, .size = 1 << 16 }).bytes.len;
+ _ = call(p, .{ .tag = 6, .op = .write, .node = log, .handle = f, .data = "follow" });
+ p.setCwd(0, "/somewhere/else");
+ var want: [64]u8 = undefined;
+ try testing.expectEqualStrings(
+ try std.fmt.bufPrint(&want, "rename {d} /somewhere/else\n", .{serial}),
+ call(p, .{ .tag = 7, .op = .read, .node = log, .handle = f, .off = frozen, .size = 4096 }).bytes,
+ );
+ _ = call(p, .{ .tag = 8, .op = .release, .node = log, .handle = f });
+}
+
test "closing a terminal pane asks its shell to hang up the pty" {
const p = try withTerm(testing.allocator);
defer p.deinit();