Skip to content

Commit e208eef

Browse files
committed
test(snapshots): migrate the last blocked snap tests to the PTY suite (#2143)
Migrates the final 10 legacy snap tests, emptying both legacy trees (`packages/cli/snap-tests`, `packages/cli/snap-tests-global`). Runner additions that unblock them: - Step env values expand `${NAME}`: `${workspace}` resolves to the step's working directory, any other name to the case env. This expresses the shell forms `VP_HOME="$(pwd)/home"` and `PATH="$(pwd)/bin:$PATH"` used by `command-env-setup-external-vp`, `npm-global-install-custom-prefix-on-path`, and `shim-corepack-enable-install-directory`. - Programs a case creates under its own root (shims from an isolated `vp env setup`) count as case-owned for resolution, and a per-case `link-node-modules = true` exposes the run-root `node_modules` as the workspace parent-dir `node_modules` like the legacy layout, so `bin-oxlint-wrapper`/`bin-oxfmt-wrapper` address `../node_modules/vite-plus/bin/*` verbatim. - The `./`-prefix program join no longer leaks a `/./` component into recorded shim targets, and an empty step cwd no longer leaks a trailing separator into `${workspace}`. Hermeticity fixes over the legacy versions: `shim-npm-downloads-uncached-package-manager-version` sets `seed-runtime = false` (its `rm` of a pinned runtime must not reach the shared seed through the symlink) and pins `.node-version 22.11.0` instead of inheriting the environment default; `command-env-setup-external-vp` drops `VP_BYPASS` (the hermetic PATH has no system node); the custom-prefix case asserts the npm bin as a symlink, which the legacy `test -f` followed silently. `fingerprint-ignore-test` and `vitest-browser-mode` stay disabled on every platform as in the legacy suite; their fixtures carry the converted steps and record no snapshot until re-enabled. The legacy CI jobs (`cli-snap-test` matrix, retry script, Renovate ignorePaths for the trees) are removed here too, and the legacy runner exits cleanly when a tree is absent from a fresh checkout, so local `pnpm test` keeps working. Deleting the legacy runner and migrator tooling under `packages/tools` can follow separately. Closes #2116.
1 parent 98cca64 commit e208eef

63 files changed

Lines changed: 568 additions & 535 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/renovate.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,7 @@
44
"description": "Skip lockfile artifact updates (npm and cargo): they fail in Renovate's clone because vite/ and rolldown/ are gitignored. The renovate-lockfiles workflow regenerates lockfiles on renovate/** pushes; gitIgnoredAuthors keeps Renovate managing branches with its commits.",
55
"gitIgnoredAuthors": ["278573678+voidzero-guard[bot]@users.noreply.github.com"],
66
"skipArtifactsUpdate": true,
7-
"ignorePaths": [
8-
"packages/cli/snap-tests/**",
9-
"packages/cli/snap-tests-global/**",
10-
"packages/cli/snap-tests-todo/**",
11-
"bench/fixtures/**",
12-
"rolldown/**",
13-
"vite/**"
14-
],
7+
"ignorePaths": ["bench/fixtures/**", "rolldown/**", "vite/**"],
158
"packageRules": [
169
{
1710
"description": "Ignore upstream toolchain npm packages (vendored via sync-remote or bumped by the proactive catalog workflow); everything else stays enabled so security alerts get fixed.",

.github/scripts/retry-failed-snap-tests.sh

Lines changed: 0 additions & 38 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 7 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ jobs:
343343
# Cross-compiles the Windows release NAPI binding (vite-plus .node) and CLI
344344
# binaries (vp.exe, vp-shim.exe, vp-setup.exe) on a fast Linux runner with
345345
# cargo-xwin, then publishes them as the windows-cli-binaries artifact. The
346-
# Windows entries of cli-e2e-test, cli-snap-test, and install-e2e-test-sfw
346+
# Windows entries of cli-e2e-test and install-e2e-test-sfw
347347
# download that artifact instead of each spending ~24 minutes rebuilding the
348348
# same binaries on slow windows-latest runners whenever build-upstream's
349349
# NAPI binding cache misses. Release builds are unaffected: they keep
@@ -899,139 +899,6 @@ jobs:
899899
pnpm bootstrap-cli:ci
900900
vp --version
901901
902-
cli-snap-test:
903-
name: CLI snap test (${{ matrix.target }}, ${{ matrix.shard }}/${{ matrix.shardTotal }})
904-
needs:
905-
- download-previous-rolldown-binaries
906-
- build-windows-cli
907-
strategy:
908-
fail-fast: false
909-
matrix:
910-
include:
911-
- os: namespace-profile-linux-x64-default
912-
target: x86_64-unknown-linux-gnu
913-
shard: 1
914-
shardTotal: 3
915-
- os: namespace-profile-linux-x64-default
916-
target: x86_64-unknown-linux-gnu
917-
shard: 2
918-
shardTotal: 3
919-
- os: namespace-profile-linux-x64-default
920-
target: x86_64-unknown-linux-gnu
921-
shard: 3
922-
shardTotal: 3
923-
- os: namespace-profile-mac-default
924-
target: aarch64-apple-darwin
925-
shard: 1
926-
shardTotal: 3
927-
- os: namespace-profile-mac-default
928-
target: aarch64-apple-darwin
929-
shard: 2
930-
shardTotal: 3
931-
- os: namespace-profile-mac-default
932-
target: aarch64-apple-darwin
933-
shard: 3
934-
shardTotal: 3
935-
- os: namespace-profile-windows-4c-8g
936-
target: x86_64-pc-windows-msvc
937-
shard: 1
938-
shardTotal: 3
939-
- os: namespace-profile-windows-4c-8g
940-
target: x86_64-pc-windows-msvc
941-
shard: 2
942-
shardTotal: 3
943-
- os: namespace-profile-windows-4c-8g
944-
target: x86_64-pc-windows-msvc
945-
shard: 3
946-
shardTotal: 3
947-
runs-on: ${{ matrix.os }}
948-
steps:
949-
- uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2
950-
- uses: ./.github/actions/clone
951-
952-
# Dev Drive works on the Namespace Windows runner: setup-dev-drive v4
953-
# creates and mounts its ReFS VHD on namespace-profile-windows-4c-8g, and
954-
# all three Windows shards pass with this step succeeding (nested
955-
# virtualization is available there). Only cli-snapshot-test-windows moved
956-
# off Namespace, and for an unrelated reason (Session-0 ConPTY, see there).
957-
- name: Setup Dev Drive
958-
if: runner.os == 'Windows'
959-
uses: samypr100/setup-dev-drive@30f0f98ae5636b2b6501e181dfb3631b9974818d # v4.0.0
960-
with:
961-
drive-size: 12GB
962-
drive-format: ReFS
963-
# Route TEMP/TMP onto the Dev Drive (ReFS) so `tmpdir()` from
964-
# `packages/tools/src/snap-test.ts` lives on a filesystem that
965-
# cleanly resolves pnpm's junction reparse points. NTFS-on-C:
966-
# preserves the junction-target backslashes during resolution,
967-
# which produces mixed `\` / `/` paths that break Node's ESM
968-
# subpath-import walk-up (`#module-sync-enabled` inside
969-
# `@voidzero-dev/vite-plus-core` → `ERR_PACKAGE_IMPORT_NOT_DEFINED`
970-
# during `vp fmt --write` in the
971-
# `new-create-vite-migrates-eslint-prettier` snap test).
972-
env-mapping: |
973-
TEMP,{{ DEV_DRIVE }}/Temp
974-
TMP,{{ DEV_DRIVE }}/Temp
975-
976-
- name: Create TEMP/TMP on Dev Drive
977-
if: runner.os == 'Windows'
978-
# `setup-dev-drive` only mounts the drive; it doesn't create the
979-
# dir we point TEMP/TMP at. Anything that calls `os.tmpdir()` /
980-
# `lstat($TEMP)` before this dir exists fails (e.g. the bootstrap
981-
# CLI installer's `lstat 'E:\Temp'` ENOENT).
982-
shell: bash
983-
run: mkdir -p "$TEMP" "$TMP"
984-
985-
# Windows runs against the prebuilt binaries from build-windows-cli,
986-
# so it needs no Rust toolchain here (the Dev Drive above stays for
987-
# the TEMP/TMP routing).
988-
- uses: oxc-project/setup-rust@68c3199c5339f965e6e163924c3c450773eba42b # main (pending v1.0.17 — Swatinem/rust-cache v2.9.1 for node24)
989-
if: runner.os != 'Windows'
990-
with:
991-
save-cache: ${{ github.ref_name == 'main' }}
992-
cache-key: cli-snap-test-${{ matrix.target }}
993-
994-
- uses: oxc-project/setup-node@4c588e9266bd930b6ddc34307df0659ed511d187 # v1.3.1
995-
996-
- name: Install docs dependencies
997-
run: pnpm -C docs install --frozen-lockfile
998-
999-
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
1000-
with:
1001-
name: rolldown-binaries
1002-
path: ./rolldown/packages/rolldown/src
1003-
merge-multiple: true
1004-
1005-
# See the cli-e2e-test job for details on the prebuilt binaries.
1006-
- name: Download prebuilt Windows binaries
1007-
if: runner.os == 'Windows'
1008-
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
1009-
with:
1010-
name: windows-cli-binaries
1011-
1012-
- name: Build with upstream
1013-
uses: ./.github/actions/build-upstream
1014-
with:
1015-
target: ${{ matrix.target }}
1016-
skip-native: ${{ runner.os == 'Windows' }}
1017-
1018-
- name: Install Global CLI vp
1019-
run: |
1020-
pnpm bootstrap-cli:ci
1021-
if [[ "$RUNNER_OS" == "Windows" ]]; then
1022-
echo "$USERPROFILE\.vite-plus\bin" >> $GITHUB_PATH
1023-
else
1024-
echo "$HOME/.vite-plus/bin" >> $GITHUB_PATH
1025-
fi
1026-
1027-
- name: Run CLI snapshot tests (shard ${{ matrix.shard }}/${{ matrix.shardTotal }})
1028-
run: |
1029-
RUST_BACKTRACE=1 pnpm -F ./packages/cli snap-test-local --shard=${{ matrix.shard }}/${{ matrix.shardTotal }}
1030-
RUST_BACKTRACE=1 pnpm -F ./packages/cli snap-test-global --shard=${{ matrix.shard }}/${{ matrix.shardTotal }}
1031-
bash .github/scripts/retry-failed-snap-tests.sh
1032-
env:
1033-
RUST_MIN_STACK: 8388608
1034-
1035902
# Runs the PTY snapshot suite (crates/vite_cli_snapshots) with BOTH vp
1036903
# flavors on Linux and macOS: the local flavor uses the packages/cli build
1037904
# from this job, the global flavor reuses the installed release binary via
@@ -1115,9 +982,12 @@ jobs:
1115982
- uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2
1116983
- uses: ./.github/actions/clone
1117984

1118-
# Same Dev Drive TEMP routing as cli-snap-test: staged fixture
1119-
# workspaces live under os.tmpdir() and must resolve pnpm junction
1120-
# reparse points cleanly (see that job for the full story).
985+
# Route TEMP/TMP onto a Dev Drive (ReFS): staged fixture workspaces
986+
# live under os.tmpdir() and must resolve pnpm junction reparse points
987+
# cleanly. NTFS-on-C: preserves the junction-target backslashes during
988+
# resolution, which produces mixed `\` / `/` paths that break Node's
989+
# ESM subpath-import walk-up (`#module-sync-enabled` inside
990+
# `@voidzero-dev/vite-plus-core` -> `ERR_PACKAGE_IMPORT_NOT_DEFINED`).
1121991
- name: Setup Dev Drive
1122992
uses: samypr100/setup-dev-drive@30f0f98ae5636b2b6501e181dfb3631b9974818d # v4.0.0
1123993
with:
@@ -1267,7 +1137,6 @@ jobs:
12671137
12681138
git config --global --add safe.directory /workspace
12691139
RUST_BACKTRACE=1 pnpm test
1270-
bash .github/scripts/retry-failed-snap-tests.sh
12711140
"
12721141
12731142
install-e2e-test:
@@ -1485,7 +1354,6 @@ jobs:
14851354
- lint
14861355
- cli-e2e-test
14871356
- cli-e2e-test-musl
1488-
- cli-snap-test
14891357
- cli-snapshot-test
14901358
- cli-snapshot-test-windows
14911359
# Skipped on unlabeled PRs; counted on push-to-main and labeled PRs.

.github/workflows/upgrade-deps.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,11 @@ jobs:
145145
### Final validation (this step is complete ONLY when all pass)
146146
1. `just build` exits 0.
147147
2. `pnpm bootstrap-cli:ci && pnpm test` exits 0.
148-
3. `git diff` on `packages/cli/snap-tests/**/snap.txt` and
149-
`packages/cli/snap-tests-global/**/snap.txt` contains no real regressions.
150-
IMPORTANT: `pnpm test` always exits 0 even when snap outputs differ, so you
151-
MUST inspect the diff yourself. Cosmetic drift from the upgrade (e.g. a
152-
bumped version string in help output) is acceptable; unexpected stack
153-
traces, missing output, or diverging CLI behavior are regressions to fix.
148+
3. `just snapshot-test` exits 0. Snapshot mismatches fail the run with a
149+
unified diff. Re-record with `UPDATE_SNAPSHOTS=1` only for cosmetic
150+
drift from the upgrade (e.g. a bumped version string in help output);
151+
unexpected stack traces, missing output, or diverging CLI behavior are
152+
regressions to fix.
154153
4. `git status --short` and `git diff --stat` have been inspected, and
155154
every changed file is intentional for the upgrade PR. Pay special
156155
attention to generated NAPI binding files, because later CI runs fail

crates/vite_cli_snapshots/tests/cli_snapshots/README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ cwd = "packages/app" # optional, relative to the fixture root
7777
skip-platforms = ["windows"] # or { os = "linux", libc = "musl" }
7878
ignore = false # true: only runs with `-- --ignored`
7979
seed-runtime = true # false: start from an empty VP_HOME
80+
link-node-modules = false # true: expose the run-root node_modules as
81+
# the workspace's parent-dir node_modules,
82+
# for `../node_modules/vite-plus/...` paths
8083
env = { MY_VAR = "1" } # case-wide env additions
8184
unset-env = ["SOME_VAR"] # remove baseline env entries
8285
steps = [ ... ]
@@ -99,7 +102,11 @@ A step is a bare argv array or a table:
99102
{ argv = ["vp", "create"],
100103
cwd = "sub", # per-step working dir
101104
comment = "...", # rendered under the step heading
102-
envs = [["K", "V"]], # per-step env
105+
envs = [["K", "V"]], # per-step env; values expand `${NAME}`:
106+
# `${workspace}` is the step's working dir,
107+
# any other name resolves from the case env
108+
# (`PATH = "${workspace}/bin:${PATH}"` is
109+
# the shell's `PATH="$(pwd)/bin:$PATH"`)
103110
timeout = 120000, # ms, default 50s
104111
snapshot = false, # omit the screen while the step succeeds
105112
# (failures always keep their output)

packages/cli/snap-tests/bin-oxfmt-wrapper/package.json renamed to crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxfmt_wrapper/package.json

File renamed without changes.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[[case]]
2+
name = "bin_oxfmt_wrapper"
3+
vp = "local"
4+
# The wrapper is addressed by path through the workspace parent, the legacy
5+
# runner's layout.
6+
link-node-modules = true
7+
steps = [
8+
{ argv = ["node", "../node_modules/vite-plus/bin/oxfmt"], comment = "should reject non-LSP usage", continue-on-failure = true },
9+
{ argv = ["node", "../node_modules/vite-plus/bin/oxfmt", "--help"], comment = "should reject non-LSP usage", continue-on-failure = true },
10+
{ argv = ["node", "../node_modules/vite-plus/bin/oxfmt", "--lsp", "--help"], comment = "should allow LSP mode" },
11+
{ argv = ["node", "../node_modules/vite-plus/bin/oxfmt", "--stdin-filepath=a.ts", "--help"], comment = "should allow Stdin mode" },
12+
]

packages/cli/snap-tests/bin-oxfmt-wrapper/snap.txt renamed to crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxfmt_wrapper/snapshots/bin_oxfmt_wrapper.md

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,32 @@
1-
[1]> node ../node_modules/vite-plus/bin/oxfmt # should reject non-LSP usage
1+
# bin_oxfmt_wrapper
2+
3+
## `node ../node_modules/vite-plus/bin/oxfmt`
4+
5+
should reject non-LSP usage
6+
7+
**Exit code:** 1
8+
9+
```
210
This oxfmt wrapper is for IDE extension use only (lsp or stdin mode).
311
To format your code, run: vp fmt
12+
```
13+
14+
## `node ../node_modules/vite-plus/bin/oxfmt --help`
15+
16+
should reject non-LSP usage
417

5-
[1]> node ../node_modules/vite-plus/bin/oxfmt --help # should reject non-LSP usage
18+
**Exit code:** 1
19+
20+
```
621
This oxfmt wrapper is for IDE extension use only (lsp or stdin mode).
722
To format your code, run: vp fmt
23+
```
24+
25+
## `node ../node_modules/vite-plus/bin/oxfmt --lsp --help`
26+
27+
should allow LSP mode
828

9-
> node ../node_modules/vite-plus/bin/oxfmt --lsp --help # should allow LSP mode
29+
```
1030
Usage: [-c=PATH] [PATH]...
1131
1232
Mode Options:
@@ -45,9 +65,13 @@ Available positional items:
4565
Available options:
4666
-h, --help Prints help information
4767
-V, --version Prints version information
68+
```
4869

70+
## `node ../node_modules/vite-plus/bin/oxfmt --stdin-filepath=a.ts --help`
4971

50-
> node ../node_modules/vite-plus/bin/oxfmt --stdin-filepath=a.ts --help # should allow Stdin mode
72+
should allow Stdin mode
73+
74+
```
5175
Usage: [-c=PATH] [PATH]...
5276
5377
Mode Options:
@@ -86,4 +110,4 @@ Available positional items:
86110
Available options:
87111
-h, --help Prints help information
88112
-V, --version Prints version information
89-
113+
```

packages/cli/snap-tests/bin-oxlint-wrapper/package.json renamed to crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxlint_wrapper/package.json

File renamed without changes.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[[case]]
2+
name = "bin_oxlint_wrapper"
3+
vp = "local"
4+
# The wrapper is addressed by path through the workspace parent, the legacy
5+
# runner's layout.
6+
link-node-modules = true
7+
steps = [
8+
{ argv = ["node", "../node_modules/vite-plus/bin/oxlint"], comment = "should reject non-LSP usage", continue-on-failure = true },
9+
{ argv = ["node", "../node_modules/vite-plus/bin/oxlint", "--help"], comment = "should reject non-LSP usage", continue-on-failure = true },
10+
{ argv = ["node", "../node_modules/vite-plus/bin/oxlint", "--lsp", "--help"], comment = "should exercise import path" },
11+
]

0 commit comments

Comments
 (0)