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 /test/process.zig | |
| 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
Diffstat (limited to 'test/process.zig')
| -rw-r--r-- | test/process.zig | 31 |
1 files changed, 20 insertions, 11 deletions
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); |
