summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-06 03:20:04 -0300
committerGabriel Schneider <[email protected]>2026-11-06 04:13:33 -0300
commit4c2125ecf47588d33f9894c1fdf2833d0512f3b4 (patch)
treec76510fd390e20187554ea86a3fdabd2dfb65ca5 /test
parentd1d5d3cfb18841604bba2057eeb3598f729b4475 (diff)
downloadpardes-4c2125ecf47588d33f9894c1fdf2833d0512f3b4.tar.gz
pardes-4c2125ecf47588d33f9894c1fdf2833d0512f3b4.zip
client #2, one frontend a session: the daemon answers `other <name>` for an attach to a session attached already (as it did for one of the other kind), so a second `pardes --attach` or `pardes-gui --attach` on this machine is a replica client through the replica socket, the path a remote one takes; a session tells the daemon its clients (SO_PEERCRED on each replica socket, at every join and leave) and `--ps` lists `client <pid> <command>` under it; the tty's per-terminal Screens (Screen.create/drop/destroy, primary, its stub and Killed slot), the Poster and its `from` input, the Gui's window-fields swap (window_fields, GuiWindow, copyWindow, freshWindow, follow, route, openAnotherWindow, closeView, windowsOpen, closeOtherWindows, resumeWindows), drawOthers and every harness's extra terminals (snapshot.zig's `start ... views=N` and `view <k>`, e2e_harness's initView and drainOthers, PARDES_TEST_VIEWS in both frontends, the GUI feed's `view;<k>`, the monkey's --views) go; the pump draws the one view this process shows (views.shown), through drawOne when a client's input was the last; an Upgrade from a build that kept a second terminal of its own lets it go (its stub told it is detached) and closes its view; deleted: views.snap, views-term.snap and views-pan.snap with their goldens (the in-process second terminal they drove is gone; views.zig's unit tests keep the per-view cursor, layout, register, sizing, closing and panning behaviour, test/replicas.zig and the soak the views of clients); the two views.zig tests that drew through drawOthers draw through drawOne; daemon.py's second terminal is a client listed by --ps, typed into in both terminals, detached from inside and closed; its second window a client listed by --ps and closed; the reference and next-daemon.md say so; no golden changes; gates: core-test 956/956 both, behaviour-test 248/248 both, unit-test 1487/1488 tui and 1530/1531 gui, pane-test 171/172 both, snap all 102 ok, process-test 0 of 37 failed on both, hxdiff 19 and hxparity 6 mismatches (the base's names), hxgolf 0, replicas, addon-test, gui-golden and monkey-gui 0 of 1 failed, daemon.py main, --window-clients and --gui ok, soak local pass (differ, mispred, view_bad, lost 0)
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test')
-rw-r--r--test/daemon.py39
-rw-r--r--test/e2e_harness.zig62
-rw-r--r--test/monkey.zig31
-rw-r--r--test/snapshot.zig85
-rw-r--r--test/snapshots/views-pan.golden52
-rw-r--r--test/snapshots/views-pan.snap27
-rw-r--r--test/snapshots/views-term.golden46
-rw-r--r--test/snapshots/views-term.snap27
-rw-r--r--test/snapshots/views.golden123
-rw-r--r--test/snapshots/views.snap57
10 files changed, 54 insertions, 495 deletions
diff --git a/test/daemon.py b/test/daemon.py
index f8ef9be4..c53405db 100644
--- a/test/daemon.py
+++ b/test/daemon.py
@@ -1139,9 +1139,11 @@ def main(binary, cycles):
assert now == baseline, (cycle, now, baseline)
print(f'daemon: {cycles} detach/attach cycles, fds/sockets/processes level: {baseline}')
- # Another terminal while one is attached: a view of its own
- # (src/views.zig), drawn beside the first. Detached from inside, its
- # stub ends and the first draws on; closed outright, the same.
+ # Another terminal while one is attached: a replica client of the
+ # session (a session shows one frontend of its own), listed under
+ # it by --ps, drawn beside the first, typed into as the first is.
+ # Detached from inside, it ends and the first draws on; closed
+ # outright, the same.
for how in ('detach', 'close'):
# Bigger than the first: the shell, sized for the first (its
# last typist), shows whole in it.
@@ -1150,6 +1152,12 @@ def main(binary, cycles):
started.append(stub2.pid)
wait_for('the second terminal\'s first frame', lambda: b'\x1b[?1049h' in term2.text())
wait_for('the second terminal\'s view live', lambda: client.screen()['cols'] == 120)
+ listed = subprocess.run([binary, '--ps'], env=env, capture_output=True, timeout=30).stdout.decode()
+ assert f'client {stub2.pid} ' in listed, listed
+ os.write(term.master, f'echo one-typed-{how}\r'.encode())
+ wait_for('the first terminal\'s keys in the shell', lambda: f'one-typed-{how}'.encode() in client.read(f'/pane/{shell}/body'))
+ os.write(term2.master, f'echo two-typed-{how}\r'.encode())
+ wait_for('the second terminal\'s keys in the shell', lambda: f'two-typed-{how}'.encode() in client.read(f'/pane/{shell}/body'))
seen = len(term.text())
run(client, shell, f'echo both-drawn-{how}\n'.encode())
wait_for('the first terminal drawn', lambda: f'both-drawn-{how}'.encode() in term.text()[seen:])
@@ -1158,20 +1166,20 @@ def main(binary, cycles):
if how == 'detach':
# Its view is the live one (its terminal spoke last).
client.write(f'/pane/{shell}/exec', b'Detach\n')
- assert stub2.wait(timeout=10) == 0, stub2.returncode
- wait_for('the second stub says it detached', lambda: b'detached from \'work\'' in term2.text())
+ stub2.wait(timeout=10)
term2.close()
else:
term2.close()
stub2.wait(timeout=10)
wait_for('the first terminal\'s view live again', lambda: client.screen()['cols'] == 100)
+ wait_for('the client gone from --ps', lambda: 'client ' not in subprocess.run([binary, '--ps'], env=env, capture_output=True, timeout=30).stdout.decode())
seen = len(term.text())
run(client, shell, f'echo first-on-{how}\n'.encode())
wait_for('the first terminal drawn on', lambda: f'first-on-{how}'.encode() in term.text()[seen:])
assert stub.poll() is None, 'the first terminal stays attached'
now = (fds(session), fds(daemon), len(list(root.iterdir())), len([p for p in processes(root) if alive(p)]))
assert now[:3] == baseline[:3], (how, now, baseline)
- print('daemon: a second terminal on an attached session drawn beside the first, then detached and closed; the first drew on')
+ print('daemon: a second terminal on an attached session a client of it (in --ps), both typed into and drawn, then detached and closed; the first drew on')
# Killed outright: its shells live on, their masters the daemon's,
# and a replica client of it hears so at once, in words (one froze
@@ -1302,17 +1310,18 @@ def gui(binary, cycles):
baseline = baseline or now
assert now == baseline, (cycle, now, baseline)
print(f'daemon: {cycles} window detach/attach cycles, fds/processes level: {baseline}')
- # Attached already: another window, a view of its own (its test
- # captures under view-1); Detach in it closes only it.
- attach = subprocess.run([binary, '--attach=win'], env=env, cwd=root, timeout=10,
- stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- assert attach.returncode == 0, attach.stderr
- wait_for('the second window drawn', lambda: (root / 'caps' / 'view-1' / 'latest.ppm').exists())
- client.write(f'/pane/{shell}/exec', b'Detach\n')
- time.sleep(.5)
+ # Attached already: another window is a replica client of the
+ # session (its own process, its captures its own), listed by --ps;
+ # closed, it ends alone.
+ second = Window(root, 'second', [binary, '--attach=win'], env)
+ wait_for('the second window drawn', lambda: (root / 'second' / 'latest.ppm').exists(), timeout=20)
+ listed = subprocess.run([binary, '--ps'], env=env, cwd=root, capture_output=True, timeout=30).stdout.decode()
+ assert f'client {second.pid} ' in listed, listed
+ second.close()
+ wait_for('the client gone from --ps', lambda: 'client ' not in subprocess.run([binary, '--ps'], env=env, cwd=root, capture_output=True, timeout=30).stdout.decode())
assert not sized(client), 'the first window stays'
assert proc.poll() is None
- print('daemon: a second window on an attached window session, detached alone')
+ print('daemon: a second window on an attached window session a client of it (in --ps), closed alone')
# Another kind joins as a replica client: a terminal of the window's
# session, by its name alone. A name nobody has is refused in words.
client.write(f'/pane/{shell}/exec', b'Detach\n')
diff --git a/test/e2e_harness.zig b/test/e2e_harness.zig
index 410c33ae..396de8c5 100644
--- a/test/e2e_harness.zig
+++ b/test/e2e_harness.zig
@@ -80,12 +80,6 @@ pub const Harness = struct {
/// clipboard writes). Capture is bounded explicitly so a runaway child cannot
/// consume unbounded test-runner memory.
raw: *RawCapture,
- /// Another view's terminal of the app this harness started (`view`):
- /// it neither started the app nor kills it.
- view: bool = false,
- /// Every terminal of the app's, this one's too: each wait reads them
- /// all, or the app would block writing a frame to one nobody reads.
- views: []const *Harness = &.{},
pub fn init(gpa: std.mem.Allocator, exe: [*:0]const u8, rows: u16, cols: u16) !Harness {
return initArgs(gpa, exe, rows, cols, null);
@@ -143,36 +137,6 @@ pub const Harness = struct {
};
}
- /// A terminal for another view of the app `pid` (views.zig): a pty of
- /// its own, whose path the app is given (PARDES_TEST_VIEWS) and opens.
- pub fn initView(gpa: std.mem.Allocator, rows: u16, cols: u16, path: *[64]u8) !Harness {
- var master: c_int = undefined;
- var slave: c_int = undefined;
- const ws = posix.winsize{ .row = rows, .col = cols, .xpixel = 0, .ypixel = 0 };
- if (openpty(&master, &slave, null, null, &ws) != 0) return error.NoPty;
- defer _ = libc.close(slave);
- const name = std.mem.span(ttyname(slave) orelse return error.NoPty);
- if (name.len >= path.len) return error.NoPty;
- @memcpy(path[0..name.len], name);
- path[name.len] = 0;
- const term = try gpa.create(ghostty_vt.Terminal);
- errdefer gpa.destroy(term);
- term.* = try ghostty_vt.Terminal.init(std.Io.Threaded.global_single_threaded.io(), gpa, .{
- .cols = cols,
- .rows = rows,
- .max_scrollback_bytes = 1024 * 1024,
- });
- errdefer term.deinit(gpa);
- const raw = try gpa.create(RawCapture);
- raw.* = .{};
- return .{ .gpa = gpa, .master = master, .pid = 0, .term = term, .stream = term.vtStream(), .rows = rows, .cols = cols, .raw = raw, .view = true };
- }
-
- /// What the app wrote to its other terminals, read without waiting.
- fn drainOthers(self: *Harness) void {
- for (self.views) |other| if (other != self) while (other.pumpRead(0)) {};
- }
-
fn pumpRead(self: *Harness, ms: i64) bool {
var fds = [_]posix.pollfd{.{ .fd = self.master, .events = posix.POLL.IN, .revents = 0 }};
const ready = posix.poll(&fds, @intCast(@max(0, ms))) catch 0;
@@ -185,17 +149,8 @@ pub const Harness = struct {
return true;
}
- /// Bytes in every terminal of the app's (`pending`).
- pub fn pendingAll(self: *Harness) usize {
- var n = self.pending();
- for (self.views) |other| if (other != self) {
- n += other.pending();
- };
- return n;
- }
-
pub fn deinit(self: *Harness) void {
- if (!self.view) posix.kill(self.pid, posix.SIG.KILL) catch {};
+ posix.kill(self.pid, posix.SIG.KILL) catch {};
_ = libc.close(self.master);
self.stream.deinit();
self.gpa.destroy(self.raw);
@@ -240,9 +195,8 @@ pub const Harness = struct {
const deadline = nowMs() + ms;
var buf: [4096]u8 = undefined;
while (nowMs() < deadline) {
- self.drainOthers();
var fds = [_]posix.pollfd{.{ .fd = self.master, .events = posix.POLL.IN, .revents = 0 }};
- _ = posix.poll(&fds, if (self.views.len > 1) 5 else 50) catch {};
+ _ = posix.poll(&fds, 50) catch {};
if ((fds[0].revents & posix.POLL.IN) != 0) {
const n = posix.read(self.master, &buf) catch break;
if (n == 0) break;
@@ -259,14 +213,7 @@ pub const Harness = struct {
/// SETTLED grid sleeps in poll until the app actually writes, instead of
/// burning a fixed window per check (see snapshot.zig's waitStable).
pub fn pumpOnce(self: *Harness, ms: i64) !bool {
- if (self.views.len <= 1) return self.pumpRead(ms);
- // Several terminals: each looked at every few milliseconds.
- const deadline = nowMs() + ms;
- while (true) {
- self.drainOthers();
- if (self.pumpRead(@min(5, @max(0, deadline - nowMs())))) return true;
- if (nowMs() >= deadline) return false;
- }
+ return self.pumpRead(ms);
}
/// Bytes sitting in the pty that nobody has picked up — keystrokes the app
@@ -326,9 +273,8 @@ pub const Harness = struct {
const deadline = nowMs() + ms;
var buf: [4096]u8 = undefined;
while (nowMs() < deadline) {
- self.drainOthers();
var fds = [_]posix.pollfd{.{ .fd = self.master, .events = posix.POLL.IN, .revents = 0 }};
- _ = posix.poll(&fds, if (self.views.len > 1) 5 else 50) catch {};
+ _ = posix.poll(&fds, 50) catch {};
if ((fds[0].revents & posix.POLL.IN) != 0) {
const n = posix.read(self.master, &buf) catch break;
if (n == 0) break;
diff --git a/test/monkey.zig b/test/monkey.zig
index 70a4b4e4..243f2fbe 100644
--- a/test/monkey.zig
+++ b/test/monkey.zig
@@ -1,6 +1,6 @@
// pardes-monkey: random snapshot scripts against the tty, hunting panics.
//
-// zig build monkey -Dplatform=tui -- <seeds> [steps] [--from=N] [--out=DIR] [--keep] [--views=N]
+// zig build monkey -Dplatform=tui -- <seeds> [steps] [--from=N] [--out=DIR] [--keep]
//
// Each seed makes one script (a fixed seed makes the same script, so a hit
// replays): keys and leader bursts, typing, mouse presses, drags and wheel,
@@ -9,10 +9,7 @@
// /tmp/pardes-monkey), and a panic is a record in the app's crash file
// (src/crash.zig, in the script's fake home: found even when the crash cut
// the script short) or a `.zig:N:N: 0x` stack frame in the report or the
-// grid it captured (a trace renders INTO the screen). --views=N gives the
-// session N terminals, each a view of it (views.zig), and types into and
-// sizes each in turn, a `view` switch among the steps. A hit
-// keeps DIR/seed-N.snap, its captures and its report; the rest are deleted.
+// grid it captured (a trace renders INTO the screen). A hit keeps DIR/seed-N.snap, its captures and its report; the rest are deleted.
// A panic's trace can scroll off a small grid: replay the kept script, or
// run the app in a larger pty. Every hit gets a fix and a pinned regression
// script in test/snapshots/.
@@ -28,9 +25,6 @@ const Script = struct {
gpa: std.mem.Allocator,
rows: u16 = 24,
cols: u16 = 80,
- /// Each terminal's size, and the one typed into (`--views`).
- sizes: [4][2]u16 = @splat(.{ 24, 80 }),
- view: usize = 0,
fn line(s: *Script, comptime fmt: []const u8, args: anytype) !void {
try s.out.print(s.gpa, fmt ++ "\n", args);
@@ -43,24 +37,18 @@ const commands = [_][]const u8{ "Newcol", "Find", "Grep", "Joincol", "Help", "Du
const leader_keys = "abcdefghijklmnopqrstuvwxyz0123456789$^";
const typed = "abcdefghijklmnopqrstuvwxyz0123456789 -_=+,:;()";
-fn generate(gpa: std.mem.Allocator, seed: u64, steps: usize, views: usize) ![]u8 {
+fn generate(gpa: std.mem.Allocator, seed: u64, steps: usize) ![]u8 {
var prng = std.Random.DefaultPrng.init(seed);
const random = prng.random();
var s: Script = .{ .gpa = gpa };
- try s.line("# pardes-monkey seed {d}, {d} steps, {d} views", .{ seed, steps, views });
+ try s.line("# pardes-monkey seed {d}, {d} steps", .{ seed, steps });
try s.line("file bad.txt hello \\xff\\xfe world\\nlatin-1 caf\\xe9 tail\\ntruncated \\xe6\\x97 here\\nend\\n", .{});
try s.line("file wide.txt {s}tail\\nsecond line\\n", .{std.mem.asBytes(&@as([8][37]u8, @splat("\\xe6\\x97\\xa5\\xe6\\x9c\\xac\\xe8\\xaa\\x9e ".*)))});
try s.line("lines long.txt 400 some words after the number, long enough to wrap in a narrow pane", .{});
- if (views > 1) try s.line("start 24 80 views={d} bad.txt", .{views}) else try s.line("start 24 80 bad.txt", .{});
+ try s.line("start 24 80 bad.txt", .{});
try s.line("wait 8000 Newcol Joincol", .{});
try s.line("stable 300 5000", .{});
for (0..steps) |step| {
- if (views > 1 and random.uintLessThan(u8, 4) == 0) {
- s.sizes[s.view] = .{ s.rows, s.cols };
- s.view = random.uintLessThan(usize, views);
- s.rows, s.cols = s.sizes[s.view];
- try s.line("view {d}", .{s.view + 1});
- }
const wide = s.cols >= 70 and s.rows >= 6;
switch (random.uintLessThan(u8, 12)) {
// A workspace word, run with a middle click: new columns make
@@ -177,7 +165,7 @@ pub fn main(init: std.process.Init) !void {
const io = init.io;
const args = try init.minimal.args.toSlice(init.arena.allocator());
if (args.len < 4) {
- std.debug.print("usage: pardes-monkey <pardes-snap> <pardes> <seeds> [steps] [--from=N] [--out=DIR] [--keep] [--tape=DIR] [--views=N] [--dump]\n", .{});
+ std.debug.print("usage: pardes-monkey <pardes-snap> <pardes> <seeds> [steps] [--from=N] [--out=DIR] [--keep] [--tape=DIR] [--dump]\n", .{});
std.process.exit(2);
}
const snap = args[1];
@@ -191,15 +179,12 @@ pub fn main(init: std.process.Init) !void {
// --tape=DIR: each seed's sessions record their tapes there and the
// seed is a hit if one does not replay (pardes-snap --tape).
var tape: ?[]const u8 = null;
- var views: usize = 1;
// --dump (with --tape): each replay loads the session's dump at its end
// too (pardes-snap --dump).
var dump = false;
var positional: usize = 0;
for (args[3..]) |a| {
- if (std.mem.startsWith(u8, a, "--views=")) {
- views = std.math.clamp(try std.fmt.parseInt(usize, a["--views=".len..], 10), 1, 4);
- } else if (std.mem.startsWith(u8, a, "--from=")) {
+ if (std.mem.startsWith(u8, a, "--from=")) {
from = try std.fmt.parseInt(u64, a["--from=".len..], 10);
} else if (std.mem.eql(u8, a, "--keep")) {
keep = true;
@@ -222,7 +207,7 @@ pub fn main(init: std.process.Init) !void {
var hits: usize = 0;
var seed = from;
while (seed < from + seeds) : (seed += 1) {
- const script = try generate(gpa, seed, steps, views);
+ const script = try generate(gpa, seed, steps);
defer gpa.free(script);
var path_buf: [4096]u8 = undefined;
const path = try std.fmt.bufPrint(&path_buf, "{s}/seed-{d}.snap", .{ out, seed });
diff --git a/test/snapshot.zig b/test/snapshot.zig
index 02215abd..d93face2 100644
--- a/test/snapshot.zig
+++ b/test/snapshot.zig
@@ -29,11 +29,7 @@
// lines <name> <n> [tail] create file with n numbered lines, tail on each
// dirmk <name> create a subdirectory
// run <shell...> run a command in the script's cwd (NOT in a pane)
-// start <rows> <cols> [views=N] [arg] fork the app in a pty (optional
-// extra CLI arg); views=N gives it N-1 more
-// terminals, each a view of the session
-// view <k> type into and capture terminal k (1 is the
-// app's own; a resize there SIGWINCHes the app)
+// start <rows> <cols> [arg] fork the app in a pty (optional extra CLI arg)
// wait <ms> <needle...> pump until needle appears on the grid (fails hard)
// settle <ms> pump for a fixed duration
// stable <quiet_ms> <timeout_ms> pump until the grid stops changing
@@ -685,14 +681,6 @@ fn runScript(arena: std.mem.Allocator, exe_z: [:0]const u8, script_path: []const
var chunk_len: usize = 0;
var h: ?eh.Harness = null;
defer if (h) |*hp| hp.deinit();
- // `views=N`: the app's other terminals, and the one driven now.
- var others: [3]eh.Harness = undefined;
- var nothers: usize = 0;
- var group: [4]*eh.Harness = undefined;
- var cur: usize = 0;
- defer for (others[0..nothers]) |*o| o.deinit();
- // A capture is a delta against the previous one of its terminal's.
- var prevs: [4]Prev = @splat(.{});
// captures are deltas against the previous one of the same kind (see Prev)
var prev: Prev = .{};
@@ -758,46 +746,16 @@ fn runScript(arena: std.mem.Allocator, exe_z: [:0]const u8, script_path: []const
const cols = try std.fmt.parseInt(u16, tok.next() orelse return error.BadScript, 10);
var extra: [6]?[*:0]const u8 = @splat(null);
var nextra: usize = 0;
- var nviews: usize = 1;
while (tok.next()) |a| {
- if (std.mem.startsWith(u8, a, "views=")) {
- nviews = try std.fmt.parseInt(usize, a["views=".len..], 10);
- if (nviews < 1 or nviews > 4) return error.BadScript;
- continue;
- }
if (nextra >= extra.len) return error.BadScript;
extra[nextra] = (try arena.dupeSentinel(u8, a, 0)).ptr;
nextra += 1;
}
if (h) |*hp| hp.deinit(); // scripts may restart (e.g. dump then -l)
- for (others[0..nothers]) |*o| o.deinit();
- nothers = 0;
- cur = 0;
// a new process is a new screen: capture it whole, or its first
// frame would be a delta against a dead instance's rows
prev = .{};
- prevs = @splat(.{});
- var paths: std.ArrayList(u8) = .empty;
- while (nothers + 1 < nviews) : (nothers += 1) {
- var path: [64]u8 = undefined;
- others[nothers] = try eh.Harness.initView(gpa, rows, cols, &path);
- try paths.print(arena, "{s}{s}", .{ if (paths.items.len > 0) " " else "", std.mem.sliceTo(&path, 0) });
- }
- if (nothers > 0) _ = setenv("PARDES_TEST_VIEWS", try arena.dupeSentinel(u8, paths.items, 0), 1);
h = try eh.Harness.initArgv(gpa, exe_z.ptr, rows, cols, extra[0..nextra]);
- _ = unsetenv("PARDES_TEST_VIEWS");
- group[0] = &h.?;
- for (others[0..nothers], 1..) |*o, i| {
- o.pid = h.?.pid;
- group[i] = o;
- }
- for (group[0 .. nothers + 1]) |v| v.views = group[0 .. nothers + 1];
- } else if (std.mem.eql(u8, cmd, "view")) {
- const k = try std.fmt.parseInt(usize, tok.next() orelse return error.BadScript, 10);
- if (k < 1 or k > nothers + 1) return error.BadScript;
- prevs[cur] = prev;
- cur = k - 1;
- prev = prevs[cur];
} else if (std.mem.eql(u8, cmd, "snapfile")) {
const label = tok.next() orelse return error.BadScript;
const contents = try readFileAlloc(arena, tok.rest());
@@ -807,52 +765,51 @@ fn runScript(arena: std.mem.Allocator, exe_z: [:0]const u8, script_path: []const
try appendChunk(chunks, &chunk_len, try snapFile(arena, label, contents));
} else if (std.mem.eql(u8, cmd, "wait")) {
const ms = try std.fmt.parseInt(i64, tok.next() orelse return error.BadScript, 10);
- try on(&h, &group, nothers, cur).expectWaitFor(tok.rest(), ms, "snapshot wait");
+ try live(&h).expectWaitFor(tok.rest(), ms, "snapshot wait");
} else if (std.mem.eql(u8, cmd, "settle")) {
- try on(&h, &group, nothers, cur).pump(try std.fmt.parseInt(i64, tok.next() orelse return error.BadScript, 10));
+ try live(&h).pump(try std.fmt.parseInt(i64, tok.next() orelse return error.BadScript, 10));
} else if (std.mem.eql(u8, cmd, "stable")) {
const quiet = try std.fmt.parseInt(i64, tok.next() orelse return error.BadScript, 10);
const timeout = try std.fmt.parseInt(i64, tok.next() orelse return error.BadScript, 10);
- try waitStable(on(&h, &group, nothers, cur), quiet, timeout);
+ try waitStable(live(&h), quiet, timeout);
} else if (std.mem.eql(u8, cmd, "text")) {
- try on(&h, &group, nothers, cur).send(tok.rest());
+ try live(&h).send(tok.rest());
} else if (std.mem.eql(u8, cmd, "send")) {
- try on(&h, &group, nothers, cur).send(try unescape(arena, tok.rest()));
+ try live(&h).send(try unescape(arena, tok.rest()));
} else if (std.mem.eql(u8, cmd, "key")) {
- while (tok.next()) |name| try on(&h, &group, nothers, cur).send(keyBytes(name) orelse return error.BadKey);
+ while (tok.next()) |name| try live(&h).send(keyBytes(name) orelse return error.BadKey);
} else if (std.mem.eql(u8, cmd, "press") or std.mem.eql(u8, cmd, "release") or std.mem.eql(u8, cmd, "drag")) {
const btn = buttonCode(tok.next() orelse return error.BadScript) orelse return error.BadScript;
const col_spec = tok.next() orelse return error.BadScript;
const row = try std.fmt.parseInt(u16, tok.next() orelse return error.BadScript, 10);
- const col = try resolveCol(on(&h, &group, nothers, cur), col_spec, row);
+ const col = try resolveCol(live(&h), col_spec, row);
const b: u16 = if (std.mem.eql(u8, cmd, "drag")) btn + 32 else btn;
const fin: u8 = if (std.mem.eql(u8, cmd, "release")) 'm' else 'M';
- try on(&h, &group, nothers, cur).send(try std.fmt.allocPrint(arena, "\x1b[<{d};{d};{d}{c}", .{ b, col, row, fin }));
+ try live(&h).send(try std.fmt.allocPrint(arena, "\x1b[<{d};{d};{d}{c}", .{ b, col, row, fin }));
} else if (std.mem.eql(u8, cmd, "motion")) {
const col_spec = tok.next() orelse return error.BadScript;
const row = try std.fmt.parseInt(u16, tok.next() orelse return error.BadScript, 10);
- const col = try resolveCol(on(&h, &group, nothers, cur), col_spec, row);
- try on(&h, &group, nothers, cur).send(try std.fmt.allocPrint(arena, "\x1b[<35;{d};{d}M", .{ col, row }));
+ const col = try resolveCol(live(&h), col_spec, row);
+ try live(&h).send(try std.fmt.allocPrint(arena, "\x1b[<35;{d};{d}M", .{ col, row }));
} else if (std.mem.eql(u8, cmd, "wheel")) {
const dir = tok.next() orelse return error.BadScript;
const b: u16 = if (std.mem.eql(u8, dir, "up")) 64 else 65;
const col_spec = tok.next() orelse return error.BadScript;
const row = try std.fmt.parseInt(u16, tok.next() orelse return error.BadScript, 10);
- const col = try resolveCol(on(&h, &group, nothers, cur), col_spec, row);
- try on(&h, &group, nothers, cur).send(try std.fmt.allocPrint(arena, "\x1b[<{d};{d};{d}M", .{ b, col, row }));
+ const col = try resolveCol(live(&h), col_spec, row);
+ try live(&h).send(try std.fmt.allocPrint(arena, "\x1b[<{d};{d};{d}M", .{ b, col, row }));
} else if (std.mem.eql(u8, cmd, "resize")) {
const rows = try std.fmt.parseInt(u16, tok.next() orelse return error.BadScript, 10);
const cols = try std.fmt.parseInt(u16, tok.next() orelse return error.BadScript, 10);
- try on(&h, &group, nothers, cur).resize(rows, cols);
+ try live(&h).resize(rows, cols);
// Another view's terminal is no one's controlling one: the app
// is told it changed, as a stub tells it of its own.
- if (cur > 0) std.posix.kill(live(&h).pid, std.posix.SIG.WINCH) catch {};
} else if (std.mem.eql(u8, cmd, "snap")) {
- try appendChunk(chunks, &chunk_len, try snapText(arena, on(&h, &group, nothers, cur), tok.rest(), &prev));
+ try appendChunk(chunks, &chunk_len, try snapText(arena, live(&h), tok.rest(), &prev));
} else if (std.mem.eql(u8, cmd, "snapstyle")) {
- try appendChunk(chunks, &chunk_len, try snapStyle(arena, on(&h, &group, nothers, cur), tok.rest(), &prev));
+ try appendChunk(chunks, &chunk_len, try snapStyle(arena, live(&h), tok.rest(), &prev));
} else if (std.mem.eql(u8, cmd, "snap9p")) {
- try appendChunk(chunks, &chunk_len, try snap9p(arena, on(&h, &group, nothers, cur), tok.rest(), &prev));
+ try appendChunk(chunks, &chunk_len, try snap9p(arena, live(&h), tok.rest(), &prev));
} else {
std.debug.print("unknown command {s}\n", .{cmd});
return error.BadScript;
@@ -967,12 +924,6 @@ fn snapFile(arena: std.mem.Allocator, label: []const u8, contents: []const u8) !
}
/// The terminal the script drives now (`view`).
-fn on(h: *?eh.Harness, group: *[4]*eh.Harness, nothers: usize, cur: usize) *eh.Harness {
- const app = live(h);
- if (cur == 0 or cur > nothers) return app;
- return group[cur];
-}
-
fn live(h: *?eh.Harness) *eh.Harness {
if (h.*) |*v| return v;
fatal("script used the app before `start`", .{});
@@ -1010,7 +961,7 @@ fn waitStable(h: *eh.Harness, quiet: i64, timeout: i64) !void {
// and nothing in its process tree is runnable. Held across two probes,
// because a pane's shell can write and sleep a scheduler tick before
// the app wakes to read it.
- if (since >= probe_after_ms and h.pendingAll() == 0 and treeAsleep(h.pid)) {
+ if (since >= probe_after_ms and h.pending() == 0 and treeAsleep(h.pid)) {
if (asleep_since == 0) {
asleep_since = now;
} else if (now - asleep_since >= probe_hold_ms) {
diff --git a/test/snapshots/views-pan.golden b/test/snapshots/views-pan.golden
deleted file mode 100644
index e2c6186b..00000000
--- a/test/snapshots/views-pan.golden
+++ /dev/null
@@ -1,52 +0,0 @@
-== snap tall grid=80x24 cursor=4,16
-| Newcol Joincol Find Grep Help Changelog Tutor Dump Themes Config Debug Exit
-| New Term Find Grep Joincol Delcol
-|$ /tmp/pardes-snap/views-pan/cwd Term+bash Save Mode Filter Collapse Del
-| 18
-| 19
-| 20
-| 21
-| 22
-| 23
-| 24
-| 25
-| 26
-| 27
-| 28
-| 29
-| 30
-| $
-| /tmp/pardes-snap/views-pan/cwd/+New Save Term Collapse Del
-| 1
-== snap short-pans grid=60x12 cursor=4,8
-| Newcol Joincol Find Grep Help Changelog Tutor Dump Themes
-| New Term Find Grep Joincol Delcol
-|$ /tmp/pardes-snap/views-pan/cwd Term+bash Save Mode Filter
-| Collapse Del
-|↑ 27
-| 28
-| 29
-| 30
-| $
-| /tmp/pardes-snap/views-pan/cwd/+New Save Term Collapse Del
-| 1
-== snap short-typed grid=60x12 cursor=4,8
-|4: 29
-|5: 30
-|6: $ echo typed-in-short
-|7: typed-in-short
-== snap tall-sees grid=80x24 cursor=4,7
-|3: 29
-|4: 30
-|5: $ echo typed-in-short
-|6: typed-in-short
-|7: $
-|8:
-|9:
-|10:
-|11:
-|12:
-|13:
-|14:
-|15:
-|16:
diff --git a/test/snapshots/views-pan.snap b/test/snapshots/views-pan.snap
deleted file mode 100644
index 3ba1ac5b..00000000
--- a/test/snapshots/views-pan.snap
+++ /dev/null
@@ -1,27 +0,0 @@
-# A terminal shown in a view shorter than it (src/views.zig): sized for the
-# tall view that typed into it, the short one passes over its top rows so
-# its cursor and prompt stay in sight, an arrow in the gutter saying rows
-# are above.
-config Verbose off
-start 24 80 views=2
-wait 8000 $
-stable 700 20000
-view 2
-resize 12 60
-stable 500 10000
-view 1
-text seq 1 30
-key enter
-wait 8000 30
-stable 500 10000
-snap tall
-view 2
-stable 500 10000
-snap short-pans
-text echo typed-in-short
-key enter
-stable 500 10000
-snap short-typed
-view 1
-stable 500 10000
-snap tall-sees
diff --git a/test/snapshots/views-term.golden b/test/snapshots/views-term.golden
deleted file mode 100644
index 3ece1f10..00000000
--- a/test/snapshots/views-term.golden
+++ /dev/null
@@ -1,46 +0,0 @@
-== snap small grid=50x14 cursor=4,4
-| Newcol Joincol Find Grep Help Changelog Tutor Du
-| New Term Find Grep Joincol Delcol
-|$ /tmp/pardes-snap/views-term/cwd Term+bash Save M
-| ode Filter Collapse Del
-| $
-|
-|
-|
-|
-|
-| /tmp/pardes-snap/views-term/cwd/+New Save Term C
-| ollapse Del
-| 1
-== snap big grid=80x24 cursor=4,5
-| Newcol Joincol Find Grep Help Changelog Tutor Dump Themes Config Debug Exit
-| New Term Find Grep Joincol Delcol
-|$ /tmp/pardes-snap/views-term/cwd Term+bash Save Mode Filter Collapse Del
-| $ echo from-the-big-one
-| from-the-big-one
-| $
-|
-|
-|
-|
-|
-|
-|
-|
-|
-|
-|
-| /tmp/pardes-snap/views-term/cwd/+New Save Term Collapse Del
-| 1
-== snap small-sees grid=50x14 cursor=4,6
-|4: $ echo from-the-big-one
-|5: from-the-big-one
-|6: $
-== snap small-typed grid=50x14 cursor=4,8
-|6: $ echo from-the-small-one
-|7: from-the-small-one
-|8: $
-== snap big-sees grid=80x24 cursor=4,7
-|5: $ echo from-the-small-one
-|6: from-the-small-one
-|7: $
diff --git a/test/snapshots/views-term.snap b/test/snapshots/views-term.snap
deleted file mode 100644
index bbd1c368..00000000
--- a/test/snapshots/views-term.snap
+++ /dev/null
@@ -1,27 +0,0 @@
-# A terminal shown in two views at two sizes (src/views.zig): it takes the
-# size of the view that typed into it last; the other shows it at that size.
-config Verbose off
-start 24 80 views=2
-wait 8000 $
-stable 700 20000
-view 2
-resize 14 50
-stable 500 10000
-snap small
-# Typed in the big view: sized for it, shown so in the small one.
-view 1
-text echo from-the-big-one
-key enter
-stable 500 10000
-snap big
-view 2
-stable 500 10000
-snap small-sees
-# Typed in the small view: sized for it now, the big one shows it so.
-text echo from-the-small-one
-key enter
-stable 500 10000
-snap small-typed
-view 1
-stable 500 10000
-snap big-sees
diff --git a/test/snapshots/views.golden b/test/snapshots/views.golden
deleted file mode 100644
index 14120f39..00000000
--- a/test/snapshots/views.golden
+++ /dev/null
@@ -1,123 +0,0 @@
-== snap one grid=80x24 cursor=7,3
-| Newcol Joincol Find Grep Help Changelog Tutor Dump Themes Config Debug Exit
-| New Term Find Grep Joincol Delcol
-| /tmp/pardes-snap/views/cwd/v.txt Save Term Collapse Del
-| 1 line 1
-| 2 line 2
-| 3 line 3
-| 4 line 4
-| 5 line 5
-| 6 line 6
-| 7 line 7
-| 8 line 8
-| 9 line 9
-| 10 line 10
-| 11 line 11
-| 12 line 12
-| 13 line 13
-| 14 line 14
-| 15 line 15
-| 16 line 16
-| 17 line 17
-| 18 line 18
-| 19 line 19
-| 20 line 20
-| 21 line 21
-== snap two grid=80x24 cursor=7,3
-| Newcol Joincol Find Grep Help Changelog Tutor Dump Themes Config Debug Exit
-| New Term Find Grep Joincol Delcol
-| /tmp/pardes-snap/views/cwd/v.txt Save Term Collapse Del
-| 1 line 1
-| 2 line 2
-| 3 line 3
-| 4 line 4
-| 5 line 5
-| 6 line 6
-| 7 line 7
-| 8 line 8
-| 9 line 9
-| 10 line 10
-| 11 line 11
-| 12 line 12
-| 13 line 13
-| 14 line 14
-| 15 line 15
-| 16 line 16
-| 17 line 17
-| 18 line 18
-| 19 line 19
-| 20 line 20
-| 21 line 21
-== snap one-edit grid=80x24 cursor=15,3
-|2: */tmp/pardes-snap/views/cwd/v.txt Save Term Collapse Del
-|3: 1 EDIT-ONEline 1
-== snap two-sees grid=80x24 cursor=7,3
-|2: */tmp/pardes-snap/views/cwd/v.txt Save Term Collapse Del
-|3: 1 EDIT-ONEline 1
-== snap two-down grid=80x24 cursor=7,6
-|3: 22 line 22
-|4: 23 line 23
-|5: 24 line 24
-|6: 25 line 25
-|7: 26 line 26
-|8: 27 line 27
-|9: 28 line 28
-|10: 29 line 29
-|11: 30 line 30
-|12: 31 line 31
-|13: 32 line 32
-|14: 33 line 33
-|15: 34 line 34
-|16: 35 line 35
-|17: 36 line 36
-|18: 37 line 37
-|19: 38 line 38
-|20: 39 line 39
-|21: 40 line 40
-|22: 41 line 41
-|23: 42 line 42
-== snap one-top grid=80x24 cursor=15,3
-== snap two-put grid=80x24 cursor=21,7
-|7: 26 EDIT-ONEline 1
-|8: 27 line 26
-|9: 28 line 27
-|10: 29 line 28
-|11: 30 line 29
-|12: 31 line 30
-|13: 32 line 31
-|14: 33 line 32
-|15: 34 line 33
-|16: 35 line 34
-|17: 36 line 35
-|18: 37 line 36
-|19: 38 line 37
-|20: 39 line 38
-|21: 40 line 39
-|22: 41 line 40
-|23: 42 line 41
-== snap two-col grid=80x24 cursor=42,1
-|1: New Term Find Grep Joincol Delcol New Term Find Grep Joincol Delcol
-|2: */tmp/pardes-snap/views/cwd/v.txt Save
-|3: Term Collapse Del
-|4: 22 line 22
-|5: 23 line 23
-|6: 24 line 24
-|7: 25 line 25
-|8: 26 EDIT-ONEline 1
-|9: 27 line 26
-|10: 28 line 27
-|11: 29 line 28
-|12: 30 line 29
-|13: 31 line 30
-|14: 32 line 31
-|15: 33 line 32
-|16: 34 line 33
-|17: 35 line 34
-|18: 36 line 35
-|19: 37 line 36
-|20: 38 line 37
-|21: 39 line 38
-|22: 40 line 39
-|23: 41 line 40
-== snap one-col grid=80x24 cursor=21,3
-== snap one-after grid=80x24 cursor=13,4
diff --git a/test/snapshots/views.snap b/test/snapshots/views.snap
deleted file mode 100644
index eba26bae..00000000
--- a/test/snapshots/views.snap
+++ /dev/null
@@ -1,57 +0,0 @@
-# Two terminals on one session, each a view of it (src/views.zig): each its
-# own layout, focus, cursor and scroll over the same panes. An edit typed in
-# one is in the other; a line yanked in one is put in the other (registers
-# are the session's); Newcol in one leaves the other's columns; Detach in
-# one lets that terminal go and leaves the other drawing.
-config Verbose off
-lines v.txt 120
-start 24 80 views=2 v.txt
-wait 8000 line 1
-stable 500 10000
-snap one
-view 2
-wait 8000 line 1
-stable 500 10000
-snap two
-# Typed in view 1: in view 2 too.
-view 1
-key i
-text EDIT-ONE
-key esc
-settle 100
-stable 400 8000
-snap one-edit
-view 2
-stable 400 8000
-snap two-sees
-# Scrolled in view 2: view 1 stays at the top.
-key pgdn
-stable 400 8000
-snap two-down
-view 1
-stable 400 8000
-snap one-top
-# Yanked in view 1, put in view 2.
-key x y
-stable 400 8000
-view 2
-key p
-stable 400 8000
-snap two-put
-# A column in view 2 only.
-key space
-text cn
-stable 400 8000
-snap two-col
-view 1
-stable 400 8000
-snap one-col
-# Detached in view 2: its terminal let go, view 1 drawing on.
-view 2
-key space
-text sD
-stable 400 8000
-view 1
-key j
-stable 400 8000
-snap one-after