Skip to content

test: order fake readiness and sweep helpers left by killed CLI calls - #290

Merged
ElbertePlinio merged 8 commits into
mainfrom
fix/282-288-fake-process-lifecycle
Oct 8, 2026
Merged

ElbertePlinio merged 8 commits into
mainfrom
fix/282-288-fake-process-lifecycle

Conversation

@ElbertePlinio

@ElbertePlinio ElbertePlinio commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

This PR audits test fakes for signals that arrive before their handlers exist (#282). It also makes the commands test cleanup stop helpers that outlive a killed CLI (#288). Test code only.

#282: I audited every listed fake. Only the fake Xvfb in integration.test.ts signalled readiness before it installed its handlers. It now creates its socket after process.on. The lock is still written first. The other fakes either wait for a ready signal written after the handler, or their tests do not depend on the handler. In session.test.ts, the spawn and pid checks in the reap-order test and three other multi-process tests now run inside the try. If one spawn fails, the finally still kills the fakes that started.

#288: a new test helper, env-process-sweep.ts, scans /proc for this user's processes whose environment holds the exact PICKFORGE_HOME=<home> entry. It SIGKILLs them one pid at a time, skips zombies and processes that change during the scan, and rescans for up to 2 s. Cleanup now drains CLI calls, runs session destroy --all with a 45 s limit, then sweeps. An Android destroy can take about 35 s, so the hook timeout went from 60 s to 90 s. runCli records every home it uses, so every commands test is covered. When no CLI call was force-killed and destroy succeeded, any process the sweep kills fails the test as "processes outlived session destroy", so a product leak stays visible. Three more multi-process tests in session.test.ts now spawn inside the try.

Closes #282
Closes #288

Requirement Verified by Scenario Result Evidence
#282 audit each listed fake Code audit proc, session, viewer, integration, devtools-mcp, viewer-fakes, browser-session, browser-command-process, watch, commands tests Only the fake Xvfb readiness needed a change; the reason for each other fake is in the worker report Worker log
#282 readiness where the handler matters Automated test, repeat runs Fake Xvfb reaping test under 24 busy loops on 16 cores 10 of 10 passed /tmp/exp288
#282 spawn checks inside the cleanup scope Automated test, repeat runs Reap-order test 25 runs; whole session.test.ts 10 runs under load 25 of 25 and 10 of 10 passed /tmp/exp288
#288 stop helpers left by a killed CLI Temporary experiment, unit tests Fake adb running sleep 300 during android install-apk; sweep tests for exact match, group member without the entry, empty value Before: helper survived. After: no process survived. Unit tests 15 of 15 under load /tmp/exp288
#288 bound session destroy --all Temporary experiment Fake adb hangs on emu kill, limit lowered to 1 s Destroy killed at the limit, then the sweep left nothing alive /tmp/exp288
Every commands test covered (review round 1) Temporary experiment Install-apk fake runs /usr/bin/sleep 300 in a test that never registered its home Before: CLI and helper survived. After: nothing survived Worker log
Leaks after a clean destroy stay visible (review round 1) Temporary experiment, repeat runs Detached sleep 60 left after a clean destroy; 3 more full runs of commands.test.ts Reported as outlived; 64 of 64 each run, no false failures Worker log
Repo checks lint, typecheck, build, PickCheck, coverage Final head b76ad9d All pass; 2968 tests passed, thresholds hold ~/Artifacts/pickforge-batch2-2026-10-07/290-cov-final.log

QA device pass: skipped. The change is test code only, so there is nothing to drive.

Spawn and check the reap-order fakes inside the try, so one failed
spawn no longer leaks the others. Move the same pid checks into the
cleanup scope in the other multi-process session tests. The fake Xvfb
now creates its socket only after it installs its stop handlers, so
readiness implies the handlers exist.

Refs #282
The product starts helpers such as adb in their own process groups, so
killing the CLI group missed them. Cleanup now bounds session destroy
--all, kills it on overrun, and then SIGKILLs every process of this user
whose environment holds the test's exact PICKFORGE_HOME.

Closes #288
runCli now records the first env for each PICKFORGE_HOME, so the drain,
bounded session destroy, and home sweep cover every commands test.
afterEach claims only homes under its own tmpDir. Fake adb tests no
longer leave the CLI or its helpers running after a timeout (#288).
@ElbertePlinio
ElbertePlinio merged commit f64211f into main Oct 8, 2026
10 checks passed
@ElbertePlinio
ElbertePlinio deleted the fix/282-288-fake-process-lifecycle branch October 8, 2026 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant