summaryrefslogtreecommitdiff
path: root/test/fs.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/fs.py')
-rw-r--r--test/fs.py28
1 files changed, 27 insertions, 1 deletions
diff --git a/test/fs.py b/test/fs.py
index 20a9bbff..977b3e45 100644
--- a/test/fs.py
+++ b/test/fs.py
@@ -161,7 +161,7 @@ def discovery(binary, embedded=False):
with session(binary, root, 'discovery') as (client, address):
top = client.list('/')
# A set: which files the root holds, not the order a listing gives.
- assert set(top) - {'src', 'shaders'} == {'README', 'index', 'status', 'focus', 'ctl', 'commands',
+ assert set(top) - {'src', 'shaders'} == {'README', 'index', 'status', 'focus', 'ctl', 'commands', 'recent',
'look', 'exec', 'log', 'screen', 'listeners', 'layout', 'tag', 'tagexec',
'pane', 'col', 'os'}, top
assert 'self' not in top and 'cons' not in top and 'new' not in top, top
@@ -539,6 +539,31 @@ def new_terminals_named_once(binary):
assert str(made[0]).encode() in b' '.join(r.split()[0] for r in client.read('/index').splitlines())
+def recent_survives_restart(binary):
+ """A file opened and closed is in /recent closed, and still is in the
+ next session: the list is kept under $XDG_STATE_HOME (here HOME's
+ .local/state) across restarts."""
+ with tempfile.TemporaryDirectory(prefix='pardes-recent-') as directory:
+ root = Path(directory)
+ kept = root / 'kept.txt'
+ kept.write_bytes(b'one\ntwo\n')
+ with session(binary, root, 'recent1') as (client, _):
+ serial = look(client, f'{kept}:2')
+ 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()
+ with session(binary, root, 'recent2') as (client, _):
+ listed = client.read('/recent').decode()
+ assert f'closed {kept}\n' in listed, listed
+ # Recent shows it, and a look at its row opens it again.
+ client.write('/pane/1/exec', b'Recent\n')
+ rows = int(client.read('/pane/1/exec').split()[-1])
+ row = next(r for r in client.read(f'/pane/{rows}/body').decode().splitlines() if r.startswith(f'{kept}:'))
+ client.write(f'/pane/{rows}/look', (row.split(' ')[0] + '\n').encode())
+ assert f'open {kept}\n' in client.read('/recent').decode()
+
+
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
@@ -803,6 +828,7 @@ def test(binary, quic=False):
unattended_messages_expire(binary)
new_terminals_named_once(binary)
workflow_canary(binary)
+ recent_survives_restart(binary)
python_repl_runs_one_line(binary)
signal_cleans_up(binary)
for options, message in [