summaryrefslogtreecommitdiff
path: root/test/daemon.py
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-21 21:07:11 -0300
committerGabriel Schneider <[email protected]>2026-11-21 22:26:19 -0300
commit27874074025f88dd9e27ece82c352c4a7c35ab51 (patch)
tree0e680a929b2c6dbc900c6ae6cce22b6121f0415b /test/daemon.py
parent603692c8effa9bf85a5fddc1afd1ac896227c0d3 (diff)
downloadpardes-27874074025f88dd9e27ece82c352c4a7c35ab51.tar.gz
pardes-27874074025f88dd9e27ece82c352c4a7c35ab51.zip
pair: a window pair's session lists as a window's (P49): the `pardes` a window execs with `--paired=FD` is only ever a window's pair's session, so it registers as `gui` (runtime/main.zig), with no word at the join and the wire unchanged; test/daemon.py: window-clients lists it `listed_as('has a frontend', 'gui')` (under the variable a pair is listed by its kind alone, P36) and ends by name the window session a terminal client's Detach kept (P36) once its window closes; gui_pair's two `(tty)` for the window pair's session are `(gui)`; gui() reads the session's pid from its /status (the window's child as a pair) and asks that process whether it carries on; with the variable window-clients and gui pass on Debug and ReleaseSafe
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'test/daemon.py')
-rw-r--r--test/daemon.py27
1 files changed, 17 insertions, 10 deletions
diff --git a/test/daemon.py b/test/daemon.py
index d53e6182..aa06c76d 100644
--- a/test/daemon.py
+++ b/test/daemon.py
@@ -1867,15 +1867,19 @@ def window_clients(binary, gui_binary):
wait_for('the terminal client agrees with the window', lambda: agreed(root / 'b.check', nb), timeout=30)
wait_for('the window client agrees with the window', lambda: agreed(root / 'g.check', ng), timeout=30)
listed = sessions_listed(binary, env, root)
- assert [(n, k) for n, _, k in listed] == [('win', '(gui, has a frontend)')], listed
+ assert [(n, k) for n, _, k in listed] == [('win', listed_as('has a frontend', 'gui'))], listed
assert wg.close() == 0, wg.said()[-800:]
os.write(tb.master, b' sD')
wait_for('the terminal client let go', lambda: b.poll() is not None, timeout=10)
assert win.p.poll() is None
print(f'daemon: a window\'s session served a terminal\'s client and a window\'s, digests agreed '
- f'{len(checks(root / "b.check"))} and {len(checks(root / "g.check"))} times; --ps listed it alone, (gui, has a frontend)')
+ f'{len(checks(root / "b.check"))} and {len(checks(root / "g.check"))} times; --ps listed it alone, {listed_as("has a frontend", "gui")}')
win.close()
nine.socket.close()
+ # Under the variable the window is its session's client, and the
+ # terminal client's Detach kept that session (P36): ended by name.
+ if WITH_PAIR:
+ subprocess.run([binary, '--kill=win'], env=dict(env, PARDES_DAEMON='on'), cwd=root, capture_output=True, timeout=30)
wait_for('nothing left', lambda: not [p for p in processes(root) if alive(p)], timeout=15)
print('daemon: window clients\' sessions ended, nothing left behind')
finally:
@@ -2832,6 +2836,9 @@ def gui(binary, cycles):
wait_for('the window session', sock.exists, timeout=20)
client = Client(sock)
shell = terminals(client)[0]
+ # The window's own process, or under the variable its child (a
+ # pair: the window a client of it).
+ session = int(dict(line.split(maxsplit=1) for line in client.read('/status').decode().splitlines())['pid'])
assert not sized(client), 'a window owns the size'
# With its window: another window is a client of the session (its
# own process, its captures its own), listed by --ps; closed, it
@@ -2843,20 +2850,20 @@ def gui(binary, cycles):
# (a pair's own window is a client too: the second's pid is what goes)
wait_for('the client gone from --ps', lambda: f'client {second.pid} ' not in listed())
assert not sized(client), 'the first window stays'
- assert proc.poll() is None
+ assert alive(session)
print('daemon: a second window on a window session a client of it (in --ps), closed alone')
# Detached: the window closed, the process on; every attach after it
# a window client, the session detached still.
client.write(f'/pane/{shell}/exec', b'Detach\n')
wait_for('the window closed', lambda: sized(client))
- assert proc.poll() is None, 'the process carries on with no window'
- assert f'session win {proc.pid} {listed_as("detached", "gui")}' in listed(), listed()
+ assert alive(session), 'the session carries on with no window'
+ assert f'session win {session} {listed_as("detached", "gui")}' in listed(), listed()
baseline = None
for cycle in range(cycles):
w = Window(root, f'w{cycle}', [binary, 'attach'] if cycle % 2 else [binary, '--attach=win'], env)
wait_for('the client window drawn', lambda: (root / f'w{cycle}' / 'latest.ppm').exists(), timeout=20)
wait_for('the client in --ps', lambda: f'client {w.pid} ' in listed())
- assert f'session win {proc.pid} {listed_as("detached", "gui")}' in listed(), listed()
+ assert f'session win {session} {listed_as("detached", "gui")}' in listed(), listed()
now = (fds(proc.pid), len(processes(root)))
baseline = baseline or now
assert now == baseline, (cycle, now, baseline)
@@ -2873,14 +2880,14 @@ def gui(binary, cycles):
tty_attach.terminate()
tty_attach.wait(timeout=10)
term.close()
- assert proc.poll() is None
+ assert alive(session)
print('daemon: a terminal attached to a window session by name, as a client')
nobody = subprocess.run([binary, '--attach=nobody'], env=env, cwd=root, timeout=10,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
assert nobody.returncode == 1 and b"no session called 'nobody'" in nobody.stderr, nobody.stderr
# Detached and told to end: it ends.
client.write(f'/pane/{shell}/exec', b'Exit\n')
- proc.wait(timeout=10)
+ wait_for('the session ended', lambda: not alive(session))
client.socket.close()
wait_for('the daemon gone once idle', lambda: not [p for p in processes(root) if alive(p)], timeout=5)
print('daemon: window session ended, nothing left behind')
@@ -2936,7 +2943,7 @@ def gui_pair(gui_binary):
try:
w, nine, session, pane = started('gp', env)
- wait_for('the window listed its client', lambda: f'session gp {session} (tty)' in listed()
+ wait_for('the window listed its client', lambda: f'session gp {session} (gui)' in listed()
and f'client {w.pid} ' in listed())
w.keys(b'Ofrom-the-window\x1b')
wait_for('its keys in the session\'s text', lambda: b'from-the-window' in nine.read(f'/pane/{pane}/body'))
@@ -2954,7 +2961,7 @@ def gui_pair(gui_binary):
os.kill(w.pid, signal.SIGKILL)
w.p.wait(timeout=10)
wait_for('the client unlisted', lambda: f'client {w.pid} ' not in listed())
- assert alive(session) and f'session gl {session} (tty)' in listed(), listed()
+ assert alive(session) and f'session gl {session} (gui)' in listed(), listed()
nine.socket.close()
assert subprocess.run([binary, 'kill', 'gl'], env=env, capture_output=True, timeout=30).returncode == 0
wait_for('the session ended', lambda: not alive(session), timeout=30)