diff options
Diffstat (limited to 'test/fs.py')
| -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 [ |
