Repository navigation
Run PTY test children through one pty_io::run (#1942) - #1955
Conversation
Assisted-by: Claude Code:claude-opus-5-5
Seven PTY suites each hand-rolled the same openpty, spawn, answer, watchdog and collect runner, and the copies drifted: only two pinned TERM, only one could send a second answer, and the update notifier read with its own read_to_end thread. They now all go through pty_io::run (the binary, one answer) or pty_io::run_command (any hermetic command, extra env, several answers), which always pins TERM=xterm-256color. Assisted-by: Claude Code:claude-opus-5-5
The detached watchdog slept out its full timeout and then signalled the pid even after the child had exited, so it could hit a reused pid. It now waits on a channel that is dropped after wait(). Also correct the runner's doc (SIGHUP, the newline portable_pty writes on drop, which answers wait for [Y/n]) and the stale update_render note. Assisted-by: Claude Code:claude-opus-5-5
|
BugBot review Generated by Claude Code |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit e8cd2b5. Configure here.
Assisted-by: Claude Code:claude-opus-5-5
|
Ready for review at head
Generated by Claude Code |
Final review briefWhat it does: Replaces seven hand-rolled PTY test runners with one shared Risk: Low. Only tests change, in Look here:
Verified:
Changes I made: none. Open questions: none. When a human approves, this PR goes straight into the merge queue: auto-merge (squash) is armed. Generated by Claude Code |
Wenxin Jiang (Wenxin-Jiang)
left a comment
There was a problem hiding this comment.
[agent] Reviewed e8cd2b5c9e4590465c95e5e3fceef6a85f978f7a. Checked shared PTY spawn/answer/output handling, signal tests, timeouts and migrated prompt sequences. No major correctness issues found. Validation: source and regression-test review plus the available exact-head CI checks; no local test pass is claimed.
LLM Description written by Claude Code:claude-opus-5-5
Fixes #1942
Summary
Seven PTY suites each hand-rolled the same runner: open a pty, build the hermetic
CommandBuilder, spawn, answer the prompts, run a watchdog, collect. The copies had drifted. Onlyprompts_ttyandscan_ttypinnedTERM, onlyprompts_ttycould send a second answer, andupdate_notifier_e2eread through its ownread_to_endthread instead ofPtyOutput.interactive_prompts_e2e's 20-line doc still described a reader design that no copy used any more. Register row T52; living document Part 5 (tests).Changes (test-only)
tests/common/pty_io.rs:run(args, cwd, input, timeout) -> (code, output), for the binary with one answer;run_command(cmd, args, cwd, env, answers, timeout) -> PtyRun { code, signal, output }, for anyhermetic::pty_command(the staged update binary, theshSIGINT-ignored wrapper), with extra env and more than one answer.TERM=xterm-256color.interactive_prompts_e2e:run_in_pty,run_in_pty_bytesand the stale doc;prompts_tty:run_in_pty,run_in_pty_then,run_in_pty_raw,run_in_pty_innerand theSigintenum (the singleIgnoredcaller now builds itsshwrapper inline);scan_tty:run_in_pty,run_in_pty_with;remove_render,rollback_render:run_in_pty;update_render:run_in_pty_env;update_notifier_e2e:run_in_pty./code-review; every old copy had this).grep -rn openpty crates/socket-patch-cli/testsnow finds onlycommon/pty_io.rs.Red→green evidence:
run_commandskip every answer turns 14 of the 18 PTY tests red: 9 in theclibinary, plus theremove,rollbackandupdatetests. They fail by watchdog at 15 s, which also shows the cancellable watchdog still fires.get_interactive_dialoguer_enter_accepts_first_ranked_optionred.Diff: +172 / −567 across 8 test files, with 0 production lines.
Behavior change
None in the product. In the tests, the five suites that didn't pin
TERMnow run underxterm-256color. All 22 PTY tests pass locally withTERMunset in the parent: 11 incli, 4 inscan, 1 each inremoveandrollback, and 2 inupdate./code-review highChildKiller::kill), names the newline and EOF that portable_pty writes when the writer drops, and spells out which answers wait for[Y/n];mod common;update_render.runreturns a tuple whilerun_commandreturnsPtyRun. The tuple keeps the 20+ simple call sites one line each.envstays a parameter because the runner pinsTERMbefore the caller's env, which lets a caller override it.Risk
Low: test-only. It touches
cfg(unix)PTY suites, so it is exercised on the Linux and macOS legs.🤖 Generated with Claude Code
https://claude.ai/code/session_011f9aeRQMNJsvzmiHpXnUQt
Note
Low Risk
Test-only consolidation on cfg(unix) PTY suites; no production code paths touched.
Overview
Test-only refactor: seven Unix PTY suites each duplicated the same openpty → hermetic spawn → prompt-aware input → watchdog → collect flow. That logic now lives in
tests/common/pty_io.rsaspty_io::run(built binary, one string answer) andpty_io::run_command(customhermetic::pty_command, extra env, byte answers, optional multi-step replies, plusPtyRunwith exit signal for SIGINT cases).Call sites in
interactive_prompts_e2e,prompts_tty,scan_tty,remove_render,rollback_render,update_render, andupdate_notifier_e2edrop localrun_in_pty*helpers (~400 lines removed) and call the shared API instead.TERM=xterm-256coloris always set in the runner (previously only some suites did). Sequences like menu Enter then[Y/n]confirm useanswersrather than bespokerun_in_pty_then/ SIGINT wrapper enums.The timeout watchdog is cancelled after
child.wait()so a late kill cannot hit a reused PID—a bug present in every old copy.No product behavior changes; interactive PTY assertions are unchanged aside from consistent terminal typing in tests.
Reviewed by Cursor Bugbot for commit e8cd2b5. Configure here.
Generated by Claude Code