summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/fs.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/fs.py b/test/fs.py
index 7401861b..db10f32d 100644
--- a/test/fs.py
+++ b/test/fs.py
@@ -1224,6 +1224,47 @@ def test(binary, quic=False):
cell[0] for cell in local.screen()['cells'])
assert client.read('/index') == before
+ # --wait (acme's E): a launch inside a pane lasts until the pane it
+ # opened is deleted, as an $EDITOR must; one on a file already open
+ # waits on that pane; a session that goes away ends it with 1.
+ with session(binary, root, 'wait') as (client, address):
+ status = dict(line.split(maxsplit=1) for line in client.read('/status').decode().splitlines())
+ env = {k: v for k, v in os.environ.items() if k != 'PARDES_FORWARD_LOOK'}
+ env.update(PARDES_9P=str(address), PARDES_PANE='1', PARDES_PID=status['pid'])
+ edited = root / 'wait edit.txt'
+ edited.write_bytes(b'edit me\n')
+
+ def serials():
+ return {int(row.split()[0]) for row in client.read('/index').splitlines()}
+
+ def launch(flag):
+ before = serials()
+ child = subprocess.Popen([binary, flag, str(edited)], cwd=root, env=env,
+ stdout=subprocess.DEVNULL, stderr=subprocess.PIPE)
+ deadline = time.monotonic() + 3
+ while child.poll() is None and not serials() - before and time.monotonic() < deadline:
+ time.sleep(.01)
+ return child
+
+ first = launch('--wait')
+ opened, = serials() - {1}
+ second = launch('-w')
+ time.sleep(.5)
+ assert first.poll() is None and second.poll() is None, (first.stderr.read(), second.stderr.read())
+ assert serials() == {1, opened}
+ client.write(f'/pane/{opened}/body', b'edited\n', truncate=True)
+ execute(client, opened, 'Save')
+ client.remove(f'/pane/{opened}')
+ deleted = time.monotonic()
+ assert first.wait(timeout=5) == 0
+ # Woken by the `del` record, not a poll.
+ assert time.monotonic() - deleted < .05, time.monotonic() - deleted
+ assert second.wait(timeout=5) == 0
+ assert edited.read_bytes() == b'edited\n'
+ orphan = launch('--wait')
+ assert orphan.poll() is None
+ assert orphan.wait(timeout=5) == 1
+
for tty in [False, True]:
name = 'lsp-tty' if tty else 'lsp-detached'
with session(binary, root, name, tty=tty) as (client, _):