diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-04 21:45:41 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-04 21:58:21 -0300 |
| commit | 351b27091c894766cba4b61e49c37f2771605779 (patch) | |
| tree | 0c4da0edc0c390cfaeaceaab89199af3abb503cf | |
| parent | 528a66cc720b25252a497adeb358e729dc8f3a62 (diff) | |
| parent | fac51df2abec19e57932e0fbe4492d372d7daac2 (diff) | |
| download | pardes-351b27091c894766cba4b61e49c37f2771605779.tar.gz pardes-351b27091c894766cba4b61e49c37f2771605779.zip | |
merge the window's new-shell fix (a new terminal's first pty/run waited for ever, its greeting typed at the same first prompt after the window's resize; the canary's Newcol refused, the runner's 80x24 terminal shrinking the window), onto the window tier: every process the runner starts is kept off the user's display (WAYLAND_DISPLAY and DISPLAY unset, SDL_VIDEO_DRIVER=offscreen, in Child.spawn), as a second pardes-gui a case started could open a window there; a window's grid is its case's (Detached.Options.grid: its terminal's size and PARDES_TEST_COLS and _ROWS), the goldens regenerated at the 120x40 they were made for (they had been captured at the 80x24 the runner bug gave) and twice reproduced, the monkey at 80x28; gui.zig's comments point at test/process/window.zig; tui 38 (2 skipped), gui 33 and 5 skipped
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
| -rw-r--r-- | docs/next-tests.md | 8 | ||||
| -rw-r--r-- | src/gui/gui.zig | 4 | ||||
| -rw-r--r-- | src/ninep/pty.zig | 24 | ||||
| -rw-r--r-- | test/gui-goldens.txt | 34 | ||||
| -rw-r--r-- | test/process.zig | 31 | ||||
| -rw-r--r-- | test/process/look_and_exec.zig | 4 | ||||
| -rw-r--r-- | test/process/terminals.zig | 3 | ||||
| -rw-r--r-- | test/process/window.zig | 7 |
8 files changed, 68 insertions, 47 deletions
diff --git a/docs/next-tests.md b/docs/next-tests.md index b05e9352..d0289a0e 100644 --- a/docs/next-tests.md +++ b/docs/next-tests.md @@ -59,13 +59,7 @@ agent's survey. The `e2e` line (kbdin, mousein) is its first step. `Detached.frame()` waits for the window to say it is idle and reads its capture. - **A case about one frontend's own behaviour says `process.only(.tty)`.** - On the window, 31 cases pass and 5 skip. - - **Open:** on the window the canary's Newcol is refused after its - terminal steps (a fresh window takes it), and one run hung there. The - canary is tty-only until that is found. - - **Open, likely the same:** on the window a fresh terminal pane's first - pty/run sometimes never answers (4 runs of 6, before its shell's first - prompt). terminals' pty/run case is tty-only until it is found. + On the window, 33 cases pass and 5 skip. Before the port, the plan was: the Python suites in the build (fs.py, monkey9p.py, gui_monkey.py, agent_session_test.py) move onto it or onto Session, then diff --git a/src/gui/gui.zig b/src/gui/gui.zig index 15347eb6..ac32ced4 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -9487,7 +9487,7 @@ fn latencyNote(comptime fmt: []const u8, args: anytype) void { /// Writes the frame to latest.ppm in the capture directory, and a panel /// transition's frame `transition` to transition-<frame>.ppm too, so a test -/// can hold one partway (test/gui_golden.py). +/// can hold one partway (test/process/window.zig). fn captureFrame(g: *Gui, gpa: std.mem.Allocator, cmd: *c.SDL_GPUCommandBuffer, target: *c.SDL_GPUTexture, sw: u32, sh: u32, transition: ?u16) !void { const size = c.SDL_CalculateGPUTextureFormatSize(g.swapchain_format, sw, sh, 1); if (size == 0) { @@ -9529,7 +9529,7 @@ fn captureFrame(g: *Gui, gpa: std.mem.Allocator, cmd: *c.SDL_GPUCommandBuffer, t g.captured +%= 1; } -/// A test window's state for a harness (test/gui_golden.py), in the +/// A test window's state for a harness (test/process/window.zig), in the /// capture directory's `status`: "<loop step> <frames captured> <idle>". /// Idle is 1 once the frame last captured is the one that stays: nothing /// owes a frame, nothing moves, nothing waits on a clock. A harness that diff --git a/src/ninep/pty.zig b/src/ninep/pty.zig index 5c9a6289..5a974adf 100644 --- a/src/ninep/pty.zig +++ b/src/ninep/pty.zig @@ -324,6 +324,9 @@ pub fn noteMarks(p: *Pardes, id: usize, pane: *Pane) void { p.emitWrite(id, slot.line); p.emitWrite(id, "\r"); pardes.panes.terminal.noteCommand(pane, slot.line); + // The run is the shell's first command: a greeting `ls` typed at the + // same prompt would run after it, and its C would be taken for ours. + pane.greet = false; slot.phase = .sent; return; } @@ -768,6 +771,27 @@ test "pty/data writes at the shell and reads the raw stream" { try testing.expectEqualStrings("still", rd(p, data, 0, 64).bytes); } +test "a run waiting for a new terminal's first prompt is the only line typed there, no greeting after it" { + const gpa = testing.allocator; + const p = try withTerm(gpa); + defer p.deinit(); + p.panes[0].?.greet = true; // a Term's, in a window (resized) + p.update(.{ .resize = .{ .cols = 80, .rows = 24 } }); + while (p.nextEffect()) |_| {} + const node = Node.of(serialOf(p), .pty_run); + const h = call(p, .{ .tag = 1, .op = .open, .node = node }).reply.handle; + _ = call(p, .{ .tag = 2, .op = .write, .node = node, .handle = h, .data = "true\n" }); + p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b]133;A;cl=line;aid=pardes\x07$ \x1b]133;B;aid=pardes\x07" } }); + var sent: [32]u8 = undefined; + var len: usize = 0; + while (p.nextEffect()) |e| if (e == .write) { + const b = e.write.bytes.slice(); + @memcpy(sent[len..][0..b.len], b); + len += b.len; + }; + try testing.expectEqualStrings("true\r", sent[0..len]); +} + test "run answers how its command ended once the shell is back at a prompt" { const gpa = testing.allocator; const p = try withTerm(gpa); diff --git a/test/gui-goldens.txt b/test/gui-goldens.txt index 5132981f..aef75582 100644 --- a/test/gui-goldens.txt +++ b/test/gui-goldens.txt @@ -1,17 +1,17 @@ -01-boot 239162cabddeed8a2edbf2d8170d158dc7d413b8fda251945c95a1573e8c1298 -02-second-document 04173d1c7aab94791cb4babc272710597cd8684b23f92e50a4892fc08df1807f -03-notice de5203c9cacb096d2976a3c6267cb1bcdc5af087b5690ca77ebc092a14cdc5d9 -04-context-rows-mid-thumb c42a08e9fe5bb00a98c78dd54fd52eff75e207767275e879b16a974ff0f361c9 -05-body-selection 05c75c7993e6d3107ddc5d908405a8a941f94467486f36a97b659833c5e50dc0 -06-tag-focus-selection ff202b98fa512254deca1dc01d4a19c0fab176bc9f9c703a1dc53d9a3741cda5 -07-prompt-notice c4d90e8f52d020c4e713c7ec0f1e5a4e73a4b6608cedf663ddac10c394e292cf -08-wide-glyph-edges 124b79077f1d204cb9f435f63f7cece52e199bde628491dfa083ec67054a6721 -09-collapsed-focus-tint 3d2c00a08659d37c8ad2da6c474b3dcad844905f2f5c5b68e95f2f0d72b3647e -10-tagbottom a3926b7a9fe16b102e876ba0c536d9de4f043376c0d100e302b785c03fd81ad8 -12-multiline-tag a04558e6f11835c13bbe81b90d31cc24d6b5b4c4220a358e4b79546ae61e8a89 -13-image 4b7af674aa77394a94ed942e7144cb2244c5189fc982dd3c69f542fb0204801e -14-theme-ink bed6e49e993e963d509d75e65f7f15ce28f72e239a063294ba72b3e5247a8f38 -15-theme-acme-light 5d2ffe65bd57afb5380891c32499e6523f5663986cef1212f2431a7559437ba1 -16-debug e7a50fbb37b8a6a7ff172ff583154626eb3f5bec5e1ac4e0d17751bce50c24dd -17-terminal e3208d4378cce3d0762c8d1073e90487da40af44a0d6e4a7f3256e0ee73ee700 -18-mid-transition 2f22bd0dbf72ec1073d794b1b442e1213491a6e80e2c6a275cf8e0c836adb22a +01-boot bb684190c85d17f6688d458756b38d645f019fbb081b4cd4d0d435a01e9de0c3 +02-second-document 1be84e0cb97531cfe37ae3382951ad6d4489b871c3000cc3d3c46d30df794a1d +03-notice 712ed4b9c02cbb8f3e18c03597dbcb5cd678a77ac560845245a44e266d038ea9 +04-context-rows-mid-thumb 429a50197dc7fa442fe0b9aa8c732c741c372348c3394e1809361086cceb1ff4 +05-body-selection 65619d076aec3d24cc2dac308228a282a898be0f6292a416197ae0f9ffe68532 +06-tag-focus-selection 248bcdad20febb363e35a53bd8b14d15289b2f56e7edc7d087ee86668236b670 +07-prompt-notice 4b1511f42b1cc06d3fe8b07e44a296a6c3fb2a37788cf0e9b5b1c7837a00993b +08-wide-glyph-edges c200d9fd0254af6b39a6387a074b1e29efeb3bd4114b373f83650a8bae8900ad +09-collapsed-focus-tint 4ac6f25f742ad68ea00a5033fd6c6c785b3426a0045499f046f99db9310c5721 +10-tagbottom 81ba5c104a359f7540bdc99ad7c24b684b0328915d90c3af606df637416190e6 +12-multiline-tag de215baa054a8435ce52356576977bd7c0b556295b9032e347d50682b8533722 +13-image f5913611e7227eb16733ca778a53621bb49f92489a956c7f8788a7d1a834e153 +14-theme-ink 80b0623442b5a4e22f508355351ca4a31b43d9bfd7e7fb63bc054c5274c98e6d +15-theme-acme-light 6e2ba713570d3d2baeaf927218d21f497a43b1d1fc59e7a3eff68f213e5cf7f7 +16-debug 86f8892f2eb9c4f14858d39eb070c95b83905874f33b8f2fa89bbffbad8602d1 +17-terminal 5f192b2fff53c66d154f4ad310d07c168838172d85cc59ba0fd51720d6abba2e +18-mid-transition 9cfac7223c513df1e15177a69808a0a922e9e6b7fe29c9934754a7e561144d0c diff --git a/test/process.zig b/test/process.zig index 00f288a7..57f12e10 100644 --- a/test/process.zig +++ b/test/process.zig @@ -548,6 +548,10 @@ pub const Detached = struct { socket: ?[]const u8 = null, /// Its startup file (`config/pardes/init` in the root), written first. init: ?[]const u8 = null, + /// A window's grid, cols and rows: its terminal's size, which a + /// test window takes, and PARDES_TEST_COLS and _ROWS. A detached + /// session's 160x50 by default, so a case means the same on both. + grid: [2]u16 = .{ 160, 50 }, }; /// A session of the backend's: `pardes --detach=<name>`, or the window @@ -605,6 +609,7 @@ pub const Detached = struct { argv[1] = first; for (opts.args, 0..) |a, k| argv[2 + k] = a; argv[2 + opts.args.len] = fixture; + var grid_buf: [2][8]u8 = undefined; var env: [16][2][:0]const u8 = undefined; var n: usize = 0; env[n] = .{ "PARDES_DUMP", try std.fmt.bufPrintSentinel(&bufs[2], "{s}/{s}.dump.zon", .{ dir, name }, 0) }; @@ -612,11 +617,8 @@ pub const Detached = struct { if (gui) for ([_][2][:0]const u8{ .{ "PARDES_TEST", "1" }, .{ "PARDES_TEST_CAPTURE_DIR", d.cap_buf[0..d.cap_len :0] }, - // A detached session's grid, so a case means the same on both. - .{ "PARDES_TEST_COLS", "160" }, - .{ "PARDES_TEST_ROWS", "50" }, - // Hidden and offscreen: no display of the user's is touched. - .{ "SDL_VIDEO_DRIVER", "offscreen" }, + .{ "PARDES_TEST_COLS", try std.fmt.bufPrintSentinel(&grid_buf[0], "{d}", .{opts.grid[0]}, 0) }, + .{ "PARDES_TEST_ROWS", try std.fmt.bufPrintSentinel(&grid_buf[1], "{d}", .{opts.grid[1]}, 0) }, }) |kv| { env[n] = kv; n += 1; @@ -629,9 +631,9 @@ pub const Detached = struct { d.child = try Child.spawn(argv[0 .. 3 + opts.args.len], .{ .root = dir, .env = env[0..n], - .unset = if (gui) &.{ "WAYLAND_DISPLAY", "DISPLAY" } else &.{}, - // A window runs on a terminal of its own, as one started from a shell. - .pty = if (gui) .{ .log = try std.fmt.bufPrintSentinel(&bufs[3], "{s}/{s}.pty", .{ dir, name }, 0) } else null, + // A window runs on a terminal of its own, as one started from a + // shell, the grid's size: a test window follows its terminal's. + .pty = if (gui) .{ .log = try std.fmt.bufPrintSentinel(&bufs[3], "{s}/{s}.pty", .{ dir, name }, 0), .cols = opts.grid[0], .rows = opts.grid[1] } else null, .err_log = try std.fmt.bufPrintSentinel(&bufs[4], "{s}/{s}.stderr", .{ dir, name }, 0), }); errdefer d.child.deinit(); @@ -832,6 +834,9 @@ pub const Child = struct { log: [:0]const u8, /// Made its controlling terminal; else a pty that is no one's. ctty: bool = true, + /// Its size: a test window follows its terminal's (gui.zig's StdinFeed). + cols: u16 = 80, + rows: u16 = 24, }; pub const Options = struct { @@ -845,7 +850,7 @@ pub const Child = struct { unset: []const [:0]const u8 = &.{}, /// Its stdin, written whole and closed; null: /dev/null. stdin: ?[]const u8 = null, - /// Started in a 24x80 pty, its stdin and stdout. + /// Started in a pty (80x24 unless it says), its stdin and stdout. pty: ?Pty = null, /// Its stderr to this file, not a pipe: a long session's, which /// nobody reads while it runs and which must never fill. `said` @@ -876,8 +881,8 @@ pub const Child = struct { @memcpy(c.err_path[0..path.len], path); c.err_path_len = path.len; } - if (opts.pty != null) { - var ws: std.posix.winsize = .{ .row = 24, .col = 80, .xpixel = 0, .ypixel = 0 }; + if (opts.pty) |p| { + var ws: std.posix.winsize = .{ .row = p.rows, .col = p.cols, .xpixel = 0, .ypixel = 0 }; if (openpty(&c.master, &c.slave, null, null, &ws) != 0) return error.NoPty; for ([_]c_int{ c.master, c.slave }) |fd| _ = libc.fcntl(fd, libc.F.SETFD, @as(c_int, 1)); // FD_CLOEXEC } @@ -903,6 +908,10 @@ pub const Child = struct { .{ "PARDES_LSP_TS", "" }, .{ "PARDES_LSP_PY", "" }, }) |kv| if (setenv(kv[0], kv[1], 1) != 0) _exit(126); if (opts.pty != null and setenv("TERM", "xterm-256color", 1) != 0) _exit(126); + // No test reaches the user's display: a window any of them + // starts (a second pardes-gui, a --tty launch) is offscreen. + for ([_][*:0]const u8{ "WAYLAND_DISPLAY", "DISPLAY" }) |v| _ = unsetenv(v); + if (setenv("SDL_VIDEO_DRIVER", "offscreen", 1) != 0) _exit(126); for (opts.env) |kv| if (setenv(kv[0], kv[1], 1) != 0) _exit(126); for (opts.unset) |name| _ = unsetenv(name); if (cwd) |d| if (libc.chdir(d) != 0) _exit(126); diff --git a/test/process/look_and_exec.zig b/test/process/look_and_exec.zig index 83836def..5a42b844 100644 --- a/test/process/look_and_exec.zig +++ b/test/process/look_and_exec.zig @@ -63,10 +63,6 @@ const Flow = struct { }; fn canary(gpa: std.mem.Allocator, exe: [:0]const u8) !void { - // shortcut: on the window, after its terminal steps, Newcol is refused - // (or a run hangs), where a fresh window takes it; tui alone until that - // is found (docs/next-tests.md). - try process.only(.tui); const started = process.nowMs(); var arena = std.heap.ArenaAllocator.init(gpa); defer arena.deinit(); diff --git a/test/process/terminals.zig b/test/process/terminals.zig index 96804adf..250c4fb0 100644 --- a/test/process/terminals.zig +++ b/test/process/terminals.zig @@ -79,9 +79,6 @@ const Other = struct { }; fn runFile(gpa: std.mem.Allocator, exe: [:0]const u8) !void { - // shortcut: on the window a fresh Term's first pty/run sometimes never - // answers (4 runs of 6); tui alone until that is found (docs/next-tests.md). - try process.only(.tui); var d = try process.Detached.start(gpa, exe, "run", .{}); defer d.deinit(); const f = &d.files; diff --git a/test/process/window.zig b/test/process/window.zig index 63247122..1fe2fd2e 100644 --- a/test/process/window.zig +++ b/test/process/window.zig @@ -59,8 +59,8 @@ fn monkeyOne(gpa: std.mem.Allocator, exe: [:0]const u8, motion: []const u8, lift defer arena.deinit(); const a = arena.allocator(); const init = try std.fmt.allocPrint(a, "Shell /bin/sh\nMessageLinger 0\nMotion {s}\nLift {s}\nBloom {s}\nPanelSlide\nSelectionGlow on\nHoverGlow on\n", .{ motion, lift, bloom }); - var d = try process.Detached.start(gpa, exe, "monkey", .{ .init = init, .env = &.{ - .{ "PARDES_TEST_CLOCK", "1" }, .{ "PARDES_TEST_COLS", "80" }, .{ "PARDES_TEST_ROWS", "28" }, .{ "PARDES_TEST_PAD", "0" }, + var d = try process.Detached.start(gpa, exe, "monkey", .{ .init = init, .grid = .{ 80, 28 }, .env = &.{ + .{ "PARDES_TEST_CLOCK", "1" }, .{ "PARDES_TEST_PAD", "0" }, } }); defer d.deinit(); const f = &d.files; @@ -245,7 +245,8 @@ fn goldens(gpa: std.mem.Allocator, exe: [:0]const u8) !void { .init = "Shell /bin/sh\nTheme forge\nMessageLinger 0\n", // The virtual clock: a transition's frames are the same frames on // any machine, so one partway through can be hashed too. - .env = &.{ .{ "PARDES_TEST_CLOCK", "1" }, .{ "PARDES_TEST_COLS", "120" }, .{ "PARDES_TEST_ROWS", "40" }, .{ "PARDES_TEST_PAD", "7" } }, + .grid = .{ 120, 40 }, + .env = &.{ .{ "PARDES_TEST_CLOCK", "1" }, .{ "PARDES_TEST_PAD", "7" } }, }); defer d.deinit(); const f = &d.files; |
