Skip to content

test(bundler): compile each outfile case in its own test - #37417

Merged
Jarred-Sumner merged 1 commit into
mainfrom
farm/d4f53d61/split-compile-outfile-test
Aug 11, 2026
Merged

Jarred-Sumner merged 1 commit into
mainfrom
farm/d4f53d61/split-compile-outfile-test

Conversation

@robobun

@robobun robobun commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

What

test/bundler/bun-build-compile.test.ts "compile with relative outfile paths" ran three Bun.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.ts at 9fcdea8:

(fail) Bun.build compile > compile with relative outfile paths [5523.70ms]
  ^ this test timed out after 5000ms.
(pass) Bun.build compile > compile with embedded resources uses correct module prefix [5227.91ms]

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_compilation is called from JSBundleCompletionTask::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 test run; 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 / toEndWith checks on the reported path become an exact comparison against the outfile that was passed in (.exe appended on Windows; with no outdir the artifact path is the outfile verbatim), and each case also checks that the executable exists at that path, which is what the nested output/nested/ and a/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:

(pass) Bun.build compile > compile writes the executable to outfile output/nested/app1 [2567.03ms]
(pass) Bun.build compile > compile writes the executable to outfile app2 [2576.66ms]
(pass) Bun.build compile > compile writes the executable to outfile a/b/c/d/app3 [2590.81ms]
(pass) Bun.build compile > compile with embedded resources uses correct module prefix [2501.16ms]

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 .exe branch).

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.

"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.
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@robobun, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 9 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6dde2a4a-80e7-4b07-8b58-d7eafbd36971

📥 Commits

Reviewing files that changed from the base of the PR and between 9fcdea8 and f0bb22b.

📒 Files selected for processing (1)
  • test/bundler/bun-build-compile.test.ts

Comment @coderabbitai help to get the list of available commands.

@robobun

robobun commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator Author

Status: reproduced and fixed in this PR.

Reproduced by running the unmodified file with a debug+ASAN build, bun bd test test/bundler/bun-build-compile.test.ts at 9fcdea8: compile with relative outfile paths [5523.70ms] ^ this test timed out after 5000ms (three compiles at about 2.5s each). With the split from f0bb22b each case runs as its own test in about 2.5s, and the file passes under the debug build (two runs), with a release bun on Linux, and with a release bun on Windows x64.

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.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_compilation in src/runtime/api/js_bundle_completion_task.rs: with no outdir and an absolute outfile, outputs[0].path is the outfile verbatim (.exe appended on Windows), so the tightened exact-match assertion holds on both platforms.
  • path.join normalizes the forward-slash test inputs to backslashes on Windows before being passed as outfile, so the Windows ${outfile}.exe comparison 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.

@Jarred-Sumner
Jarred-Sumner merged commit d1b5b7d into main Aug 11, 2026
51 checks passed
@Jarred-Sumner
Jarred-Sumner deleted the farm/d4f53d61/split-compile-outfile-test branch August 11, 2026 05:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants