feat(plugin-js): js_test driver, per-test-file granularity - #364
Draft
raphaelvigee wants to merge 1 commit into
Draft
feat(plugin-js): js_test driver, per-test-file granularity#364raphaelvigee wants to merge 1 commit into
raphaelvigee wants to merge 1 commit into
Conversation
M4 of the JS/TS plugin: a cacheable js_test ManagedDriver with one target per test file (vitest default, jest alt via a single testrunner config option), fed by the M2/M3 import graph rather than package-level caching — the differentiator the design doc calls out over Turborepo/Nx, which never get finer than per-package task caching. - Per-test-file Input scoping: the test file's own runtime-transitive closure (BFS over ImportGraph::runtime_edges, bounded to the owning package), third-party deps resolved via the same lockfile-driven mechanism js_install/js_typecheck use (no ambient node_modules dependency, per the M3 lesson), and the resolved test-runner config. - Runner-config discovery covers vitest's own fallback (vite.config.*) and jest's package.json "jest" field, not just the dedicated config filenames. Reviewed by feature-quality/code-quality/hermeticity. Three BLOCKERs found and fixed: a js_test addr's file= argument accepted an absolute path or a `..`-escape with no validation, letting a target read/exec outside the workspace and sandbox entirely (fixed at both Provider::get and defensively again in the driver's run()); vitest/jest config-referenced files (setupFiles, globalSetup, a shared base config reached via a relative import) were untracked, so editing one didn't bust the cache of every test that depends on it; and the primary runner-config file itself could go undiscovered for the vite.config.*/package.json-jest-field layouts. Each has a regression test. Explicitly deferred (named, not silent): per-test-file Provider::get rebuilds the whole package's import graph from scratch rather than caching it once per package (a real warm-cache-path cost); the cross-package one-hop trim now risks a stale test-pass cache hit, not just a missed diagnostic, for a barrel-file re-export; test-runner-specific alias resolution (vitest resolve.alias, jest moduleNameMapper) isn't fed into the resolver. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M3wZfyPsG8stfRQuybLRjN
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.
M4 of the JS/TS heph plugin plan (part 4/6 of the stack).
A cacheable js_test ManagedDriver with one target per test file (vitest default, jest alt via a single testrunner config option), fed by the M2/M3 import graph — the differentiator over Turborepo/Nx, which never get finer than per-package task caching.
Reviewed by feature-quality/code-quality/hermeticity. Three BLOCKERs found and fixed: a real sandbox escape — a js_test addr's
file=argument accepted an absolute path or a..-escape with no validation, letting a target read/exec outside the workspace and sandbox entirely (fixed at both Provider::get and defensively again in the driver's run()); vitest/jest config-referenced files (setupFiles, globalSetup, a shared base config) were untracked, so editing one didn't bust the cache of every dependent test; and the primary runner-config file itself could go undiscovered for vite.config.*/package.json-jest-field layouts. Each has a regression test.Explicitly deferred: per-test-file Provider::get rebuilding the whole package's import graph from scratch (fixed later in the stack); the cross-package one-hop trim risking a stale test-pass cache hit for a barrel-file re-export; test-runner-specific alias resolution.
Test plan
Stack created with GitHub Stacks CLI • Give Feedback 💬