Skip to content

test(cli): linked fixtures link their packages with a junction on Windows - #11266

Merged
cixzhang merged 3 commits into
meta:mainfrom
prath47:windows-linked-fixture-junction
Nov 13, 2026
Merged

cixzhang merged 3 commits into
meta:mainfrom
prath47:windows-linked-fixture-junction

Conversation

@prath47

@prath47 prath47 commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Maintainer impact

On a stock Windows setup, every test that builds a fixture with makeLinkedFixture (packages/cli/test-utils/linked-fixture.mjs) fails in its beforeAll:

Error: EPERM: operation not permitted, symlink 'D:\...\packages\cli\node_modules\@astryxdesign' -> 'C:\Users\...\Temp\astryx-...\node_modules\@astryxdesign'
 ❯ makeLinkedFixture packages/cli/test-utils/linked-fixture.mjs:42:8

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 (the theme-edit suites, the icon/build theme suites, text-json-parity, both render suites, 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 tsc test before it reached pnpm.

Intended invariant

The fixture still resolves its imports as the CLI resolves them, and removeLinkedFixture still 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, which packageDir() already gives. Node reads it like a symlink (lstat().isSymbolicLink() is true, and realpath and module resolution go through it), and fs.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.json and packages/cli/package.json still exist.

Evidence

All 22 test files that use the helper, run together on Windows 10 (Node 24.22.1, no Developer Mode), on main and then with this change:

Test files Tests passed Failed Skipped EPERM in output
main 22 failed 290 66 778 80
this PR 9 failed, 13 passed 931 54 149 8
  • No test that passed before fails now. The 54 that fail after this change are all in files that couldn't start before. For example, theme-edit.test.mjs went from 55 tests | 55 skipped to 55 tests | 3 failed, theme-hunt.test.mjs from 53 skipped to 16 failed, and theme-preview-safety.test.mjs from 69 skipped to 10 failed. What's left are separate Windows problems that these tests now get far enough to show: cd ..\.. where cd ../.. is expected, tests that create their own symlinks with fs.symlinkSync directly (the 8 remaining EPERMs), and a few path-string comparisons.
  • The helper's own test failed with EPERM before and passes after, including the new removal assertions.
  • Cleanup safety, checked separately: a junction to a temp directory with nested files, then fs.rmSync of the fixture root. The root is gone and every target file is still there.
  • Product/runtime behavior verified unchanged: test support only. changeset-coverage.mjs pr --base origin/main reports both files as exempt.
  • CI impact: none. On Linux CI the helper still makes 'dir' symlinks.

Scope

Components: CLI test support (packages/cli/test-utils/linked-fixture.mjs)

  • No intended public API, product behavior, visual direction, or policy change.
  • Product changes discovered during the work were removed or split.
  • Public text and artifacts contain no internal Meta context.

Testing

  • The 22-file before/after run above, on Windows.
  • prettier --check on both files: clean. ESLint ignores test-utils/ by config. Pre-commit hook passed.
  • Not run on macOS/Linux here. The non-Windows branch passes the same 'dir' as before.

…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'.
@vercel

vercel Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 13, 2026 4:07pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 13, 2026, 4:12 PM UTC

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 11, 2026
@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Nov 11, 2026
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 9b4cfa4

Storybook · Sandbox · built from this PR's head

Package size: no published package changed; no new dependencies.

Not run on this PR: add ci:run-visual, ci:run-a11y or ci:run-rtl to run them.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot 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.

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.

Automated review (maintainer link)

@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 5db2713

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 11, 2026
@cixzhang
cixzhang marked this pull request as draft November 11, 2026 19:39
@cixzhang
cixzhang marked this pull request as ready for review November 11, 2026 19:40

@astracat-bot astracat-bot 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.

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 packageDir returns: 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's files list, 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.
  • Files:
    • packages/cli/test-utils/linked-fixture.mjs: clear.
    • packages/cli/test-utils/linked-fixture.test.mjs: clear.

Automated review (maintainer link)

@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec daadbbc

@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 9b4cfa4

@astracat-bot astracat-bot 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.

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 packageDir returns: 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's files list, 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.
  • Files:
    • packages/cli/test-utils/linked-fixture.mjs: clear.
    • packages/cli/test-utils/linked-fixture.test.mjs: clear.

Automated review (maintainer link)

@cixzhang
cixzhang marked this pull request as draft November 13, 2026 16:42
@cixzhang
cixzhang marked this pull request as ready for review November 13, 2026 16:42
@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Nov 13, 2026
@cixzhang
cixzhang merged commit 497b48b into meta:main Nov 13, 2026
193 of 195 checks passed

This branch was successfully deployed

1 active deployment
Preview — 9b4cfa47 Deployed Nov 13, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) CLA Signed This label is managed by the Meta Open Source bot. community Authored by a community contributor (not on the eng/design team)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants