From 513938c1cfb216a3bc4a3559cf7731b8e44a952f Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 6 Jul 2026 20:43:40 -0300 Subject: dumps: per-user data dir + timestamped names; Restore builtin loads a dump into the live session. dump.outPath resolves $PARDES_DUMP verbatim (the snapshot harness pins /tmp/pardes-dump.zon so dump/load/restore goldens stay deterministic), else $XDG_DATA_HOME|~/.local/share /pardes/pardes-YYYYMMDD-HHMMSS.zon (dir mkdir-ed; wall clock via libc clock_gettime — std.time.timestamp is gone in 0.16). After write_dump the shell reports the written path back (core.setLastDump) and the topbar grows "Restore ": middle-clicking Restore reloads the last dump, and "Restore " executed anywhere takes the path as its first argument (onSelect prefix match). Core stays sans-IO: the builtin stashes restore_req; each shell consumes takeRestore() after drainEffects and swaps in initFromDump at the current screen size (pre-sized: dump panes never greet), tearing down the live ptys (tty: cancel reader + close + gen bump; gui: SIGKILL, the gen-guarded eof closes the old fds). Web ignores it. New restore.snap golden: KEEPME survives the restore, GONESOON echoed after Dump does not, the topbar word appears then resets. 29/29. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/snapshot.zig | 4 +++ test/snapshots/restore.golden | 62 +++++++++++++++++++++++++++++++++++++++++++ test/snapshots/restore.snap | 25 +++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 test/snapshots/restore.golden create mode 100644 test/snapshots/restore.snap (limited to 'test') diff --git a/test/snapshot.zig b/test/snapshot.zig index 10aa0c86..54ba0271 100644 --- a/test/snapshot.zig +++ b/test/snapshot.zig @@ -130,6 +130,10 @@ fn runScript(arena: std.mem.Allocator, exe_z: [:0]const u8, script_path: []const _ = setenv("HOME", try arena.dupeZ(u8, home), 1); _ = setenv("TERM", "xterm-256color", 1); _ = setenv("LC_ALL", "C", 1); + // pin the dump path: live runs use a timestamped file under the user data + // dir (dump.outPath), which would make the dump/load/restore goldens + // nondeterministic + _ = setenv("PARDES_DUMP", "/tmp/pardes-dump.zon", 1); if (chdirRc(try arena.dupeZ(u8, work)) < 0) return error.ChdirFailed; var out: std.ArrayList(u8) = .empty; diff --git a/test/snapshots/restore.golden b/test/snapshots/restore.golden new file mode 100644 index 00000000..6b8c4d7e --- /dev/null +++ b/test/snapshots/restore.golden @@ -0,0 +1,62 @@ +== snap dumped grid=100x30 cursor=4,5 +|Kill Newcol Tutor Debug Colors NextColor Dump Restore /tmp/pardes-dump.zon +| TTY /tmp/pardes-snap/restore/cwd Del +| $ ls +| $ echo KEEP''ME +| KEEPME +| $ +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +== snap restored grid=100x30 cursor=4,5 +|Kill Newcol Tutor Debug Colors NextColor Dump +| TTY /tmp/pardes-snap/restore/cwd Del +| $ ls +| $ echo KEEP''ME +| KEEPME +| $ +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| +| diff --git a/test/snapshots/restore.snap b/test/snapshots/restore.snap new file mode 100644 index 00000000..8a677877 --- /dev/null +++ b/test/snapshots/restore.snap @@ -0,0 +1,25 @@ +# Dump writes to the resolved dump path ($PARDES_DUMP here; a timestamped file +# under ~/.local/share/pardes in live runs) and the topbar grows Restore ; +# middle-click Restore loads that dump back into the live session: output on +# screen at Dump time survives (pty history), later output does not +start 30 100 +wait 8000 Kill Newcol +stable 700 20000 +key c-b +stable 600 8000 +text echo KEEP''ME +key enter +wait 8000 KEEPME +stable 700 10000 +press middle 42 1 +release middle 42 1 +stable 700 10000 +snap dumped +text echo GONE''SOON +key enter +wait 8000 GONESOON +stable 700 10000 +press middle 48 1 +release middle 48 1 +stable 900 15000 +snap restored -- cgit v1.3