From a0320c49c1288e8e74f18983f18988a024952bb8 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 3 Nov 2026 16:38:06 -0300 Subject: test: four more of src/ninep/ctl.zig's tests through the 9P tree alone (test/behaviour/look_and_exec, columns_and_tags, root_ctl): a look's leading blanks and exec's trim, a bare :N look from a pane's look, the root's and an event write-back (dot read from the dot file), a look after Newcol (the column read from /layout), size of a detached session (the screen read from /screen); Session's range and detach; each checked to fail against a break (a look's blanks trimmed, size taking a screen too small for its panes) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/ninep/ctl.zig | 75 ------------------------------------------------------- 1 file changed, 75 deletions(-) (limited to 'src') diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 69a0e791..4a3d753c 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -2493,24 +2493,6 @@ test "a look line's trailing colon is dropped, and a look whose address fails ne try testing.expectEqual(@as(i32, 1), opened.body.cur_row); } -test "a bare :N or :N:M look addresses the pane itself, from its look, the root's and event write-back" { - const p = try withFile(testing.allocator, "alpha\nbeta\ngamma\n"); - defer p.deinit(); - const serial = serialOf(p); - const pane = p.panes[p.paneBySerial(serial).?].?; - try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .look), ":2\n").reply.status); - try testing.expectEqual(pane_files.State.Range{ .q0 = 6, .q1 = 11 }, pane_files.dotOf(pane)); - try testing.expectEqual(Status.ok, wr(p, root_look, ":3\n").reply.status); - try testing.expectEqual(pane_files.State.Range{ .q0 = 11, .q1 = 17 }, pane_files.dotOf(pane)); - try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .look), ":3:2\n").reply.status); - try testing.expectEqual(@as(u32, 12), pane_files.dotOf(pane).q0); - // Written back by an event reader, the same. - const event = Node.of(serial, .event); - const h = call(p, .{ .tag = 1, .op = .open, .node = event }).reply.handle; - defer _ = call(p, .{ .tag = 9, .op = .release, .node = event, .handle = h }); - try testing.expectEqual(Status.ok, wr(p, event, "ML0 0 0 2 :1\n").reply.status); - try testing.expectEqual(pane_files.State.Range{ .q0 = 0, .q1 = 6 }, pane_files.dotOf(pane)); -} test "a refused Del written back through event fails that write, EIO, with its err" { const gpa = testing.allocator; @@ -2806,25 +2788,6 @@ test "Joincol with no column to the right and Theme with no such theme say so" { try testing.expect(tested); } -test "a look after Newcol fills the empty column the keyboard is on" { - const gpa = testing.allocator; - const p = try withFile(gpa, "x\n"); - defer p.deinit(); - var tmp = testing.tmpDir(.{}); - defer tmp.cleanup(); - try tmp.dir.writeFile(testing.io, .{ .sub_path = "f.txt", .data = "file\n" }); - var dir: [4096]u8 = undefined; - const at = dir[0..try tmp.dir.realPath(testing.io, &dir)]; - var line: [4200]u8 = undefined; - // Newcol makes an empty column and gives its tag the keyboard; no pane - // has it, so focus reads empty. - try testing.expectEqual(tree.Status.ok, wr(p, @backingInt(tree.TopFile.ctl), "Newcol\n").reply.status); - try testing.expectEqual(@as(usize, 0), p.col_n[p.ncol - 1]); - try testing.expectEqualStrings("", rd(p, @backingInt(tree.TopFile.focus), 0, 64).bytes); - try testing.expectEqual(tree.Status.ok, wr(p, @backingInt(tree.TopFile.look), try std.fmt.bufPrint(&line, "{s}/f.txt\n", .{at})).reply.status); - try testing.expectEqual(@as(usize, 1), p.col_n[p.ncol - 1]); - try testing.expectEqual(p.active, p.col_panes[p.ncol - 1][0]); -} test "a look at file:addr whose file is not there is one miss, quoting what was written, in a terminal too" { const p = try th.withTerm(testing.allocator); @@ -2999,27 +2962,6 @@ test "Edit's p and = never fail for want of room for +Errors: the text is logged try testing.expectEqual(@as(usize, 1), count); // the +Errors that had no room is gone } -test "size sets the screen of a session no frontend is attached to, and only of one" { - const p = try withFile(testing.allocator, "x\n"); - defer p.deinit(); - const root_ctl = @backingInt(tree.TopFile.ctl); - try testing.expectEqual(E.INVAL, wr(p, root_ctl, "size 120 40\n").errno()); // a frontend's - p.unattended = true; - try testing.expectEqual(Status.ok, wr(p, root_ctl, "size 120 40\n").reply.status); - try testing.expectEqual(@as(u16, 120), p.screen_w); - try testing.expectEqual(@as(u16, 40), p.screen_h); - try testing.expectEqual(E.INVAL, wr(p, root_ctl, "size 120\n").errno()); - try testing.expectEqual(E.INVAL, wr(p, root_ctl, "size\n").errno()); - try testing.expect(std.mem.indexOf(u8, wr(p, root_ctl, "size 5 2\n").reply.ename, "at least 20x6, at most 4096x4096") != null); - // The bad value quoted, never the word size. - try testing.expect(std.mem.endsWith(u8, wr(p, root_ctl, "size 5 2\n").reply.ename, "\"5 2\"")); - // Too small for the panes it has, each its tag and two rows: refused, - // the size as it was. - for (0..4) |_| p.newScratchBelow(p.active); - p.sync(); - try testing.expect(std.mem.indexOf(u8, wr(p, root_ctl, "size 80 8\n").reply.ename, "too small for the panes") != null); - try testing.expectEqual(@as(u16, 40), p.screen_h); -} test "Mount dials its peer and fails, mounting nothing, when none answers; a look through a peer gone says dial failed" { const p = try withFile(testing.allocator, "x\n"); @@ -3578,23 +3520,6 @@ test "a restored pane whose file is gone from disk comes back dirty, and Del ask try testing.expect(std.mem.indexOf(u8, r.reply.ename, "Modified") != null); } -test "a 9P look keeps its leading blanks, a blank-only look included, and exec still trims" { - const p = try withFile(testing.allocator, "a indented\nb\n indented\n \n"); - defer p.deinit(); - const serial = serialOf(p); - const pane = p.panes[p.paneBySerial(serial).?].?; - pane_files.setDot(pane, .{ .q0 = 0, .q1 = 0 }); - // The indented line, not the `indented` after `a `. - try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .look), " indented\n").reply.status); - try testing.expectEqual(pane_files.State.Range{ .q0 = 13, .q1 = 25 }, pane_files.dotOf(pane)); - // Blanks alone are text to find too. - pane_files.setDot(pane, .{ .q0 = 26, .q1 = 26 }); - try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .look), " \n").reply.status); - try testing.expectEqual(pane_files.State.Range{ .q0 = 26, .q1 = 30 }, pane_files.dotOf(pane)); - // exec's line is still trimmed: ` Msg hi` runs Msg. - try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .exec), " Msg blanks trimmed\n").reply.status); - try testing.expect(th.logHas(p, "blanks trimmed")); -} test "a focus moved over 9P tells the programs that asked for focus reports, as a click does" { const p = try Pardes.init(testing.allocator, .{ .cols = 90, .rows = 30, .shells = 2 }); -- cgit v1.3