diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-24 13:47:11 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-24 15:43:44 -0300 |
| commit | f3405aaef8db79094b2741a9caaeaa5328ab6288 (patch) | |
| tree | 5130b95da1d545a5f669710feca9bfa4dfba1a98 /test | |
| parent | 9db48c4c8a9b2d239680a59d451cd8c1e290ff56 (diff) | |
| download | pardes-f3405aaef8db79094b2741a9caaeaa5328ab6288.tar.gz pardes-f3405aaef8db79094b2741a9caaeaa5328ab6288.zip | |
Store 2/3: one bounded store every window shares (Store.zig): Recent as records read on use, the panes a session closes kept as one-pane dumps; Panes lists them (closed), Enter or a look at @pN brings one back beside the pane that took its rows
An append-only log under $XDG_STATE_HOME/pardes/store, framed records with
a CRC, flock on store.lock (never blocking a step), a stat on use, garbage
passed over and compacted away by the next writer, compaction by rename,
100 MiB cap. dump.dumpPane/restorePane lifted out of dumpState/initDump;
layout.giveBack; Options.recent_path is store_path. Host calls yield one at
a time; /recent refreshes only when no step is out. Tests: two windows and a
busy lock, the cap, garbage/torn/partial records, a closed pane's reopen
with the layout invariant; fs.py: two live sessions over 9P.
Diffstat (limited to 'test')
| -rw-r--r-- | test/fs.py | 42 |
1 files changed, 41 insertions, 1 deletions
@@ -711,7 +711,7 @@ def recent_survives_restart(binary): assert f'open {kept}\n' in client.read('/recent').decode() client.write(f'/pane/{serial}/ctl', b'Del\n') assert f'closed {kept}\n' in client.read('/recent').decode(), client.read('/recent') - assert (root / '.local' / 'state' / 'pardes' / 'recent').exists() + assert (root / '.local' / 'state' / 'pardes' / 'store').exists() with session(binary, root, 'recent2') as (client, _): listed = client.read('/recent').decode() assert f'closed {kept}\n' in listed, listed @@ -726,6 +726,45 @@ def recent_survives_restart(binary): assert f'open {kept}\n' in client.read('/recent').decode() +def del_twice(client, serial): + """Del, and again when the first refused over unsaved text.""" + try: + client.write(f'/pane/{serial}/ctl', b'Del\n') + except OSError: + client.write(f'/pane/{serial}/ctl', b'Del\n') + + +def store_shared_between_windows(binary): + """Two windows share one store (Store.zig): a file opened in one is in + the other's /recent at its next read, with no restart; a pane Del'd in + one comes back where it was from a look at its @p serial there, its text + with it, and only there.""" + with tempfile.TemporaryDirectory(prefix='pardes-store-') as directory: + root = Path(directory) + shared = root / 'shared.txt' + shared.write_bytes(b'one\ntwo\nthree\n') + with session(binary, root, 'store1') as (one, _), session(binary, root, 'store2') as (two, _): + serial = look(one, f'{shared}:3') + assert f'open {shared}\n' in one.read('/recent').decode() + assert f'closed {shared}\n' in two.read('/recent').decode(), two.read('/recent') + one.write(f'/pane/{serial}/ctl', b'Del\n') + assert f'closed {shared}\n' in one.read('/recent').decode() + scratch = new_pane(one, b'kept across a Del\n') + del_twice(one, scratch) + assert str(scratch) not in [row.split()[0] for row in one.read('/index').decode().splitlines()] + back = look(one, f'@p{scratch}') + assert one.read(f'/pane/{back}/body') == b'kept across a Del\n' + # The other window's session closed no such pane. + source = new_pane(two, b'') + try: + two.write(f'/pane/{source}/look', f'@p{scratch}\n'.encode()) + except OSError: + pass + assert b'kept across a Del' not in b''.join(two.read(f'/pane/{row.split()[0]}/body') + for row in two.read('/index').decode().splitlines()) + assert (root / '.local' / 'state' / 'pardes' / 'store').exists() + + def workflow_canary(binary): """One session driven as the dogfood agents drive it, asserting the log and the read-backs at every step: the canary for the main paths (the @@ -1163,6 +1202,7 @@ def test(binary, quic=False): putall_answers_after_its_saves(binary) workflow_canary(binary) recent_survives_restart(binary) + store_shared_between_windows(binary) python_repl_runs_one_line(binary) signal_cleans_up(binary) for options, message in [ |
