diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-06 03:20:04 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-06 04:13:33 -0300 |
| commit | 4c2125ecf47588d33f9894c1fdf2833d0512f3b4 (patch) | |
| tree | c76510fd390e20187554ea86a3fdabd2dfb65ca5 /test/daemon.py | |
| parent | d1d5d3cfb18841604bba2057eeb3598f729b4475 (diff) | |
| download | pardes-4c2125ecf47588d33f9894c1fdf2833d0512f3b4.tar.gz pardes-4c2125ecf47588d33f9894c1fdf2833d0512f3b4.zip | |
client #2, one frontend a session: the daemon answers `other <name>` for an attach to a session attached already (as it did for one of the other kind), so a second `pardes --attach` or `pardes-gui --attach` on this machine is a replica client through the replica socket, the path a remote one takes; a session tells the daemon its clients (SO_PEERCRED on each replica socket, at every join and leave) and `--ps` lists `client <pid> <command>` under it; the tty's per-terminal Screens (Screen.create/drop/destroy, primary, its stub and Killed slot), the Poster and its `from` input, the Gui's window-fields swap (window_fields, GuiWindow, copyWindow, freshWindow, follow, route, openAnotherWindow, closeView, windowsOpen, closeOtherWindows, resumeWindows), drawOthers and every harness's extra terminals (snapshot.zig's `start ... views=N` and `view <k>`, e2e_harness's initView and drainOthers, PARDES_TEST_VIEWS in both frontends, the GUI feed's `view;<k>`, the monkey's --views) go; the pump draws the one view this process shows (views.shown), through drawOne when a client's input was the last; an Upgrade from a build that kept a second terminal of its own lets it go (its stub told it is detached) and closes its view; deleted: views.snap, views-term.snap and views-pan.snap with their goldens (the in-process second terminal they drove is gone; views.zig's unit tests keep the per-view cursor, layout, register, sizing, closing and panning behaviour, test/replicas.zig and the soak the views of clients); the two views.zig tests that drew through drawOthers draw through drawOne; daemon.py's second terminal is a client listed by --ps, typed into in both terminals, detached from inside and closed; its second window a client listed by --ps and closed; the reference and next-daemon.md say so; no golden changes; gates: core-test 956/956 both, behaviour-test 248/248 both, unit-test 1487/1488 tui and 1530/1531 gui, pane-test 171/172 both, snap all 102 ok, process-test 0 of 37 failed on both, hxdiff 19 and hxparity 6 mismatches (the base's names), hxgolf 0, replicas, addon-test, gui-golden and monkey-gui 0 of 1 failed, daemon.py main, --window-clients and --gui ok, soak local pass (differ, mispred, view_bad, lost 0)
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/daemon.py')
| -rw-r--r-- | test/daemon.py | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/test/daemon.py b/test/daemon.py index f8ef9be4..c53405db 100644 --- a/test/daemon.py +++ b/test/daemon.py @@ -1139,9 +1139,11 @@ def main(binary, cycles): assert now == baseline, (cycle, now, baseline) print(f'daemon: {cycles} detach/attach cycles, fds/sockets/processes level: {baseline}') - # Another terminal while one is attached: a view of its own - # (src/views.zig), drawn beside the first. Detached from inside, its - # stub ends and the first draws on; closed outright, the same. + # Another terminal while one is attached: a replica client of the + # session (a session shows one frontend of its own), listed under + # it by --ps, drawn beside the first, typed into as the first is. + # Detached from inside, it ends and the first draws on; closed + # outright, the same. for how in ('detach', 'close'): # Bigger than the first: the shell, sized for the first (its # last typist), shows whole in it. @@ -1150,6 +1152,12 @@ def main(binary, cycles): started.append(stub2.pid) wait_for('the second terminal\'s first frame', lambda: b'\x1b[?1049h' in term2.text()) wait_for('the second terminal\'s view live', lambda: client.screen()['cols'] == 120) + listed = subprocess.run([binary, '--ps'], env=env, capture_output=True, timeout=30).stdout.decode() + assert f'client {stub2.pid} ' in listed, listed + os.write(term.master, f'echo one-typed-{how}\r'.encode()) + wait_for('the first terminal\'s keys in the shell', lambda: f'one-typed-{how}'.encode() in client.read(f'/pane/{shell}/body')) + os.write(term2.master, f'echo two-typed-{how}\r'.encode()) + wait_for('the second terminal\'s keys in the shell', lambda: f'two-typed-{how}'.encode() in client.read(f'/pane/{shell}/body')) seen = len(term.text()) run(client, shell, f'echo both-drawn-{how}\n'.encode()) wait_for('the first terminal drawn', lambda: f'both-drawn-{how}'.encode() in term.text()[seen:]) @@ -1158,20 +1166,20 @@ def main(binary, cycles): if how == 'detach': # Its view is the live one (its terminal spoke last). client.write(f'/pane/{shell}/exec', b'Detach\n') - assert stub2.wait(timeout=10) == 0, stub2.returncode - wait_for('the second stub says it detached', lambda: b'detached from \'work\'' in term2.text()) + stub2.wait(timeout=10) term2.close() else: term2.close() stub2.wait(timeout=10) wait_for('the first terminal\'s view live again', lambda: client.screen()['cols'] == 100) + wait_for('the client gone from --ps', lambda: 'client ' not in subprocess.run([binary, '--ps'], env=env, capture_output=True, timeout=30).stdout.decode()) seen = len(term.text()) run(client, shell, f'echo first-on-{how}\n'.encode()) wait_for('the first terminal drawn on', lambda: f'first-on-{how}'.encode() in term.text()[seen:]) assert stub.poll() is None, 'the first terminal stays attached' now = (fds(session), fds(daemon), len(list(root.iterdir())), len([p for p in processes(root) if alive(p)])) assert now[:3] == baseline[:3], (how, now, baseline) - print('daemon: a second terminal on an attached session drawn beside the first, then detached and closed; the first drew on') + print('daemon: a second terminal on an attached session a client of it (in --ps), both typed into and drawn, then detached and closed; the first drew on') # Killed outright: its shells live on, their masters the daemon's, # and a replica client of it hears so at once, in words (one froze @@ -1302,17 +1310,18 @@ def gui(binary, cycles): baseline = baseline or now assert now == baseline, (cycle, now, baseline) print(f'daemon: {cycles} window detach/attach cycles, fds/processes level: {baseline}') - # Attached already: another window, a view of its own (its test - # captures under view-1); Detach in it closes only it. - attach = subprocess.run([binary, '--attach=win'], env=env, cwd=root, timeout=10, - stdout=subprocess.PIPE, stderr=subprocess.PIPE) - assert attach.returncode == 0, attach.stderr - wait_for('the second window drawn', lambda: (root / 'caps' / 'view-1' / 'latest.ppm').exists()) - client.write(f'/pane/{shell}/exec', b'Detach\n') - time.sleep(.5) + # Attached already: another window is a replica client of the + # session (its own process, its captures its own), listed by --ps; + # closed, it ends alone. + second = Window(root, 'second', [binary, '--attach=win'], env) + wait_for('the second window drawn', lambda: (root / 'second' / 'latest.ppm').exists(), timeout=20) + listed = subprocess.run([binary, '--ps'], env=env, cwd=root, capture_output=True, timeout=30).stdout.decode() + assert f'client {second.pid} ' in listed, listed + second.close() + wait_for('the client gone from --ps', lambda: 'client ' not in subprocess.run([binary, '--ps'], env=env, cwd=root, capture_output=True, timeout=30).stdout.decode()) assert not sized(client), 'the first window stays' assert proc.poll() is None - print('daemon: a second window on an attached window session, detached alone') + print('daemon: a second window on an attached window session a client of it (in --ps), closed alone') # Another kind joins as a replica client: a terminal of the window's # session, by its name alone. A name nobody has is refused in words. client.write(f'/pane/{shell}/exec', b'Detach\n') |
