Skip to content

fix: kill timed-out hook/shell process trees (Windows hang) + flaky and Windows test fixes - #30

Merged
Amanbig merged 5 commits into
mainfrom
ci/fix-flaky-screen-and-windows-tests
Oct 31, 2026
Merged

Amanbig merged 5 commits into
mainfrom
ci/fix-flaky-screen-and-windows-tests

Conversation

@Amanbig

@Amanbig Amanbig commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner

Why

main has CI problems that were hidden by the matrix's fail-fast (the first failing job cancels the rest, so the Windows jobs were usually cancelled and never reported).

1. Flaky screen tests

tests/test_boxed_input.py: the virtual-terminal harness snapshotted after a fixed 0.15 s. On a slow runner one Ubuntu job snapshotted before the first frame was drawn and hit IndexError. This is what failed the docs-only PR #29. Fix: wait at least that long, then until the output stops changing, with a clear error if nothing renders.

2. Windows hooks tests

tests/test_hooks.py (from #5) used POSIX syntax (echo nope >&2; exit 2, sleep 5). cmd.exe has no ; separator or sleep, so two tests failed on every Windows job. Fix: run Python for the exit code, stderr and sleep.

3. A real bug the stricter timeout test exposed (Windows hang)

subprocess.run(cmd, shell=True, timeout=...) only kills the shell. On Windows the command's own process keeps running and keeps the output pipes open, so run() blocks until it exits anyway. Observed in CI: a hook with timeout=1 ran for 30 s. A stuck hook would freeze DevOrch, and tools/shell.py (timeout=120) has the identical flaw.

Fix: new utils/proc.run_shell starts the command in its own process group/session and kills the whole tree on timeout or Ctrl+C (taskkill /F /T on Windows, killpg elsewhere), then reaps. It keeps subprocess.run's contract (raises TimeoutExpired, stdin inherited unless input is given). Used by hooks and the shell tool.

Tests

  • tests/test_proc.py: output/exit code, stdin, cwd, UTF-8, prompt return on timeout, a grandchild is killed on timeout, Ctrl+C kills the child and propagates, shell tool timeout and formatting
  • Mutation check in memory: swapping the old subprocess.run behaviour back in makes the grandchild test fail
  • Suite passes locally (479); Linux and macOS jobs were green on the previous push

Not verified locally

I only run Linux. The Windows result of this PR's jobs is the real verification; the previous push already isolated the single remaining Windows failure to the timeout test, which this change targets.

Merge order

Merge this first; #28 and #29 then just need "Update branch".

The screen-test harness snapshotted after a fixed 0.15s, which is racy on a
slow CI runner: one job snapshotted before the first frame was drawn and
indexed into an empty screen. Wait at least that long, then until the output
has stopped changing, and fail with a clear message if nothing renders.
The hooks tests used POSIX shell syntax (echo x >&2; exit 2, sleep 5). In
cmd.exe there is no ; separator or sleep, so the hook never exited with 2 and
two tests failed on every Windows job. Run Python for the exit code, stderr
output and sleep instead, and assert the timeout test really stops the hook.
subprocess.run(shell=True, timeout=...) only kills the shell. On Windows the
command's own process kept running and held the output pipes open, so run()
blocked until it finished anyway: a hook with a 1 second timeout took 30
seconds, and the shell tool's 120 second limit had the same flaw. Add
utils.proc.run_shell, which starts the command in its own process group or
session and kills the whole tree on timeout or Ctrl+C, and use it for hooks
and the shell tool.
@Amanbig Amanbig changed the title ci: fix the flaky screen tests and the Windows hooks tests fix: kill timed-out hook/shell process trees (Windows hang) + flaky and Windows test fixes Oct 31, 2026
An unrelated DevOrch session run in this directory replaced the command
imports with 'from cli.commands import ask, edit, run', which imports modules
instead of the command functions, and that edit was swept into the previous
commit. Restore the original imports.
@Amanbig
Amanbig merged commit 817e074 into main Oct 31, 2026
10 of 14 checks passed
@Amanbig
Amanbig deleted the ci/fix-flaky-screen-and-windows-tests branch October 31, 2026 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant