Repository navigation
fix(vitest): stage a directory output's files from the test's runfiles - #262
Merged
Merged
Conversation
Where runfiles are materialized as files, as under remote execution, a realpath taken inside ts_test's private tree lands in the launcher's runfiles tree. The launcher now exports that directory as TS_TEST_RUNFILES_ORIGIN; runfilesPath maps paths under it back onto the private tree, and Vite's fs.allow includes it. A materialized-runfiles test reproduces the failure without the fix. The integration harness's nested Bazel sets --remote_download_outputs=all: its --disk_cache counts as a remote cache, so once CI's shared disk cache is warm a cache hit left outputs the tests read back unmaterialized. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mikn
force-pushed
the
mikn/vitest-runfiles-realpath
branch
from
October 6, 2026 19:02
5dd4e84 to
1714415
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When runfiles are materialized as files, as they are under remote execution, a
realpathtaken insidets_test's private tree resolves into the launcher's runfiles tree underbazel-out/<cfg>/bin. That path is outside Vite'sfs.allowlist, andrunfilesPathcannot map it back. Tests that import a file inside a directory output, or load an npm asset by URL, then fail with Vite's "Denied ID" error. The same tests pass where runfiles are symlinks, so the failure appears only under remote execution.What changes
tools/launcher/vitest.goexports the resolved runfiles directory asTS_TEST_RUNFILES_ORIGIN.ts/private/actions/vitest.bzladds it tofs.allow, andrunfilesPathmaps paths under it back onto the private tree.New
tests/codegen_tree/tree_import_test(ats_testimporting a file from a directory output and an npm asset by URL) andmaterialized_runfiles_test(a Go test that re-materializes the runfiles as remote execution does and runs the launcher from there). The Go test fails without the fix.tests/integration/harness/harness.go: the nested Bazel's generated bazelrc sets--remote_download_outputs=all. Its--disk_cachecounts as a remote cache, so once CI's shared disk cache is warm, a cache hit left outputs unmaterialized, and tests that read files back frombazel-outfailed with "cannot read …". This is what madeIntegration Tests (core)and(npm)fail onmainand on every open PR.Verification
All 88 tests in
codegen_treeandvitestpass on remote execution (BuildBuddy invocation029b2236), including the new regression test.Disk-cache fix:
lsp_test,gazelle_roundtrip_roots_testandgazelle_roundtrip_packages_testwere run twice in one invocation with a shared scratch directory, so the second pass sees a warm disk cache. Without the change, the second pass failed all three with the CI error (88a81ef4). With it, both passes pass (fc6fbd55).🤖 Generated with Claude Code