summaryrefslogtreecommitdiff
path: root/test/e2e_harness.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-20 19:02:34 -0300
committerGabriel Schneider <[email protected]>2026-11-20 19:02:34 -0300
commit486f347adeed5bac6aaabe8be34e6a69bf323a62 (patch)
treeda8b333b4033889aa2fd16ab7f5a4bef35b0401d /test/e2e_harness.zig
parent4053e62a2aabd794db9075d93ebe57eec3f432a6 (diff)
parent06f6c72583faf8256190a0ae195a8085e7cd7f32 (diff)
downloadpardes-486f347adeed5bac6aaabe8be34e6a69bf323a62.tar.gz
pardes-486f347adeed5bac6aaabe8be34e6a69bf323a62.zip
integration: six small faults on a hang-up as a close: pardes-faults-6 (a hang-up with no daemon kills the language servers' children; the daemon's reader hands a note under a lock; a retried Edit write answered from the listener's hold; the cursor hidden when a frame has no caret; syntax-test deleted and the grammar tiers' tests skipping; the tty harness's Esc after what came before is read) and pardes-merge41, merged without a textual conflict; tui core-test 874/1031 (157 skipped), shell-test 1073/1076, term-test 17/17, both soaks diverged 0, unequal 0, unlisted 0, the window builds; the coordinator's gate in the ledger (reorg/merge42)
Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'test/e2e_harness.zig')
-rw-r--r--test/e2e_harness.zig22
1 files changed, 20 insertions, 2 deletions
diff --git a/test/e2e_harness.zig b/test/e2e_harness.zig
index 26e942e7..9481166e 100644
--- a/test/e2e_harness.zig
+++ b/test/e2e_harness.zig
@@ -20,6 +20,7 @@ extern "c" fn openpty(
winp: ?*const posix.winsize,
) c_int;
extern "c" fn ttyname(fd: c_int) ?[*:0]const u8;
+extern "c" fn ptsname(fd: c_int) ?[*:0]const u8;
extern "c" fn execvp(file: [*:0]const u8, argv: [*:null]const ?[*:0]const u8) c_int;
extern "c" fn _exit(status: c_int) noreturn;
extern "c" fn unsetenv(name: [*:0]const u8) c_int;
@@ -251,6 +252,21 @@ pub const Harness = struct {
return if (n > 0) @intCast(n) else 0;
}
+ /// Bytes typed that the app has not read yet: its end's input queue
+ /// (the master's FIONREAD counts only what the app wrote).
+ pub fn unread(self: *Harness) usize {
+ const FIONREAD: c_int = switch (@import("builtin").os.tag) {
+ .linux => posix.T.FIONREAD,
+ else => 0x4004667f,
+ };
+ const fd = libc.open(ptsname(self.master) orelse return 0, .{ .ACCMODE = .RDWR, .NOCTTY = true, .CLOEXEC = true });
+ if (fd < 0) return 0;
+ defer _ = libc.close(fd);
+ var n: c_int = 0;
+ if (posix.system.ioctl(fd, FIONREAD, @intFromPtr(&n)) != 0) return 0;
+ return if (n > 0) @intCast(n) else 0;
+ }
+
/// Resize both the pty (SIGWINCH to the app) and our terminal (grid reflows
/// to the new size). Harness terminal first so it's ready for the app's
/// re-render at the new size.
@@ -333,11 +349,13 @@ pub const Harness = struct {
};
}
- /// The visual cursor position (viewport coords): { x, y }.
- pub fn cursor(self: *Harness) struct { x: u16, y: u16 } {
+ /// The visual cursor position (viewport coords): { x, y }, and whether
+ /// the app shows it (DECTCEM).
+ pub fn cursor(self: *Harness) struct { x: u16, y: u16, shown: bool } {
return .{
.x = self.term.screens.active.cursor.x,
.y = self.term.screens.active.cursor.y,
+ .shown = self.term.modes.get(.cursor_visible),
};
}