Repository navigation
test(cli): linked fixtures link their packages with a junction on Windows - #11266
Conversation
…dows makeLinkedFixture made each package link with fs.symlinkSync(..., 'dir'). On Windows a directory symlink needs Developer Mode or an elevated shell, so on a stock setup every fixture failed with EPERM in its beforeAll and each of the 22 test files that use the helper skipped or failed whole. Use a directory junction on win32. It needs no special rights, resolves and realpaths like the symlink, and fs.rmSync removes the junction, not its target. The helper's test now also checks that removing a fixture leaves the linked packages in place. Other platforms keep 'dir'.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet, so a maintainer needs to add the ci:run label for it to run.
Using a directory junction on Windows in makeLinkedFixture matches what the other CLI test helpers already do (pack-cli.mjs, global-local-fixtures.mjs), leaves the macOS and Linux path unchanged, and the new assertions in the helper's own test guard the one new risk: cleanup reaching the linked packages. The helper's test and two suites that use it pass on Linux at this head; the Windows results rest on your run.
|
/approve-spec 5db2713 |
There was a problem hiding this comment.
Approved pending CI: CI has not passed on this head yet.
Using a directory junction on Windows in makeLinkedFixture matches what the other CLI test helpers already do, leaves the macOS and Linux path unchanged, and the new assertions in the helper's own test guard the one new risk: cleanup reaching the linked packages. One Node test shard hit CI's 15-minute job limit after every test it finished had passed, so a maintainer needs to re-run it before the required test check can pass. The Windows results rest on your run, since CI runs these suites on Linux only.
Claims and files checked
- Claims:
- Before this change the helper linked each package with a directory symlink: verified (base
linked-fixture.mjs:42). - On Windows each link is now a junction and other platforms keep the directory symlink: verified (
linked-fixture.mjs:46-50). - The junction gets the absolute target that
packageDirreturns: verified (linked-fixture.mjs:17,:72-77). - Removing a fixture leaves the linked packages in place: verified by the new assertions (
linked-fixture.test.mjs:43-49); the Windows run is yours. - Fixture imports still resolve as the CLI resolves them: verified by the existing test (
linked-fixture.test.mjs:31-38). - 22 test files use the helper: verified; 22 suites besides the helper's own test import it.
- A junction needs no special rights and Node resolves and removes it like a symlink: consistent with the code; the Windows evidence is yours.
- The Windows before and after numbers: your run, not reproduced here.
- No published file or product behavior changes and no changeset is needed: verified (
test-utils/is outside the package'sfileslist, and the release tooling exempts unpacked files). - ESLint ignores these files: verified (
eslint.config.js:207-215). - Both files pass Prettier: verified by the lint workflow's changed-file check at this head.
- Linux CI still makes directory symlinks: verified (
linked-fixture.mjs:49). - The problem was first raised in #11261: verified.
- Before this change the helper linked each package with a directory symlink: verified (base
- Files:
packages/cli/test-utils/linked-fixture.mjs: clear.packages/cli/test-utils/linked-fixture.test.mjs: clear.
|
/approve-spec daadbbc |
|
/approve-spec 9b4cfa4 |
There was a problem hiding this comment.
Approved pending CI: CI has not finished on this head yet.
Using a directory junction on Windows in makeLinkedFixture matches what the other CLI test helpers already do, leaves the macOS and Linux path unchanged, and the new assertions in the helper's own test guard the one new risk: cleanup reaching the linked packages. The helper's own test passes on Linux at this head; the Windows results rest on your run, since CI runs these suites on Linux only. The description's count of 22 test files predates the merges from main: 99 test files use the helper now, so you may want to update that line.
Claims and files checked
- Claims:
- Before this change the helper linked each package with a directory symlink: verified (base
linked-fixture.mjs:42). - On Windows each link is now a junction and other platforms keep the directory symlink: verified (
linked-fixture.mjs:46-50). - The junction gets the absolute target that
packageDirreturns: verified (linked-fixture.mjs:17,:79-84). - Removing a fixture leaves the linked packages in place: verified by the new assertions (
linked-fixture.test.mjs:48-54), passing on Linux; the Windows run is yours. - Fixture imports still resolve as the CLI resolves them: verified by the existing test (
linked-fixture.test.mjs:36-43). - 22 test files use the helper: true when written; 99 test files import it at this head after merges from
main. - A junction needs no special rights and Node resolves and removes it like a symlink: consistent with the code; the Windows evidence is yours.
- The Windows before and after numbers and the separate cleanup check: your runs, not reproduced here.
- No published file or product behavior changes and no changeset is needed: verified (
test-utils/is outside the package'sfileslist, and the release tooling exempts unpacked files). - ESLint ignores these files: verified (
eslint.config.js:207-215). - Both files pass Prettier: verified.
- Linux CI still makes directory symlinks: verified (
linked-fixture.mjs:49). - The problem was first raised in #11261: verified.
- Before this change the helper linked each package with a directory symlink: verified (base
- Files:
packages/cli/test-utils/linked-fixture.mjs: clear.packages/cli/test-utils/linked-fixture.test.mjs: clear.
Maintainer impact
On a stock Windows setup, every test that builds a fixture with
makeLinkedFixture(packages/cli/test-utils/linked-fixture.mjs) fails in itsbeforeAll:The helper links each package with
fs.symlinkSync(target, link, 'dir'), and a Windows directory symlink needs Developer Mode or an elevated shell. 22 test files use the helper (thetheme-editsuites, the icon/build theme suites,text-json-parity, bothrendersuites, and others), so on such a machine most of them skip or fail as a whole before any assertion runs.I mentioned this in #11261, where it blocked the authoring-migration
tsctest before it reachedpnpm.Intended invariant
The fixture still resolves its imports as the CLI resolves them, and
removeLinkedFixturestill removes only the fixture, never the packages it links to. On macOS and Linux nothing changes.Change
On
win32, create each link as a directory junction ('junction') instead of a directory symlink. A junction needs no special rights. It takes an absolute target, whichpackageDir()already gives. Node reads it like a symlink (lstat().isSymbolicLink()is true, andrealpathand module resolution go through it), andfs.rmSync(root, {recursive: true})removes the junction itself, not its target. Other platforms keep'dir'.Because removal now goes through a junction on Windows, I added two assertions to the helper's own test: after
removeLinkedFixture,packages/core/package.jsonandpackages/cli/package.jsonstill exist.Evidence
All 22 test files that use the helper, run together on Windows 10 (Node 24.22.1, no Developer Mode), on
mainand then with this change:EPERMin outputmaintheme-edit.test.mjswent from55 tests | 55 skippedto55 tests | 3 failed,theme-hunt.test.mjsfrom53 skippedto16 failed, andtheme-preview-safety.test.mjsfrom69 skippedto10 failed. What's left are separate Windows problems that these tests now get far enough to show:cd ..\..wherecd ../..is expected, tests that create their own symlinks withfs.symlinkSyncdirectly (the 8 remainingEPERMs), and a few path-string comparisons.EPERMbefore and passes after, including the new removal assertions.fs.rmSyncof the fixture root. The root is gone and every target file is still there.changeset-coverage.mjs pr --base origin/mainreports both files as exempt.'dir'symlinks.Scope
Components: CLI test support (
packages/cli/test-utils/linked-fixture.mjs)Testing
prettier --checkon both files: clean. ESLint ignorestest-utils/by config. Pre-commit hook passed.'dir'as before.