summaryrefslogtreecommitdiff
path: root/test/e2e_harness.zig
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/e2e_harness.zig
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/e2e_harness.zig')
-rw-r--r--test/e2e_harness.zig62
1 files changed, 4 insertions, 58 deletions
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;