summaryrefslogtreecommitdiff
path: root/test/session.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-08 23:49:04 -0300
committerGabriel Schneider <[email protected]>2026-11-09 01:28:28 -0300
commit174e031985db910b4907ba324d6fd12c67898a5a (patch)
tree5bcb0dbc1dbab457fcf4a4b95572a1631bb3ade1 /test/session.zig
parent21277ffc6b08f458eb9a1210a3818e40b14293d2 (diff)
downloadpardes-174e031985db910b4907ba324d6fd12c67898a5a.tar.gz
pardes-174e031985db910b4907ba324d6fd12c67898a5a.zip
tests: monkey and replay are modes of the T1 runner and snapshot.zig goes: behaviour-test runs test/monkey9p.zig bare (its smoke), `-- --monkey <seeds>` drives an in-process session with test/monkey.zig's input (keys, leader bursts, the mouse, tiny resizes, over /kbdin, /mousein and Session.resize) hunting panics and hangs, `-- --replay` records each seed's sessions as a tape in memory and replays it (tape.replayBytes, replayMain's loop: three replicas and the dump), and `process-test -- --replay` records and replays the tty cases' real sessions as `zig build replay` did (with the addons it lacked, so images passes); the snap, snap-driver-test, monkey, monkey-test (it no longer compiled), replay and monkey-session steps, pardes-snap and build/snap.zig (now build/process.zig) go; checked: a counter outside the core bumped at the 40th update diverges every T1 seed and 89 of 103 old tapes, one bumped on terminal output diverges no T1 seed but 69 tty cases and 70 old tapes (why the tty replay stays), a panic on a window under 5x5 is found by the T1 monkey (seeds 1 8 17 20) and the old one (seed 13)
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/session.zig')
-rw-r--r--test/session.zig31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/session.zig b/test/session.zig
index b35d08ad..136d34d1 100644
--- a/test/session.zig
+++ b/test/session.zig
@@ -190,6 +190,37 @@ pub const Session = struct {
return .{ try std.fmt.parseInt(u32, it.next() orelse return error.NoRange, 10), try std.fmt.parseInt(u32, it.next() orelse return error.NoRange, 10) };
}
+ /// The window resized to `cols` by `rows`, as a terminal's SIGWINCH or
+ /// a window's resize tells its host.
+ pub fn resize(s: *Session, cols: u16, rows: u16) void {
+ pardesOf(s).update(.{ .resize = .{ .cols = cols, .rows = rows } });
+ s.drain();
+ }
+
+ /// Every session started from here on records what it consumes as a
+ /// tape in memory, as PARDES_RECORD has a real one record it
+ /// (src/tape.zig); `replayTape` replays it once the session is gone.
+ pub fn recordTape(gpa: std.mem.Allocator) !void {
+ const t = try gpa.create(pardes.tape.Tape);
+ t.* = pardes.tape.memory(gpa);
+ pardes.tape.on = t;
+ }
+
+ /// The tape `recordTape` started, replayed as `PARDES_REPLAY` replays a
+ /// real session's: into two replicas at different addresses and one
+ /// that never draws, every digest checked, and the session's dump at
+ /// its end loaded to its digest and dumped to its bytes again. False
+ /// when a replica diverged (said on stderr). After `deinit`.
+ pub fn replayTape(gpa: std.mem.Allocator) bool {
+ const t = pardes.tape.on orelse return true;
+ pardes.tape.on = null;
+ defer {
+ pardes.tape.release(t);
+ gpa.destroy(t);
+ }
+ return pardes.tape.replayBytes(gpa, t.buf.items, "session", true);
+ }
+
/// No frontend attached, as a detached session's daemon says.
pub fn detach(s: *Session) void {
pardesOf(s).unattended = true;