fix(tests): dispose test translator budgets in every file that creates them - #5607
FredAmartey wants to merge 1 commit into
Conversation
…s them `tests/helpers/translator-budget.ts` cleaned up with a module-level `afterEach`. Bun evaluates a module once per process, and a hook registered while it loads belongs to the test file that imported it first, so in a shared process only that file disposed its budgets and reset the translator aggregate. Every later importer kept both for the rest of the run: `tests/images/loop.test.ts` counts live budgets and sees 8 instead of 1 when `gemini-inline.test.ts` imported the helper first. `createTestTranslatorBudget` now also registers the cleanup with `onTestFinished`, which belongs to the running test whatever file it is in. Budgets created outside a test keep the `afterEach` as their only cleanup. Under `--isolate`, where every file loads its own copy of the helper, the only change is a second cleanup that finds nothing left.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: lidge-jun/opencodex/.coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe translator budget test helper now uses shared cleanup for tracked budgets. It registers cleanup with ChangesTranslator budget cleanup
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The cleanup change is mergeable with no remaining actionable risk identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
✅ Deterministic PR hygiene checks passed. |
리뷰 · 우선순위 64 / 80이 PR은 테스트용 번역 예산(translator budget) 청소가, Bun을 라인 - 라인 - 라인 - 라인 - Draft / 호스트 CI — Draft라 CodeRabbit은 스킵했고, 지금 보이는 잡은 hygiene·label 통과와 resolve-pr pending 정도입니다. 작성자 로컬로는 메인테이너의 판단이 필요한 지점 빈 너의 추천 원인·고침·검증이 한줄로 맞고, #5439류 묶음 실패를 줄이는 데 바로 도움이 됩니다. Ready로 바꾼 뒤 호스트 CI(테스트 포함)만 확인하고 머지하는 쪽을 권합니다. 빈 catch 좁히기와 테스트 밖 경로 잔여 누수는 필수는 아니고, 원하면 후속 이슈로 남겨도 됩니다. 닫을 types/config 중복 PR은 없습니다. 이 댓글은 grok-bot이 작성했습니다 |
✅ READY
Review readiness checklist
✅ 4/4 boxes ticked. This pull request is already Ready for Review. |
…EADME inventory counts (#5672) * docs(devlog): triage the lane A tests-hygiene bundle * fix(tests): capture the real resolver before mocking adapter-resolve Carries #5482. Co-authored-by: Fred Amartey <43480311+FredAmartey@users.noreply.github.com> * fix(tests): dispose test translator budgets in every file that creates them Carries #5607. Co-authored-by: Fred Amartey <43480311+FredAmartey@users.noreply.github.com> * fix(tests): restore the sandbox home after every test file Carries #5570 (both PR commits, including the CodeRabbit ordering fix). Co-authored-by: Fred Amartey <43480311+FredAmartey@users.noreply.github.com> * fix(tests): put the real modules back after the image tests mock them Carries #5605. Folded review fix: each file restores only the module snapshots it actually captured, so a beforeAll that failed partway cannot install an empty module, and z-handler-activation restores its overrides in a finally block so a failed directory removal cannot leave them installed for later files in the process. Co-authored-by: Fred Amartey <43480311+FredAmartey@users.noreply.github.com> * fix(desktop): never restart the real desktop app from the test runner Carries #5630. restartCodexDesktopApp returns the skipped reason test_environment when the test preload armed OCX_TEST_HOME_GUARD and no execFile was injected, and the CLI reports that skip. Folded review fix: structure/runtime.md documents the guarded outcome next to the CLI restart scope it owns. Co-authored-by: terin <100397903+sh940701@users.noreply.github.com> * docs(readme): derive the memory inventory counts instead of restating them Carries #5340, rebuilt on dev after #5615 and #5638 so their README and locale prose stays intact. Folded review fixes: dev now registers 14 retained stores, and native_control_replay is pinned (evictOldest returns 0), so every page says 14 and names the one store the budget never evicts; the guard's header drops the numbers that had gone stale; readme/i18n-manifest.json carries the hash of the final README.md. Co-authored-by: codingbo <9621077+codingbooo@users.noreply.github.com> * docs(devlog): record the lane A delivery --------- Co-authored-by: Fred Amartey <43480311+FredAmartey@users.noreply.github.com> Co-authored-by: terin <100397903+sh940701@users.noreply.github.com> Co-authored-by: codingbo <9621077+codingbooo@users.noreply.github.com>
Summary
tests/helpers/translator-budget.tsdisposes the budgets it hands out, and resets the translator aggregate, from a module-levelafterEach. Bun evaluates a module once per process, and a hook registered while it loads belongs to the test file that imported it first. In a shared process only that file gets the cleanup. The other files that reach the helper (128 test files import it directly or throughpassthrough-key-url.ts) keep their budgets and the aggregate for the rest of the run.afterEachwhen it loads runs it after the first file's tests and never after the second's. Under--isolateeach file loads its own copy and gets its own hook, which is why CI does not see this.tests/images/loop.test.tsasserts the number of live budgets. Whengemini-inline.test.tsimported the helper first,loopsees 8 where it expects 1, and 4 of its tests fail.loopis one of the files Batched test runner cannot run on macOS, and one-process runs give batch-size-dependent failure counts #5439 lists as failing only in batches.createTestTranslatorBudgetnow also registers the cleanup withonTestFinished, which belongs to the running test whatever file it is in. It throws outside a test, so a budget created at module scope or inbeforeAllkeeps theafterEachas its only cleanup, as before. Under--isolatethe only change is a second cleanup that finds nothing left. No runtime code changes.Verification
Head
c5c586ad6on dev6d5d501a6, Bun 1.4.0 (thebundependency inpackage.json). The measurements below were taken at dev965a6e5b1. None of the 9 dev commits since then touches the helper,src/lib/translator-budget.tsortests/images, and thegemini-inlineandlooppair and the static checks were rerun on this head:bun test tests/images/gemini-inline.test.ts tests/images/loop.test.tsin one process gives 78 pass, 4 fail on untouched dev and 82 pass, 0 fail with this change.loopbudget failures are gone and nothing new fails. The other 9 fail the same way on dev, 7 of them import errors from the image-test mocks fixed in fix(tests): put the real modules back after the image tests mock them #5605.--isolate, the way CI runs them: 3431 pass, 0 fail.scripts/ci/run-bun-test-batches.shslices them (12 files per batch,bun test --isolate --timeout 60000,CI=true), run past failing batches because the script stops a shard at its first failure, with the four shards in parallel on one macOS machine: 28969 pass, 4 fail across 1506 files. None of the four files reaches the helper.codex-runtime.test.tsandopenai-provider-option-e2e.test.tsalso fail in their batches on untouched dev at the same base; the second is one of the tests [Bug]: four tests exceed their timeouts in the unsharded macOS control lane, first observed once the lane was able to finish #4997 tracks.codex-shim.test.tsandmacos-serial-lanes.test.tsfailed only under the four-shard load: their batches pass on this head and on dev when rerun on their own.bun run typecheck,bun run structure:check,bun run privacy:scanandgit diff --check: passed.Checklist
Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
Required local validation passed; commands, results, and any full-suite exception are documented.
I pushed my PR to the latest dev commit.
I resolved all correct Codex and CodeRabbit findings.
My PR is ready for review.
Summary by CodeRabbit