Repository navigation
Conversation
Five test files under test/internal each carried their own copy of a fake Toolchain for resolveConfig(). Two of them (macos-cross-config, windows-cross-config) predate Toolchain.hostCc/hostCxx and no longer type-check against the interface; an LLVM bump has to edit all five. Move the mock to test/_util/mock-toolchain.ts: mockToolchain() is the unix variant, mockWindowsCrossToolchain() layers the MSVC-flavored tool family on top of it. The windows variant now also carries the plain clang/clang++ host compilers that tools.ts resolves for a windows cross-compile. The test tree is not type-checked in CI, so add a source-lints test that pins the mocks' keys to the properties declared by `interface Toolchain` at runtime; it runs on every PR that touches scripts/build/ or test/_util/.
|
Warning Review limit reached
Next review available in: 27 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 (8)
Comment |
|
Status: ready for review. Reproduced the drift with a narrowed The automated review above raised nothing to change. A further self-review pass is in progress; this comment will be updated if it turns up anything. Open PRs that touch these copies (#34299, #37575) will need a small rebase onto the shared helper; noted in the description. |
There was a problem hiding this comment.
LGTM — mechanical test-infrastructure dedup, no production code touched.
What was reviewed:
- Confirmed the shared
mockToolchain()literal matches all 29 fields ofexport interface Toolchaininscripts/build/config.ts, and that the three up-to-date copies it replaces were byte-identical to it. - Verified
_util/*is already mapped intest/tsconfig.jsonandtest/_util/**is already a trigger path in.github/workflows/source-lints.yml, so the new import path and the sync test both work in the source-lints lane. - Checked that the windows fixture's inherited-from-unix values (
strip,ld64Lld,ranlib, etc.) aren't read by any assertion inwindows-cross-config.test.ts— onlycfg.ldandcfg.msvcLinkerare asserted, andtoolchain.msvcLinkerwas alreadyundefinedin the old copy.
Extended reasoning...
Overview
This PR consolidates five duplicated mockToolchain() fixtures across test/internal/ build-script tests into a single shared helper at test/_util/mock-toolchain.ts, and adds a source-lints test (mock-toolchain.test.ts) that pins the helper's keys to the property list parsed from export interface Toolchain in scripts/build/config.ts. Net -185 lines. All eight touched files are test infrastructure; no runtime, build-script, or CI-workflow code changes.
Security risks
None. This is a test-fixture refactor. No user-facing surface, no parsing of untrusted input, no auth/crypto/permissions.
Level of scrutiny
Low. The change is a textbook "the second time a multi-line block appears, extract a named helper" dedup that the repo's own review guidelines call for. The five deleted copies had already drifted (two were missing hostCc/hostCxx and failed tsc), which is exactly the failure mode a shared fixture prevents. I checked the Toolchain interface at scripts/build/config.ts:397-483 against the new literal — all 29 fields present with matching types. The source-lints regex (^\\s+(\\w+)\\??: over the comment-stripped interface body) correctly extracts every field of the current interface shape and throws on "interface not found", so it fails loudly rather than vacuously if the file is reshaped.
Other factors
_util/*is already apathsentry intest/tsconfig.json:18andtest/_util/**is already a trigger path in.github/workflows/source-lints.yml, so no new plumbing is needed and the sync test runs where the PR says it will.- The one semantic wrinkle is that
mockWindowsCrossToolchain()now derives from the unix base instead of being a full literal, so a handful of fields the old windows copy set toundefined(ranlib,ld64Lld,dsymutil) or to different paths (strip,llvmStrip) now inherit unix values. The PR description addresses this by diffing the resolvedConfigs across every shape the file exercises; I additionally grepped the file for assertions on those fields and found none — onlycfg.ldandcfg.msvcLinkerare asserted, both of which are set explicitly (ld) or were alreadyundefinedin the old toolchain (msvcLinker, derived byresolveConfig). - Verification section reports 43 passing tests across the six files under both released bun and
bun bd, plus the fullsource-lints/suite (83 tests), plus a clean narrowedtscrun.
|
Updated 10:51 AM PT - Aug 12th, 2026
✅ @robobun, your commit 7217904c40dd9db7aafb6faca0b73fe352da63a6 passed in 🧪 To try this PR locally: bunx bun-pr 37817That installs a local version of the PR into your bun-37817 --bun |
|
Closing this PR because it has been inactive for more than 90 days. |
Problem
test/internal/each carry their own copy of a fakeToolchainforresolveConfig(), and the copies have drifted.hostCc/hostCxx(added in build: support cross-compiling Windows (x64 and arm64) from Linux #31300), so they fail to type-check:error TS2322 ... Property 'hostCc' is optional ... but required in type 'Toolchain'. The test tree is not type-checked in CI, so nobody noticed.Toolchainfield has to land once per copy; [build images] Upgrade LLVM toolchain from 21.1.8 to 22.1.8 #34299 touches three of the five and build: make cargo test link on Windows hosts via /FORCE:UNRESOLVED in the generated .cargo/config.toml #37575 would add a sixth.Fix
test/_util/: a unix fixture, plus a windows-cross variant that overrides it, so a new field has exactly one place to go. The five local copies are deleted.interface Toolchaindeclares. It runs on every PR touchingscripts/build/**ortest/_util/**, so the next added field fails CI until the mock follows; droppinghostCc/hostCxxfrom the helper makes it fail.hostCc/hostCxx,clangResourceDir,ranlib/dsymutil/mt); every fieldresolveConfig()derives from them comes out identical, and no assertion reads the moved ones.bun bd test, and a narrowedtscrun over the touched files is clean.Background
Toolchain(scripts/build/config.ts) is the record of resolved tool paths (clang, lld, ar, cmake, ...) thatresolveConfig()turns, together with os / arch / build type, into the full buildConfig. It only records the paths, so tests pass fakes and run without LLVM.clang-cl,llvm-lib,lld-link, ...) but keeps plain clang / clang++ as host compilers, hence the second fixture.test/internal/source-lints/holds tests a GitHub workflow runs with released bun on a bare checkout when certain paths change; they may only import built-ins, relative paths,harnessand_util/*.Original description
What
The build-script tests under
test/internal/each carried a private copy of a fakeToolchainforresolveConfig():build-debug-info-flags,build-post-link-ordering,macos-cross-config,source-lints/windows-cross-configandsource-lints/webkit-prebuilt-url(#36139 added the fourth copy and left the dedupe as a follow-up). This replaces them with one helper,test/_util/mock-toolchain.ts, and adds a source-lints test that keeps it in sync with the interface.Why
The copies had already drifted.
Toolchain.hostCc/hostCxxwere added in #31300; themacos-cross-configandwindows-cross-configcopies never got them, so those two files fail to type-check againstToolchain:(
tsc --noEmitwith a config extendingtest/tsconfig.jsonand including just these files.) Nobody noticed because the test tree is not type-checked in CI. The same fan-out shows up in open PRs: #34299 (LLVM 22) bumpsclangVersionin three of the five copies, and #37575 adds what would be a sixth copy; both can use the shared helper after a rebase.Change
test/_util/mock-toolchain.ts:mockToolchain(overrides?)is the unix fixture (identical values to the three copies that were up to date).mockWindowsCrossToolchain(overrides?)layers the MSVC-flavored family (clang-cl,llvm-lib,lld-link,llvm-rc,llvm-mt,nasm) on top of it instead of being a second full literal, so a newToolchainfield has exactly one place to go.test/_util/is already a trigger path of the source-lints workflow, and_util/*already resolves there throughtest/harness.ts.windows-cross-config's linux case usesmockToolchain()directly instead of patchingcc/cxx/ldonto the windows copy.test/internal/source-lints/mock-toolchain.test.ts: assertsObject.keys()of both fixtures equals the property list parsed out ofexport interface Toolchaininscripts/build/config.ts. This is the runtime stand-in for the type check CI does not run; the source-lints workflow runs it on every PR touchingscripts/build/**ortest/_util/**, so the next added field fails there in seconds unless the mock is updated. WithhostCc/hostCxxremoved from the helper (the drift above) it fails withExpected - 2naming the two fields.Deriving the windows fixture from the unix one changes a few of its values compared with the old windows copy. Resolving the windows x64/arm64, lto/non-lto, ci/local shapes the tests use with both versions and diffing the resulting
Configs, the fields that move arehostCc/hostCxx(clang-cl->clang/clang++, which is whatresolveLlvmToolchain()actually returns for a windows target on a unix host),clangResourceDir(now undefined, as tools.ts skips the probe for msvc targets), andranlib/dsymutil/mt(now defined, as they are on a linux host). All of them are pass-through fields;computeFlags,webkit.source,rustTarget,ld,stripandmsvcLinkercome out identical, and no assertion in the file reads the moved fields.Verification
bun test(released bun, as the source-lints workflow runs it) andbun bd teston the six files: 43 pass.bun test test/internal/source-lints/: 83 pass across 19 files.tscrun above reports no errors in any of the touched files after the change.