Repository navigation
test: stop test runs from touching the real sessions directory, leaking Xvfb, and using live pids - #286
Merged
Conversation
The x11-prebind fallback test sets an empty PICKFORGE_HOME, so the state root falls back to os.homedir(). That reads the process HOME, not the env object, so each run left a desk-* permit directory and a takeover identity file in the real ~/.pickforge/lab/sessions. Point HOME at the test root for that case. Add a global setup guard that fails the run when the real sessions directory gains or loses entries. It only observes and never deletes. Closes #264.
A test that exceeds its timeout keeps running after vitest moves on. Its later session create then ran after afterEach had destroyed the sessions and deleted the registry, and the new Xvfb outlived the run with a recreated registry under the test temp dir. afterEach now closes the test's envs to new CLI calls, waits for running ones, destroys every session, and keeps the registry when a destroy fails. Closes #262.
The kill case waits on three fixed 1 s product budgets and took 4.5 s on an idle host, so the 5 s vitest default timed it out under concurrent suites. 32 parallel runs of the file timed it out every time before this change and passed every time after. Also create the temp root under the OS temp directory, so a killed worker no longer leaves .viewer-state-test-* in the checkout. Closes #263.
The home sessions guard compared top-level names only, so a rewritten session record or a new permit inside an existing session passed. It also ignored the legacy ~/.pickforge/picklab and ~/.picklab session roots that fallback resolution can write into. Snapshot every entry at any depth with its type, inode, size and mtime, and report added, removed and modified paths relative to the root. Watch the legacy roots too. PICKFORGE_TEST_ALLOW_REAL_HOME_CHANGES=1 turns the failure into a warning on a shared host where real sessions run during the tests.
afterEach removed the module-level tmpDir after an unbounded wait for running CLI calls. If a call outlived the hook timeout, the next test had already replaced tmpDir, and the resumed cleanup deleted the newer registry. Calls were also keyed by env object, so an env copy, as in the browser viewer watch test, was never closed or awaited. Capture the test's directory and envs at the start of cleanup. Key running and closed calls by PICKFORGE_HOME. Spawn each CLI in its own process group and keep the child, wait at most 20 s, SIGKILL the group of any survivor, then destroy all sessions and remove only this test's directory.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes four test-hygiene bugs. No product code changed.
packages/desktop-linux/test/x11-prebind.test.ts"uses PICKLAB fallback but gives an empty PICKFORGE_HOME precedence" passed{ PICKFORGE_HOME: "", HOME: root }. An emptyPICKFORGE_HOMEfalls back toos.homedir(), which reads the processHOME, so each run created adesk-*/permitsdirectory and an identity file in the real~/.pickforge/lab/sessions. The test now stubs the processHOMEand asserts the permit lands under its temp root. A new global setup,test/home-sessions-guard.ts, records the entry names of the real sessions directory (and$PICKFORGE_HOME/sessionswhen set) and fails the run if entries were added or removed. It only reads.vnc-rollback.test.ts(same problem, not listed in the issue).packages/cli/test/commands.test.tsafterEach now refuses new CLI calls for the test's envs, waits for running calls, runssession destroy --all, and keeps the registry and throws if a destroy fails, following test(desktop-linux): stop display, port and session collisions under load #256.os.tmpdir(). The kill case waits on three fixed 1 s product budgets, about 4.5 s idle, against Vitest's 5 s default; the "viewer teardown" block now has a 20 s timeout.HOMEfor one full runx11-prebind.test.tscreated entriesdesk-7829492dand the guard reported it; fixed test left nothing; guard unit tests (9)test/home-sessions-guard.test.ts~/.pickforge/lab/sessionsheld 335 entries before and after a full coverage runisPidAlivegets ESRCH; record checks need only an integer:104running with a live record; new code left nothing and refused the late createos.tmpdir()rootPICKFORGE_TEST_ALLOW_REAL_HOME_CHANGES=1downgrades it to a warningbun run lint,bun run typecheck,bun run build;GSK_RENDERER=cairo bun run test:coverageat 1fc4c24: 2910 passed, 6 skipped, thresholds held (87.91 / 82.85 / 88.32 / 88.86); PickCheck no new or worsened violationsThe guard has one local limit: a test run from a branch without the #264 fix, or real Pickforge sessions used on the same host during a run, change the watched directories and fail the run. Set
PICKFORGE_TEST_ALLOW_REAL_HOME_CHANGES=1to turn that into a warning. CI starts with an empty home and stays strict.QA pass skipped: test-only changes with nothing to drive.
Follow-ups filed: #285 (
pickforgeHomeignores the env object'sHOME), #288 (cleanup cannot stop helpers the CLI starts in their own process groups).Closes #261
Closes #262
Closes #263
Closes #264