Repository navigation
test(bundler): compile each outfile case in its own test - #37417
Conversation
"compile with relative outfile paths" ran three Bun.build compiles in one test. Each compile copies the whole bun binary, which takes about 2.5s with a debug+ASAN build, so the test regularly exceeded the default 5s per-test timeout under bun bd test. Turn the three cases into a test.each so every test does one compile, like the rest of the file, and assert the exact output path plus that the executable exists.
|
Warning Review limit reached
Next review available in: 9 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
Comment |
|
Status: reproduced and fixed in this PR. Reproduced by running the unmodified file with a debug+ASAN build, Overlap note: #37389 raises this test's timeout to 60s as a side change; #37397 changes a neighbouring test in the same file without touching this hunk. |
There was a problem hiding this comment.
LGTM — test-only refactor splitting three sequential compiles into a test.each, matching the one-compile-per-test shape of the rest of the file.
What was reviewed:
- Verified against
do_compilationinsrc/runtime/api/js_bundle_completion_task.rs: with nooutdirand an absoluteoutfile,outputs[0].pathis the outfile verbatim (.exeappended on Windows), so the tightened exact-match assertion holds on both platforms. path.joinnormalizes the forward-slash test inputs to backslashes on Windows before being passed asoutfile, so the Windows${outfile}.execomparison is separator-consistent.- Coverage is preserved (all three original path shapes remain) and strengthened with a file-existence check; no existing assertion was weakened.
Extended reasoning...
Overview
This PR touches a single test file, test/bundler/bun-build-compile.test.ts, converting one test that ran three Bun.build({ compile }) calls sequentially into a test.each over the three outfile paths. Each compile copies the ~1 GB debug+ASAN bun binary and takes ~2.5s, so three in one test intermittently exceeded the 5s default per-test timeout. The fix shrinks the per-test workload rather than raising the timeout, which is exactly what the repo review guidance prescribes.
Security risks
None. This is a test-only change with no production code, network, or filesystem-boundary implications beyond the existing temp-dir usage.
Level of scrutiny
Low. The change is mechanical and self-contained: same three inputs, same Bun.build call shape, restructured via test.each. The only semantic change is tightening toContain/toEndWith to an exact toEqual on the outputs array plus a new Bun.file(...).exists() check. I traced do_compilation in js_bundle_completion_task.rs to confirm that when outdir is empty and outfile is absolute, entry.dest_path is set to the outfile verbatim (with .exe on Windows targets), so the exact match is correct. On Windows, join(String(dir), "output/nested/app1") normalizes to backslashes before being passed in, keeping the comparison consistent — and the PR description reports it was verified on Windows Server 2019.
Other factors
The change follows repo conventions: test.each for matrices, tempDir from harness, String(dir) over dir + "", and a short comment explaining the one-compile-per-test constraint (non-obvious to a future editor who might re-merge them). No existing assertion is weakened; the new assertions are strictly stronger. The PR description notes overlap with #37389 (which raises this test's timeout) — whichever lands second drops a one-line hunk, which is a merge concern rather than a correctness one.
What
test/bundler/bun-build-compile.test.ts"compile with relative outfile paths" ran threeBun.build({ compile: { outfile } })calls inside one test. Every compile copies and rewrites the whole bun binary, which is about 1 GB with a debug+ASAN build and takes roughly 2.5s there (every single-compile test in the file reports 2.4s to 2.9s), so the test needed 7s or more of a 5s default per-test budget. On the unmodified file,bun bd test test/bundler/bun-build-compile.test.tsat 9fcdea8:The failure is intermittent (the session that reported it saw it in about 1 run in 3, with the passing runs taking 7.0s to 7.2s). The compile step runs on the JS thread inside the bundle completion task (
do_compilationis called fromJSBundleCompletionTask::on_complete), so the timeout can only be observed between compiles: when the first two compiles add up to more than 5s the test fails after the second one, otherwise the third compile starts and the test finishes late but passes. The third compile of a timed-out run also keeps going and slows down the next test, which is why "embedded resources" shows 5.2s above and 2.5s once this is fixed.This only affects the 5s default used by a plain
bun test/bun bd testrun; the CI runner passes a much larger--timeout, and with a release binary each compile takes about 0.13s.Fix
Turn the three cases into a
test.each, so every test does exactly one compile, the same shape as the rest of the file. The per-test timeout is left at the default rather than raised: the workload per test is what was out of proportion.While rewriting the assertion, the three
toContain/toEndWithchecks on the reported path become an exact comparison against the outfile that was passed in (.exeappended on Windows; with nooutdirthe artifact path is the outfile verbatim), and each case also checks that the executable exists at that path, which is what the nestedoutput/nested/anda/b/c/d/cases are there to prove. Nothing else in the file changes.Verification
bun bd test test/bundler/bun-build-compile.test.ts(debug+ASAN), two runs, 14 pass / 1 skip each, about 40s per run:The same file also passes with a release bun on Linux (
USE_SYSTEM_BUN=1) and on Windows Server 2019 x64 (release bun 1.4.0, where the exact path assertion exercises the.exebranch).Related: #37389 raises this test's timeout to 60s as a side change of an unrelated fix; whichever lands second drops or rebases a one-line hunk. #37397 fixes the neighbouring "embedded resources" test in the same file and does not overlap with this hunk.