summaryrefslogtreecommitdiff
path: root/test/session.zig
diff options
context:
space:
mode:
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;