Repository navigation
test: use per-run temp roots in update-cli and migrate suites - #125171
Conversation
update-cli.test.ts used a fixed /tmp/openclaw-update-tests root with deterministic case-dir names; some cases write real fixture files there and cleanup rm -rf's them, so concurrent runs on one machine (CI shards, sibling checkouts) deleted each other's live fixtures — observed as 34 spurious failures on PR #124997 run 31992421445. migrate.test.ts had the same shape via a fixed mocked resolveStateDir root rm -rf'd in beforeEach/afterEach. Both suites now use per-run mkdtemp roots, realpath'd for the macOS /var -> /private/var symlink, removed on suite exit.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 17, 2026, 5:06 AM ET / 09:06 UTC. ClawSweeper reviewWhat this changesThe branch gives the update CLI and migration command test suites unique per-run temporary roots so concurrent runs cannot recursively delete each other’s real fixture files. Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readinessKeep open: this maintainer-owned, test-only PR addresses a current shared-temp-root defect with a focused owner-boundary repair. Likely related: steipete (recent contributor to both affected test surfaces). Priority: P3 Review scores
Verification
How this fits togetherThe update CLI suite creates temporary package entrypoints for post-update handoff tests, while the migrate command suite creates report directories under its mocked state root. Both clean up those paths, so a per-run namespace prevents cross-process cleanup from affecting another suite instance. flowchart LR
A[Concurrent test process] --> B[Unique temporary root]
B --> C[Fixture or migration report files]
C --> D[Suite cleanup]
D --> E[Only this process's files removed]
Decision needed
Why: The PR has a protected maintainer signal, so automated cleanup must not close or land it without an explicit maintainer decision. Before merge
Agent review detailsSecurityNone. PR surfaceTests +18. Total +18 across 2 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the per-run realpath-resolved roots, rebase or refresh against current main, and land once the exact merged head remains green. Do we have a high-confidence way to reproduce the issue? Yes — current main has deterministic roots that feed real file writes and recursive cleanup, and the PR body records concurrent-run failure before the change. This review did not execute the suite because the checkout is read-only. Is this the best way to solve the issue? Yes — allocating unique roots where the suites own fixture setup prevents the destructive cross-run interaction without changing production behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e8c761ea7080. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Land-ready verification for source head
Best-fix verdict: this belongs in fixture ownership at the two test harnesses; serializing CI, weakening cleanup, or changing production code would only mask the race. |
|
Merged via squash.
|
…aw#125171) update-cli.test.ts used a fixed /tmp/openclaw-update-tests root with deterministic case-dir names; some cases write real fixture files there and cleanup rm -rf's them, so concurrent runs on one machine (CI shards, sibling checkouts) deleted each other's live fixtures — observed as 34 spurious failures on PR openclaw#124997 run 31992421445. migrate.test.ts had the same shape via a fixed mocked resolveStateDir root rm -rf'd in beforeEach/afterEach. Both suites now use per-run mkdtemp roots, realpath'd for the macOS /var -> /private/var symlink, removed on suite exit.
What Problem This Solves
src/cli/update-cli.test.tsanchored all its fixture paths to a fixed shared root (/tmp/openclaw-update-tests) with deterministic per-case names (openclaw-updated-root-6, ...). The suite's comment claimed all I/O was mocked, butsetupUpdatedRootRefreshreally writes entrypoint files andpackage.jsonunder those paths and registers them for recursivefs.rmcleanup. Two concurrent runs on one machine (CI shards, sibling checkouts) generate byte-identical paths, so one run's cleanup deletes the other run's live fixtures mid-test — observed as 34 spurious failures on PR #124997 run 31992421445 while the same head was green locally.A sibling sweep found one more instance of the same destructive class:
src/commands/migrate.test.tsmocksresolveStateDirto a fixed/tmp/openclaw-migrate-command-test, the apply flow reallymkdirs report dirs under it, and bothbeforeEachandafterEachrecursivelyrmthe shared root.Why This Change Was Made
Repo test rules require per-run
mkdtemp+fs.realpath'd roots. Both suites now derive their root frommkdtempunderos.tmpdir(), realpath'd for the macOS/var -> /private/varsymlink, and remove it on suite exit. The eleven inline/tmp/openclaw-update-tests/...profile literals in update-cli were rebased onto the per-run root so the whole suite shares one unique namespace. In migrate.test.ts the unique root is computed in an asyncvi.hoistedblock because thevi.mockfactory runs during static imports.User Impact
None at runtime — test-only change. CI shards and sibling checkouts sharing one machine no longer produce spurious cross-run failures in these suites.
Evidence
rm -rf /tmp/openclaw-update-testsevery 50ms) fails 3 tests; the fixed suite under identical interference passes 240/240.node scripts/check-changed.mjs -- <both files>exit 0 (core-test typecheck shards, lint, deadcode, temp-dir report: no new warnings); oxfmt/oxlint clean./tmpliterals elsewhere are mock-only strings; two additive-only (non-destructive) fixed-mkdir cases inextensions/browserare flagged as a follow-up rather than expanding this diff.Production LOC: +0/-0 | Tests: +34/-16