fix(tests): put the real modules back after the image tests mock them - #5605
FredAmartey wants to merge 1 commit into
Conversation
Five image test files replace modules with `mock.module` and never put them back: `z-fulfill`, `download-cap-default`, `loop`, `loop-reasoning-replay` and `z-handler-activation`. Bun keeps a `mock.module` override for the rest of the process, and `mock.restore()`, which four of them call in `afterAll`, does not undo it. Every file that runs after them in the same process gets the stubs. The stubs lack exports such as `createVideoBudget`, `pinnedHttpPost` and `imageFulfillmentTailSnapshot`, so later files fail on import, and the ones that keep the real exports still change behaviour: after `z-handler-activation`, every provider resolves to its fixture adapter. On dev, `bun test tests/images` has 49 failures in one process, and each of these files run ahead of the 125 other files that use the translator budget helper adds between 7 and 241. The `z-` prefix does not keep a file last. Bun runs a directory's files in the order the filesystem lists them, whatever order they are passed in. Each file now copies the real modules before stubbing them and puts the copies back in `afterAll`. It has to be a copy: `mock.module` rewrites the namespace object's bindings in place, so the namespace would hand back the stub.
|
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 (5)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe tests now capture real module exports before applying ChangesTest mock isolation
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The changed test cleanup addresses the intended mock leakage, and no actionable merge-blocking risk remains. 🚥 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. |
✅ READY
Review readiness checklist
✅ 4/4 boxes ticked. This pull request is already Ready for Review. |
리뷰 · 우선순위 68 / 80이 PR은 이미지 테스트 다섯 파일이 라인 - 라인 - “진짜” 복사 시점 — 라인 - 라인 - Draft / CI — 본문 checklist는 다 체크됐지만 PR은 아직 Draft입니다. CodeRabbit은 draft라 스킵했고, 호스트 hygiene·label·enforce-target 위주만 보입니다. 작성자 로컬 검증(쌍 검사, 라인 - 형제 PR — #5607은 이 PR 뒤에도 남는 메인테이너의 판단이 필요한 지점
너의 추천 원인·고침·검증이 한줄로 맞고, #5439류 “묶음으로만 실패”를 줄이는 데 바로 도움이 됩니다. Ready로 바꾼 뒤 호스트 CI(테스트 포함)만 확인하고 머지하는 쪽을 권합니다. 이 댓글은 grok-bot이 작성했습니다 |
…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
mock.moduleand never put them back.z-fulfillstubssrc/images/artifactsandsrc/images/xai-client,download-cap-defaultstubssrc/lib/pinned-httpandnode:dns/promises,loopandloop-reasoning-replaystubsrc/images/fulfillandsrc/web-search/progress-stream, andz-handler-activationstubssrc/server/adapter-resolve,src/images/loopandsrc/web-search/index. Bun keeps amock.moduleoverride for the rest of the process, andmock.restore(), which four of these files call inafterAll, does not reset it.createVideoBudget,pinnedHttpPost,imageFulfillmentTailSnapshot,MAX_ENCODED_BYTES_PER_IMAGE), so later files fail on import. The others change behaviour: afterz-handler-activation, every provider resolves to its fixture adapter. On dev,bun test tests/imagesgives 65 pass and 49 fail in one process, andloopis 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.z-handler-activation241,download-cap-default83,z-fulfill53,loop-reasoning-replay9 andloop7.z-prefix does not keep these files last. Bun runs a directory's files in the order the filesystem lists them, whatever order they are passed in, and on the macOS checkout this was measured onz-fulfill.test.tsruns first intests/images. In a two-file check, Bun 1.3.11 and 1.4.0 also ran the same pair in opposite orders.afterAll. It has to be a copy:mock.modulerewrites the namespace object's bindings in place, so the namespace would hand back the stub. No runtime code changes.artifacts-ssrf(node:dns/promises) andpinned-https-get(node:https) also leave mocks behind, but neither changes another file's result in any of the runs below, so they are left alone.Verification
Head
a54e23578on dev6d5d501a6, Bun 1.4.0 (thebundependency inpackage.json). The measurements below were taken at dev965a6e5b1. None of the 9 dev commits since then touchestests/images,src/imagesor the translator budget helper, and the twotests/imagesruns, the five files alone and the static checks were rerun on this head:tests/images: each mocking file run before each image file that comes after it, one pair per process. On untouched dev 12 of the 37 pairs change a result (z-fulfillbreaks 7 files,download-cap-defaultbreaks 5); with this change none does.bun test tests/imagesin one process: 65 pass, 49 fail on dev; 213 pass, 4 fail with this change. The 4 are a separate leak in the translator budget test helper, fixed in fix(tests): dispose test translator budgets in every file that creates them #5607; with both changes the directory gives 217 pass, 0 fail.bun test --isolate tests/images: 217 pass, 0 fail. The five changed files alone: 21, 2, 52, 1 and 7 pass.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. No failing batch contains an image file.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 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