From e208eefbc1e05461883ad5cd7cb3a9408febc893 Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Fri, 10 Jul 2026 14:06:03 +0000 Subject: [PATCH] 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. --- .github/renovate.json | 9 +- .github/scripts/retry-failed-snap-tests.sh | 38 ----- .github/workflows/ci.yml | 146 +----------------- .github/workflows/upgrade-deps.yml | 11 +- .../tests/cli_snapshots/README.md | 9 +- .../fixtures/bin_oxfmt_wrapper}/package.json | 0 .../fixtures/bin_oxfmt_wrapper/snapshots.toml | 12 ++ .../snapshots/bin_oxfmt_wrapper.md | 34 +++- .../fixtures/bin_oxlint_wrapper}/package.json | 0 .../bin_oxlint_wrapper/snapshots.toml | 11 ++ .../snapshots/bin_oxlint_wrapper.md | 28 +++- .../assert-shims.mjs | 0 .../snapshots.toml | 18 +++ .../command_env_setup_external_vp.md | 51 ++++++ .../fingerprint_ignore_test}/package.json | 0 .../fingerprint_ignore_test/snapshots.toml | 17 ++ .../fingerprint_ignore_test}/vite.config.ts | 0 .../npm-global-on-path-pkg/cli.js | 0 .../npm-global-on-path-pkg/package.json | 0 .../snapshots.toml | 16 ++ ...pm_global_install_custom_prefix_on_path.md | 29 ++++ .../shim_corepack_bundled/snapshots.toml | 10 ++ .../snapshots/shim_corepack_bundled.md | 33 ++++ .../fake-corepack.sh | 0 .../snapshots.toml | 17 ++ .../shim_corepack_enable_install_directory.md | 69 +++++++++ .../check-npm-version.mjs | 9 ++ .../package.json | 0 .../snapshots.toml | 21 +++ ...nloads_uncached_package_manager_version.md | 61 ++++++++ .../recursive-cli-pkg/cli.js | 0 .../recursive-cli-pkg/package.json | 0 .../snapshots.toml | 8 + .../shim_recursive_package_binary.md | 30 ++++ .../vitest_browser_mode}/package.json | 0 .../vitest_browser_mode/snapshots.toml | 14 ++ .../fixtures/vitest_browser_mode}/src/bar.js | 0 .../fixtures/vitest_browser_mode}/src/foo.js | 0 .../vitest_browser_mode}/src/foo.test.js | 0 .../vitest_browser_mode}/vite.config.ts | 0 .../vitest_browser_mode}/vitest.config.ts | 0 .../tests/cli_snapshots/main.rs | 67 +++++++- .../command-env-setup-external-vp/snap.txt | 10 -- .../command-env-setup-external-vp/steps.json | 15 -- .../snap.txt | 14 -- .../steps.json | 12 -- .../shim-corepack-bundled/snap.txt | 7 - .../shim-corepack-bundled/steps.json | 12 -- .../snap.txt | 19 --- .../steps.json | 18 --- .../.node-version | 1 - .../snap.txt | 19 --- .../steps.json | 15 -- .../.node-version | 1 - .../shim-recursive-package-binary/snap.txt | 11 -- .../shim-recursive-package-binary/steps.json | 8 - .../snap-tests/bin-oxfmt-wrapper/steps.json | 8 - .../snap-tests/bin-oxlint-wrapper/steps.json | 7 - .../fingerprint-ignore-test/snap.txt | 87 ----------- .../fingerprint-ignore-test/steps.json | 14 -- .../snap-tests/vitest-browser-mode/snap.txt | 40 ----- .../snap-tests/vitest-browser-mode/steps.json | 10 -- packages/tools/src/snap-test.ts | 7 + 63 files changed, 568 insertions(+), 535 deletions(-) delete mode 100755 .github/scripts/retry-failed-snap-tests.sh rename {packages/cli/snap-tests/bin-oxfmt-wrapper => crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxfmt_wrapper}/package.json (100%) create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxfmt_wrapper/snapshots.toml rename packages/cli/snap-tests/bin-oxfmt-wrapper/snap.txt => crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxfmt_wrapper/snapshots/bin_oxfmt_wrapper.md (90%) rename {packages/cli/snap-tests/bin-oxlint-wrapper => crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxlint_wrapper}/package.json (100%) create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxlint_wrapper/snapshots.toml rename packages/cli/snap-tests/bin-oxlint-wrapper/snap.txt => crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxlint_wrapper/snapshots/bin_oxlint_wrapper.md (95%) rename {packages/cli/snap-tests-global/command-env-setup-external-vp => crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/command_env_setup_external_vp}/assert-shims.mjs (100%) create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/command_env_setup_external_vp/snapshots.toml create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/command_env_setup_external_vp/snapshots/command_env_setup_external_vp.md rename {packages/cli/snap-tests/fingerprint-ignore-test => crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/fingerprint_ignore_test}/package.json (100%) create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/fingerprint_ignore_test/snapshots.toml rename {packages/cli/snap-tests/fingerprint-ignore-test => crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/fingerprint_ignore_test}/vite.config.ts (100%) rename {packages/cli/snap-tests-global/npm-global-install-custom-prefix-on-path => crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/npm_global_install_custom_prefix_on_path}/npm-global-on-path-pkg/cli.js (100%) rename {packages/cli/snap-tests-global/npm-global-install-custom-prefix-on-path => crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/npm_global_install_custom_prefix_on_path}/npm-global-on-path-pkg/package.json (100%) create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/npm_global_install_custom_prefix_on_path/snapshots.toml create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/npm_global_install_custom_prefix_on_path/snapshots/npm_global_install_custom_prefix_on_path.md create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_corepack_bundled/snapshots.toml create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_corepack_bundled/snapshots/shim_corepack_bundled.md rename {packages/cli/snap-tests-global/shim-corepack-enable-install-directory => crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_corepack_enable_install_directory}/fake-corepack.sh (100%) create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_corepack_enable_install_directory/snapshots.toml create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_corepack_enable_install_directory/snapshots/shim_corepack_enable_install_directory.md create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_npm_downloads_uncached_package_manager_version/check-npm-version.mjs rename {packages/cli/snap-tests-global/shim-npm-downloads-uncached-package-manager-version => crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_npm_downloads_uncached_package_manager_version}/package.json (100%) create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_npm_downloads_uncached_package_manager_version/snapshots.toml create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_npm_downloads_uncached_package_manager_version/snapshots/shim_npm_downloads_uncached_package_manager_version.md rename {packages/cli/snap-tests-global/shim-recursive-package-binary => crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_recursive_package_binary}/recursive-cli-pkg/cli.js (100%) rename {packages/cli/snap-tests-global/shim-recursive-package-binary => crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_recursive_package_binary}/recursive-cli-pkg/package.json (100%) create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_recursive_package_binary/snapshots.toml create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_recursive_package_binary/snapshots/shim_recursive_package_binary.md rename {packages/cli/snap-tests/vitest-browser-mode => crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/vitest_browser_mode}/package.json (100%) create mode 100644 crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/vitest_browser_mode/snapshots.toml rename {packages/cli/snap-tests/vitest-browser-mode => crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/vitest_browser_mode}/src/bar.js (100%) rename {packages/cli/snap-tests/vitest-browser-mode => crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/vitest_browser_mode}/src/foo.js (100%) rename {packages/cli/snap-tests/vitest-browser-mode => crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/vitest_browser_mode}/src/foo.test.js (100%) rename {packages/cli/snap-tests/vitest-browser-mode => crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/vitest_browser_mode}/vite.config.ts (100%) rename {packages/cli/snap-tests/vitest-browser-mode => crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/vitest_browser_mode}/vitest.config.ts (100%) delete mode 100644 packages/cli/snap-tests-global/command-env-setup-external-vp/snap.txt delete mode 100644 packages/cli/snap-tests-global/command-env-setup-external-vp/steps.json delete mode 100644 packages/cli/snap-tests-global/npm-global-install-custom-prefix-on-path/snap.txt delete mode 100644 packages/cli/snap-tests-global/npm-global-install-custom-prefix-on-path/steps.json delete mode 100644 packages/cli/snap-tests-global/shim-corepack-bundled/snap.txt delete mode 100644 packages/cli/snap-tests-global/shim-corepack-bundled/steps.json delete mode 100644 packages/cli/snap-tests-global/shim-corepack-enable-install-directory/snap.txt delete mode 100644 packages/cli/snap-tests-global/shim-corepack-enable-install-directory/steps.json delete mode 100644 packages/cli/snap-tests-global/shim-npm-downloads-uncached-package-manager-version/.node-version delete mode 100644 packages/cli/snap-tests-global/shim-npm-downloads-uncached-package-manager-version/snap.txt delete mode 100644 packages/cli/snap-tests-global/shim-npm-downloads-uncached-package-manager-version/steps.json delete mode 100644 packages/cli/snap-tests-global/shim-recursive-package-binary/.node-version delete mode 100644 packages/cli/snap-tests-global/shim-recursive-package-binary/snap.txt delete mode 100644 packages/cli/snap-tests-global/shim-recursive-package-binary/steps.json delete mode 100644 packages/cli/snap-tests/bin-oxfmt-wrapper/steps.json delete mode 100644 packages/cli/snap-tests/bin-oxlint-wrapper/steps.json delete mode 100644 packages/cli/snap-tests/fingerprint-ignore-test/snap.txt delete mode 100644 packages/cli/snap-tests/fingerprint-ignore-test/steps.json delete mode 100644 packages/cli/snap-tests/vitest-browser-mode/snap.txt delete mode 100644 packages/cli/snap-tests/vitest-browser-mode/steps.json diff --git a/.github/renovate.json b/.github/renovate.json index afdda01716..f772aca81d 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -4,14 +4,7 @@ "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.", "gitIgnoredAuthors": ["278573678+voidzero-guard[bot]@users.noreply.github.com"], "skipArtifactsUpdate": true, - "ignorePaths": [ - "packages/cli/snap-tests/**", - "packages/cli/snap-tests-global/**", - "packages/cli/snap-tests-todo/**", - "bench/fixtures/**", - "rolldown/**", - "vite/**" - ], + "ignorePaths": ["bench/fixtures/**", "rolldown/**", "vite/**"], "packageRules": [ { "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.", diff --git a/.github/scripts/retry-failed-snap-tests.sh b/.github/scripts/retry-failed-snap-tests.sh deleted file mode 100755 index 3610bf8411..0000000000 --- a/.github/scripts/retry-failed-snap-tests.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env bash -# Retry only the snap test cases whose snap.txt changed, up to max_retries times. -# Usage: retry-failed-snap-tests.sh [max_retries] -set -euo pipefail - -max_retries=${1:-2} - -for retry in $(seq 1 "$max_retries"); do - changed=$(git diff --name-only -- 'packages/cli/snap-tests*/*/snap.txt') - if [ -z "$changed" ]; then - exit 0 - fi - - echo "::warning::Snapshot diff detected, retry $retry/$max_retries for failed cases..." - git diff --stat -- 'packages/cli/snap-tests*/*/snap.txt' - - failed_local=$(echo "$changed" | grep -v 'snap-tests-global/' | sed -E 's|packages/cli/snap-tests/([^/]+)/.*|\1|' | sort -u || true) - failed_global=$(echo "$changed" | grep 'snap-tests-global/' | sed -E 's|packages/cli/snap-tests-global/([^/]+)/.*|\1|' | sort -u || true) - - echo "$changed" | xargs git checkout -- - - for name in $failed_local; do - echo "Retrying local snap test: $name" - RUST_BACKTRACE=1 pnpm -F ./packages/cli snap-test-local "$name" - done - for name in $failed_global; do - echo "Retrying global snap test: $name" - RUST_BACKTRACE=1 pnpm -F ./packages/cli snap-test-global "$name" - done -done - -# Final check after all retries -if ! git diff --quiet -- 'packages/cli/snap-tests*/*/snap.txt'; then - echo "::error::Snapshot diff detected after $max_retries retries. Run 'pnpm -F vite-plus snap-test' locally and commit the updated snap.txt files." - git diff --stat - git diff - exit 1 -fi diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 058673dbed..13b3141593 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -343,7 +343,7 @@ jobs: # Cross-compiles the Windows release NAPI binding (vite-plus .node) and CLI # binaries (vp.exe, vp-shim.exe, vp-setup.exe) on a fast Linux runner with # cargo-xwin, then publishes them as the windows-cli-binaries artifact. The - # Windows entries of cli-e2e-test, cli-snap-test, and install-e2e-test-sfw + # Windows entries of cli-e2e-test and install-e2e-test-sfw # download that artifact instead of each spending ~24 minutes rebuilding the # same binaries on slow windows-latest runners whenever build-upstream's # NAPI binding cache misses. Release builds are unaffected: they keep @@ -899,139 +899,6 @@ jobs: pnpm bootstrap-cli:ci vp --version - cli-snap-test: - name: CLI snap test (${{ matrix.target }}, ${{ matrix.shard }}/${{ matrix.shardTotal }}) - needs: - - download-previous-rolldown-binaries - - build-windows-cli - strategy: - fail-fast: false - matrix: - include: - - os: namespace-profile-linux-x64-default - target: x86_64-unknown-linux-gnu - shard: 1 - shardTotal: 3 - - os: namespace-profile-linux-x64-default - target: x86_64-unknown-linux-gnu - shard: 2 - shardTotal: 3 - - os: namespace-profile-linux-x64-default - target: x86_64-unknown-linux-gnu - shard: 3 - shardTotal: 3 - - os: namespace-profile-mac-default - target: aarch64-apple-darwin - shard: 1 - shardTotal: 3 - - os: namespace-profile-mac-default - target: aarch64-apple-darwin - shard: 2 - shardTotal: 3 - - os: namespace-profile-mac-default - target: aarch64-apple-darwin - shard: 3 - shardTotal: 3 - - os: namespace-profile-windows-4c-8g - target: x86_64-pc-windows-msvc - shard: 1 - shardTotal: 3 - - os: namespace-profile-windows-4c-8g - target: x86_64-pc-windows-msvc - shard: 2 - shardTotal: 3 - - os: namespace-profile-windows-4c-8g - target: x86_64-pc-windows-msvc - shard: 3 - shardTotal: 3 - runs-on: ${{ matrix.os }} - steps: - - uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2 - - uses: ./.github/actions/clone - - # Dev Drive works on the Namespace Windows runner: setup-dev-drive v4 - # creates and mounts its ReFS VHD on namespace-profile-windows-4c-8g, and - # all three Windows shards pass with this step succeeding (nested - # virtualization is available there). Only cli-snapshot-test-windows moved - # off Namespace, and for an unrelated reason (Session-0 ConPTY, see there). - - name: Setup Dev Drive - if: runner.os == 'Windows' - uses: samypr100/setup-dev-drive@30f0f98ae5636b2b6501e181dfb3631b9974818d # v4.0.0 - with: - drive-size: 12GB - drive-format: ReFS - # Route TEMP/TMP onto the Dev Drive (ReFS) so `tmpdir()` from - # `packages/tools/src/snap-test.ts` lives on a filesystem that - # cleanly resolves pnpm's junction reparse points. NTFS-on-C: - # preserves the junction-target backslashes during resolution, - # which produces mixed `\` / `/` paths that break Node's ESM - # subpath-import walk-up (`#module-sync-enabled` inside - # `@voidzero-dev/vite-plus-core` → `ERR_PACKAGE_IMPORT_NOT_DEFINED` - # during `vp fmt --write` in the - # `new-create-vite-migrates-eslint-prettier` snap test). - env-mapping: | - TEMP,{{ DEV_DRIVE }}/Temp - TMP,{{ DEV_DRIVE }}/Temp - - - name: Create TEMP/TMP on Dev Drive - if: runner.os == 'Windows' - # `setup-dev-drive` only mounts the drive; it doesn't create the - # dir we point TEMP/TMP at. Anything that calls `os.tmpdir()` / - # `lstat($TEMP)` before this dir exists fails (e.g. the bootstrap - # CLI installer's `lstat 'E:\Temp'` ENOENT). - shell: bash - run: mkdir -p "$TEMP" "$TMP" - - # Windows runs against the prebuilt binaries from build-windows-cli, - # so it needs no Rust toolchain here (the Dev Drive above stays for - # the TEMP/TMP routing). - - uses: oxc-project/setup-rust@68c3199c5339f965e6e163924c3c450773eba42b # main (pending v1.0.17 — Swatinem/rust-cache v2.9.1 for node24) - if: runner.os != 'Windows' - with: - save-cache: ${{ github.ref_name == 'main' }} - cache-key: cli-snap-test-${{ matrix.target }} - - - uses: oxc-project/setup-node@4c588e9266bd930b6ddc34307df0659ed511d187 # v1.3.1 - - - name: Install docs dependencies - run: pnpm -C docs install --frozen-lockfile - - - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 - with: - name: rolldown-binaries - path: ./rolldown/packages/rolldown/src - merge-multiple: true - - # See the cli-e2e-test job for details on the prebuilt binaries. - - name: Download prebuilt Windows binaries - if: runner.os == 'Windows' - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 - with: - name: windows-cli-binaries - - - name: Build with upstream - uses: ./.github/actions/build-upstream - with: - target: ${{ matrix.target }} - skip-native: ${{ runner.os == 'Windows' }} - - - name: Install Global CLI vp - run: | - pnpm bootstrap-cli:ci - if [[ "$RUNNER_OS" == "Windows" ]]; then - echo "$USERPROFILE\.vite-plus\bin" >> $GITHUB_PATH - else - echo "$HOME/.vite-plus/bin" >> $GITHUB_PATH - fi - - - name: Run CLI snapshot tests (shard ${{ matrix.shard }}/${{ matrix.shardTotal }}) - run: | - RUST_BACKTRACE=1 pnpm -F ./packages/cli snap-test-local --shard=${{ matrix.shard }}/${{ matrix.shardTotal }} - RUST_BACKTRACE=1 pnpm -F ./packages/cli snap-test-global --shard=${{ matrix.shard }}/${{ matrix.shardTotal }} - bash .github/scripts/retry-failed-snap-tests.sh - env: - RUST_MIN_STACK: 8388608 - # Runs the PTY snapshot suite (crates/vite_cli_snapshots) with BOTH vp # flavors on Linux and macOS: the local flavor uses the packages/cli build # from this job, the global flavor reuses the installed release binary via @@ -1115,9 +982,12 @@ jobs: - uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2 - uses: ./.github/actions/clone - # Same Dev Drive TEMP routing as cli-snap-test: staged fixture - # workspaces live under os.tmpdir() and must resolve pnpm junction - # reparse points cleanly (see that job for the full story). + # Route TEMP/TMP onto a Dev Drive (ReFS): staged fixture workspaces + # live under os.tmpdir() and must resolve pnpm junction reparse points + # cleanly. NTFS-on-C: preserves the junction-target backslashes during + # resolution, which produces mixed `\` / `/` paths that break Node's + # ESM subpath-import walk-up (`#module-sync-enabled` inside + # `@voidzero-dev/vite-plus-core` -> `ERR_PACKAGE_IMPORT_NOT_DEFINED`). - name: Setup Dev Drive uses: samypr100/setup-dev-drive@30f0f98ae5636b2b6501e181dfb3631b9974818d # v4.0.0 with: @@ -1267,7 +1137,6 @@ jobs: git config --global --add safe.directory /workspace RUST_BACKTRACE=1 pnpm test - bash .github/scripts/retry-failed-snap-tests.sh " install-e2e-test: @@ -1485,7 +1354,6 @@ jobs: - lint - cli-e2e-test - cli-e2e-test-musl - - cli-snap-test - cli-snapshot-test - cli-snapshot-test-windows # Skipped on unlabeled PRs; counted on push-to-main and labeled PRs. diff --git a/.github/workflows/upgrade-deps.yml b/.github/workflows/upgrade-deps.yml index ce995a62d1..12d7c47dfe 100644 --- a/.github/workflows/upgrade-deps.yml +++ b/.github/workflows/upgrade-deps.yml @@ -145,12 +145,11 @@ jobs: ### Final validation (this step is complete ONLY when all pass) 1. `just build` exits 0. 2. `pnpm bootstrap-cli:ci && pnpm test` exits 0. - 3. `git diff` on `packages/cli/snap-tests/**/snap.txt` and - `packages/cli/snap-tests-global/**/snap.txt` contains no real regressions. - IMPORTANT: `pnpm test` always exits 0 even when snap outputs differ, so you - MUST inspect the diff yourself. Cosmetic drift from the upgrade (e.g. a - bumped version string in help output) is acceptable; unexpected stack - traces, missing output, or diverging CLI behavior are regressions to fix. + 3. `just snapshot-test` exits 0. Snapshot mismatches fail the run with a + unified diff. Re-record with `UPDATE_SNAPSHOTS=1` only for cosmetic + drift from the upgrade (e.g. a bumped version string in help output); + unexpected stack traces, missing output, or diverging CLI behavior are + regressions to fix. 4. `git status --short` and `git diff --stat` have been inspected, and every changed file is intentional for the upgrade PR. Pay special attention to generated NAPI binding files, because later CI runs fail diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/README.md b/crates/vite_cli_snapshots/tests/cli_snapshots/README.md index 944519cdc8..be3cd51f13 100644 --- a/crates/vite_cli_snapshots/tests/cli_snapshots/README.md +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/README.md @@ -77,6 +77,9 @@ cwd = "packages/app" # optional, relative to the fixture root skip-platforms = ["windows"] # or { os = "linux", libc = "musl" } ignore = false # true: only runs with `-- --ignored` seed-runtime = true # false: start from an empty VP_HOME +link-node-modules = false # true: expose the run-root node_modules as + # the workspace's parent-dir node_modules, + # for `../node_modules/vite-plus/...` paths env = { MY_VAR = "1" } # case-wide env additions unset-env = ["SOME_VAR"] # remove baseline env entries steps = [ ... ] @@ -99,7 +102,11 @@ A step is a bare argv array or a table: { argv = ["vp", "create"], cwd = "sub", # per-step working dir comment = "...", # rendered under the step heading - envs = [["K", "V"]], # per-step env + envs = [["K", "V"]], # per-step env; values expand `${NAME}`: + # `${workspace}` is the step's working dir, + # any other name resolves from the case env + # (`PATH = "${workspace}/bin:${PATH}"` is + # the shell's `PATH="$(pwd)/bin:$PATH"`) timeout = 120000, # ms, default 50s snapshot = false, # omit the screen while the step succeeds # (failures always keep their output) diff --git a/packages/cli/snap-tests/bin-oxfmt-wrapper/package.json b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxfmt_wrapper/package.json similarity index 100% rename from packages/cli/snap-tests/bin-oxfmt-wrapper/package.json rename to crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxfmt_wrapper/package.json diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxfmt_wrapper/snapshots.toml b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxfmt_wrapper/snapshots.toml new file mode 100644 index 0000000000..8570017ff5 --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxfmt_wrapper/snapshots.toml @@ -0,0 +1,12 @@ +[[case]] +name = "bin_oxfmt_wrapper" +vp = "local" +# The wrapper is addressed by path through the workspace parent, the legacy +# runner's layout. +link-node-modules = true +steps = [ + { argv = ["node", "../node_modules/vite-plus/bin/oxfmt"], comment = "should reject non-LSP usage", continue-on-failure = true }, + { argv = ["node", "../node_modules/vite-plus/bin/oxfmt", "--help"], comment = "should reject non-LSP usage", continue-on-failure = true }, + { argv = ["node", "../node_modules/vite-plus/bin/oxfmt", "--lsp", "--help"], comment = "should allow LSP mode" }, + { argv = ["node", "../node_modules/vite-plus/bin/oxfmt", "--stdin-filepath=a.ts", "--help"], comment = "should allow Stdin mode" }, +] diff --git a/packages/cli/snap-tests/bin-oxfmt-wrapper/snap.txt b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxfmt_wrapper/snapshots/bin_oxfmt_wrapper.md similarity index 90% rename from packages/cli/snap-tests/bin-oxfmt-wrapper/snap.txt rename to crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxfmt_wrapper/snapshots/bin_oxfmt_wrapper.md index 19a1033b95..798d243a1f 100644 --- a/packages/cli/snap-tests/bin-oxfmt-wrapper/snap.txt +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxfmt_wrapper/snapshots/bin_oxfmt_wrapper.md @@ -1,12 +1,32 @@ -[1]> node ../node_modules/vite-plus/bin/oxfmt # should reject non-LSP usage +# bin_oxfmt_wrapper + +## `node ../node_modules/vite-plus/bin/oxfmt` + +should reject non-LSP usage + +**Exit code:** 1 + +``` This oxfmt wrapper is for IDE extension use only (lsp or stdin mode). To format your code, run: vp fmt +``` + +## `node ../node_modules/vite-plus/bin/oxfmt --help` + +should reject non-LSP usage -[1]> node ../node_modules/vite-plus/bin/oxfmt --help # should reject non-LSP usage +**Exit code:** 1 + +``` This oxfmt wrapper is for IDE extension use only (lsp or stdin mode). To format your code, run: vp fmt +``` + +## `node ../node_modules/vite-plus/bin/oxfmt --lsp --help` + +should allow LSP mode -> node ../node_modules/vite-plus/bin/oxfmt --lsp --help # should allow LSP mode +``` Usage: [-c=PATH] [PATH]... Mode Options: @@ -45,9 +65,13 @@ Available positional items: Available options: -h, --help Prints help information -V, --version Prints version information +``` +## `node ../node_modules/vite-plus/bin/oxfmt --stdin-filepath=a.ts --help` -> node ../node_modules/vite-plus/bin/oxfmt --stdin-filepath=a.ts --help # should allow Stdin mode +should allow Stdin mode + +``` Usage: [-c=PATH] [PATH]... Mode Options: @@ -86,4 +110,4 @@ Available positional items: Available options: -h, --help Prints help information -V, --version Prints version information - +``` diff --git a/packages/cli/snap-tests/bin-oxlint-wrapper/package.json b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxlint_wrapper/package.json similarity index 100% rename from packages/cli/snap-tests/bin-oxlint-wrapper/package.json rename to crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxlint_wrapper/package.json diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxlint_wrapper/snapshots.toml b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxlint_wrapper/snapshots.toml new file mode 100644 index 0000000000..2ca5c6de91 --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxlint_wrapper/snapshots.toml @@ -0,0 +1,11 @@ +[[case]] +name = "bin_oxlint_wrapper" +vp = "local" +# The wrapper is addressed by path through the workspace parent, the legacy +# runner's layout. +link-node-modules = true +steps = [ + { argv = ["node", "../node_modules/vite-plus/bin/oxlint"], comment = "should reject non-LSP usage", continue-on-failure = true }, + { argv = ["node", "../node_modules/vite-plus/bin/oxlint", "--help"], comment = "should reject non-LSP usage", continue-on-failure = true }, + { argv = ["node", "../node_modules/vite-plus/bin/oxlint", "--lsp", "--help"], comment = "should exercise import path" }, +] diff --git a/packages/cli/snap-tests/bin-oxlint-wrapper/snap.txt b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxlint_wrapper/snapshots/bin_oxlint_wrapper.md similarity index 95% rename from packages/cli/snap-tests/bin-oxlint-wrapper/snap.txt rename to crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxlint_wrapper/snapshots/bin_oxlint_wrapper.md index 0a790ac8fe..c4b9d4ac91 100644 --- a/packages/cli/snap-tests/bin-oxlint-wrapper/snap.txt +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/bin_oxlint_wrapper/snapshots/bin_oxlint_wrapper.md @@ -1,12 +1,32 @@ -[1]> node ../node_modules/vite-plus/bin/oxlint # should reject non-LSP usage +# bin_oxlint_wrapper + +## `node ../node_modules/vite-plus/bin/oxlint` + +should reject non-LSP usage + +**Exit code:** 1 + +``` This oxlint wrapper is for IDE extension use only (--lsp mode). To lint your code, run: vp lint +``` + +## `node ../node_modules/vite-plus/bin/oxlint --help` -[1]> node ../node_modules/vite-plus/bin/oxlint --help # should reject non-LSP usage +should reject non-LSP usage + +**Exit code:** 1 + +``` This oxlint wrapper is for IDE extension use only (--lsp mode). To lint your code, run: vp lint +``` + +## `node ../node_modules/vite-plus/bin/oxlint --lsp --help` -> node ../node_modules/vite-plus/bin/oxlint --lsp --help # should exercise import path +should exercise import path + +``` Usage: [-c=<./.oxlintrc.json>] [PATH]... Basic Configuration @@ -113,4 +133,4 @@ Available options: diagnostics) -h, --help Prints help information -V, --version Prints version information - +``` diff --git a/packages/cli/snap-tests-global/command-env-setup-external-vp/assert-shims.mjs b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/command_env_setup_external_vp/assert-shims.mjs similarity index 100% rename from packages/cli/snap-tests-global/command-env-setup-external-vp/assert-shims.mjs rename to crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/command_env_setup_external_vp/assert-shims.mjs diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/command_env_setup_external_vp/snapshots.toml b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/command_env_setup_external_vp/snapshots.toml new file mode 100644 index 0000000000..280c43ede5 --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/command_env_setup_external_vp/snapshots.toml @@ -0,0 +1,18 @@ +[[case]] +name = "command_env_setup_external_vp" +vp = "global" +skip-platforms = ["windows"] +steps = [ + { argv = ["vpt", "mkdir", "-p", "external", "home"], comment = "Prepare isolated external install and VP_HOME", snapshot = false }, + { argv = ["vpt", "cp", "$VP_HOME/bin/vp", "external/vp"], comment = "Simulate a Homebrew-style vp outside VP_HOME", snapshot = false }, + { argv = ["vpt", "chmod", "+x", "external/vp"], snapshot = false }, + { argv = ["vpt", "write-file", ".node-version", "22.18.0\n"], comment = "Project Node.js version", snapshot = false }, + { argv = ["vpt", "write-file", "home/js_runtime/node/22.18.0/bin/node", "#!/bin/sh\necho vp-managed-node-22.18.0\n"], comment = "Preinstall managed Node runtime", snapshot = false }, + { argv = ["vpt", "chmod", "+x", "home/js_runtime/node/22.18.0/bin/node"], snapshot = false }, + { argv = ["./external/vp", "env", "setup"], envs = [["VP_HOME", "${workspace}/home"]], comment = "Setup shims from external vp", snapshot = false }, + # The legacy step set VP_BYPASS to reach a system node, which the hermetic + # case PATH does not have; the node shim resolving the pinned 22.18.0 from + # the seeded runtime serves the same purpose (any node can run the asserts). + { argv = ["node", "assert-shims.mjs"], comment = "Shims should point to external vp, not VP_HOME/current/bin/vp" }, + { argv = ["node", "-v"], envs = [["VP_HOME", "${workspace}/home"], ["PATH", "${workspace}/home/bin:${PATH}"]], comment = "node shim uses the project version" }, +] diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/command_env_setup_external_vp/snapshots/command_env_setup_external_vp.md b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/command_env_setup_external_vp/snapshots/command_env_setup_external_vp.md new file mode 100644 index 0000000000..3d2caaf3cd --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/command_env_setup_external_vp/snapshots/command_env_setup_external_vp.md @@ -0,0 +1,51 @@ +# command_env_setup_external_vp + +## `vpt mkdir -p external home` + +Prepare isolated external install and VP_HOME + + +## `vpt cp $VP_HOME/bin/vp external/vp` + +Simulate a Homebrew-style vp outside VP_HOME + + +## `vpt chmod +x external/vp` + + +## `vpt write-file .node-version '22.18.0 +'` + +Project Node.js version + + +## `vpt write-file home/js_runtime/node/22.18.0/bin/node '#'\!'/bin/sh +echo vp-managed-node-22.18.0 +'` + +Preinstall managed Node runtime + + +## `vpt chmod +x home/js_runtime/node/22.18.0/bin/node` + + +## `VP_HOME=${workspace}/home ./external/vp env setup` + +Setup shims from external vp + + +## `node assert-shims.mjs` + +Shims should point to external vp, not VP_HOME/current/bin/vp + +``` +all shims point to external vp +``` + +## `VP_HOME=${workspace}/home PATH=${workspace}/home/bin:${PATH} node -v` + +node shim uses the project version + +``` +vp-managed-node-22.18.0 +``` diff --git a/packages/cli/snap-tests/fingerprint-ignore-test/package.json b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/fingerprint_ignore_test/package.json similarity index 100% rename from packages/cli/snap-tests/fingerprint-ignore-test/package.json rename to crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/fingerprint_ignore_test/package.json diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/fingerprint_ignore_test/snapshots.toml b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/fingerprint_ignore_test/snapshots.toml new file mode 100644 index 0000000000..6f73d9fe20 --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/fingerprint_ignore_test/snapshots.toml @@ -0,0 +1,17 @@ +# Disabled on every platform since the legacy suite (fingerprintIgnores is not +# yet supported in vite-task user config); no snapshot is recorded until the +# case is re-enabled. +[[case]] +name = "fingerprint_ignore_test" +vp = "local" +skip-platforms = ["linux", "windows", "macos"] +steps = [ + { argv = ["vp", "run", "create-files"], comment = "first run" }, + { argv = ["vp", "run", "create-files"], comment = "cache hit - no changes" }, + { argv = ["vpt", "write-file", "node_modules/pkg-a/index.js", "module.exports = {modified: true}\n"], snapshot = false }, + { argv = ["vp", "run", "create-files"], comment = "cache hit - index.js ignored" }, + { argv = ["vpt", "write-file", "dist/bundle.js", "modified output\n"], snapshot = false }, + { argv = ["vp", "run", "create-files"], comment = "cache hit - dist ignored" }, + { argv = ["vpt", "write-file", "node_modules/pkg-a/package.json", "{\"name\":\"pkg-a\",\"version\":\"2.0.0\"}\n"], snapshot = false }, + { argv = ["vp", "run", "create-files"], comment = "cache miss - package.json NOT ignored" }, +] diff --git a/packages/cli/snap-tests/fingerprint-ignore-test/vite.config.ts b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/fingerprint_ignore_test/vite.config.ts similarity index 100% rename from packages/cli/snap-tests/fingerprint-ignore-test/vite.config.ts rename to crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/fingerprint_ignore_test/vite.config.ts diff --git a/packages/cli/snap-tests-global/npm-global-install-custom-prefix-on-path/npm-global-on-path-pkg/cli.js b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/npm_global_install_custom_prefix_on_path/npm-global-on-path-pkg/cli.js similarity index 100% rename from packages/cli/snap-tests-global/npm-global-install-custom-prefix-on-path/npm-global-on-path-pkg/cli.js rename to crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/npm_global_install_custom_prefix_on_path/npm-global-on-path-pkg/cli.js diff --git a/packages/cli/snap-tests-global/npm-global-install-custom-prefix-on-path/npm-global-on-path-pkg/package.json b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/npm_global_install_custom_prefix_on_path/npm-global-on-path-pkg/package.json similarity index 100% rename from packages/cli/snap-tests-global/npm-global-install-custom-prefix-on-path/npm-global-on-path-pkg/package.json rename to crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/npm_global_install_custom_prefix_on_path/npm-global-on-path-pkg/package.json diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/npm_global_install_custom_prefix_on_path/snapshots.toml b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/npm_global_install_custom_prefix_on_path/snapshots.toml new file mode 100644 index 0000000000..a82b9cad48 --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/npm_global_install_custom_prefix_on_path/snapshots.toml @@ -0,0 +1,16 @@ +[[case]] +name = "npm_global_install_custom_prefix_on_path" +vp = "global" +serial = true +skip-platforms = ["windows"] +steps = [ + { argv = ["vpt", "mkdir", "-p", "custom-prefix-on-path/bin"], snapshot = false }, + { argv = ["npm", "install", "-g", "./npm-global-on-path-pkg"], envs = [["PATH", "${workspace}/custom-prefix-on-path/bin:${PATH}"], ["NPM_CONFIG_PREFIX", "${workspace}/custom-prefix-on-path"]], comment = "Should install without hint (bin dir on PATH)", tty = false }, + # npm installs package bins as symlinks; the legacy `test -f` followed them. + { argv = ["vpt", "stat-file", "custom-prefix-on-path/bin/npm-global-on-path-cli", "--assert", "symlink"], comment = "Verify installed to custom prefix" }, + { argv = ["vpt", "stat-file", "$VP_HOME/bin/npm-global-on-path-cli", "--assert", "missing"], comment = "No link should be created" }, +] +after = [ + { argv = ["npm", "uninstall", "-g", "npm-global-on-path-pkg"], envs = [["NPM_CONFIG_PREFIX", "${workspace}/custom-prefix-on-path"]] }, + { argv = ["vpt", "rm", "-rf", "custom-prefix-on-path"] }, +] diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/npm_global_install_custom_prefix_on_path/snapshots/npm_global_install_custom_prefix_on_path.md b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/npm_global_install_custom_prefix_on_path/snapshots/npm_global_install_custom_prefix_on_path.md new file mode 100644 index 0000000000..f6c4443a99 --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/npm_global_install_custom_prefix_on_path/snapshots/npm_global_install_custom_prefix_on_path.md @@ -0,0 +1,29 @@ +# npm_global_install_custom_prefix_on_path + +## `vpt mkdir -p custom-prefix-on-path/bin` + + +## `PATH=${workspace}/custom-prefix-on-path/bin:${PATH} NPM_CONFIG_PREFIX=${workspace}/custom-prefix-on-path npm install -g ./npm-global-on-path-pkg` + +Should install without hint (bin dir on PATH) + +``` + +added 1 package in +``` + +## `vpt stat-file custom-prefix-on-path/bin/npm-global-on-path-cli --assert symlink` + +Verify installed to custom prefix + +``` +custom-prefix-on-path/bin/npm-global-on-path-cli: symlink +``` + +## `vpt stat-file $VP_HOME/bin/npm-global-on-path-cli --assert missing` + +No link should be created + +``` +/.vite-plus/bin/npm-global-on-path-cli: missing +``` diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_corepack_bundled/snapshots.toml b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_corepack_bundled/snapshots.toml new file mode 100644 index 0000000000..a84d9285eb --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_corepack_bundled/snapshots.toml @@ -0,0 +1,10 @@ +[[case]] +name = "shim_corepack_bundled" +vp = "global" +skip-platforms = ["windows"] +steps = [ + { argv = ["vp", "remove", "-g", "corepack"], comment = "Isolate from a leftover managed corepack, which would win over the bundled one", snapshot = false, continue-on-failure = true }, + { argv = ["vpt", "write-file", ".node-version", "20.18.0\n"], comment = "Pin the project Node.js version", snapshot = false, continue-on-failure = true }, + { argv = ["vp", "env", "exec", "node", "--version"], comment = "Ensure Node.js is installed first", timeout = 120000 }, + { argv = ["corepack", "--version"], comment = "corepack shim runs the Node-bundled corepack" }, +] diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_corepack_bundled/snapshots/shim_corepack_bundled.md b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_corepack_bundled/snapshots/shim_corepack_bundled.md new file mode 100644 index 0000000000..541eaec651 --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_corepack_bundled/snapshots/shim_corepack_bundled.md @@ -0,0 +1,33 @@ +# shim_corepack_bundled + +## `vp remove -g corepack` + +Isolate from a leftover managed corepack, which would win over the bundled one + +**Exit code:** 1 + +``` +Failed to uninstall corepack: Package corepack is not installed +``` + +## `vpt write-file .node-version '20.18.0 +'` + +Pin the project Node.js version + + +## `vp env exec node --version` + +Ensure Node.js is installed first + +``` + +``` + +## `corepack --version` + +corepack shim runs the Node-bundled corepack + +``` +0.29.3 +``` diff --git a/packages/cli/snap-tests-global/shim-corepack-enable-install-directory/fake-corepack.sh b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_corepack_enable_install_directory/fake-corepack.sh similarity index 100% rename from packages/cli/snap-tests-global/shim-corepack-enable-install-directory/fake-corepack.sh rename to crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_corepack_enable_install_directory/fake-corepack.sh diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_corepack_enable_install_directory/snapshots.toml b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_corepack_enable_install_directory/snapshots.toml new file mode 100644 index 0000000000..0f31a1c51c --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_corepack_enable_install_directory/snapshots.toml @@ -0,0 +1,17 @@ +[[case]] +name = "shim_corepack_enable_install_directory" +vp = "global" +skip-platforms = ["windows"] +steps = [ + { argv = ["vpt", "mkdir", "-p", "home/js_runtime/node/22.18.0/bin"], comment = "Isolated VP_HOME with a fake managed Node runtime layout", snapshot = false }, + { argv = ["vpt", "write-file", ".node-version", "22.18.0\n"], comment = "Project Node.js version", snapshot = false }, + { argv = ["vpt", "write-file", "home/js_runtime/node/22.18.0/bin/node", "#!/bin/sh\necho fake-node\n"], comment = "Fake node binary", snapshot = false }, + { argv = ["vpt", "chmod", "+x", "home/js_runtime/node/22.18.0/bin/node"], snapshot = false }, + { argv = ["vpt", "cp", "fake-corepack.sh", "home/js_runtime/node/22.18.0/bin/corepack"], comment = "Fake bundled corepack that echoes its args", snapshot = false }, + { argv = ["vpt", "chmod", "+x", "home/js_runtime/node/22.18.0/bin/corepack"], snapshot = false }, + { argv = ["vp", "env", "setup"], envs = [["VP_HOME", "${workspace}/home"]], comment = "Create shims in the isolated home", snapshot = false }, + { argv = ["corepack", "use", "pnpm@10"], envs = [["VP_HOME", "${workspace}/home"], ["PATH", "${workspace}/home/bin:${PATH}"]], comment = "Non-link commands run unchanged" }, + { argv = ["corepack", "enable", "--install-directory", "/tmp/custom-dir"], envs = [["VP_HOME", "${workspace}/home"], ["PATH", "${workspace}/home/bin:${PATH}"]], comment = "Explicit --install-directory is respected, clobbered npm shim is restored" }, + { argv = ["corepack", "enable"], envs = [["VP_HOME", "${workspace}/home"], ["PATH", "${workspace}/home/bin:${PATH}"]], comment = "--install-directory defaults to VP_HOME/bin" }, + { argv = ["vpt", "stat-file", "home/bin/npm", "--assert", "symlink"], comment = "Vite+ owns the npm shim" }, +] diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_corepack_enable_install_directory/snapshots/shim_corepack_enable_install_directory.md b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_corepack_enable_install_directory/snapshots/shim_corepack_enable_install_directory.md new file mode 100644 index 0000000000..d66cf17ca4 --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_corepack_enable_install_directory/snapshots/shim_corepack_enable_install_directory.md @@ -0,0 +1,69 @@ +# shim_corepack_enable_install_directory + +## `vpt mkdir -p home/js_runtime/node/22.18.0/bin` + +Isolated VP_HOME with a fake managed Node runtime layout + + +## `vpt write-file .node-version '22.18.0 +'` + +Project Node.js version + + +## `vpt write-file home/js_runtime/node/22.18.0/bin/node '#'\!'/bin/sh +echo fake-node +'` + +Fake node binary + + +## `vpt chmod +x home/js_runtime/node/22.18.0/bin/node` + + +## `vpt cp fake-corepack.sh home/js_runtime/node/22.18.0/bin/corepack` + +Fake bundled corepack that echoes its args + + +## `vpt chmod +x home/js_runtime/node/22.18.0/bin/corepack` + + +## `VP_HOME=${workspace}/home vp env setup` + +Create shims in the isolated home + + +## `VP_HOME=${workspace}/home PATH=${workspace}/home/bin:${PATH} corepack use pnpm@10` + +Non-link commands run unchanged + +``` +corepack use pnpm@10 +``` + +## `VP_HOME=${workspace}/home PATH=${workspace}/home/bin:${PATH} corepack enable --install-directory /tmp/custom-dir` + +Explicit --install-directory is respected, clobbered npm shim is restored + +``` +corepack enable --install-directory /tmp/custom-dir +warn: 'npm' is managed by Vite+ and was restored. Vite+ already resolves 'npm' per project, so corepack does not need to manage it. +``` + +## `VP_HOME=${workspace}/home PATH=${workspace}/home/bin:${PATH} corepack enable` + +--install-directory defaults to VP_HOME/bin + +``` +corepack enable --install-directory /home/bin +warn: 'npm' is managed by Vite+ and was restored. Vite+ already resolves 'npm' per project, so corepack does not need to manage it. +``` + +## `vpt stat-file home/bin/npm --assert symlink` + +Vite+ owns the npm shim + +``` +home/bin/npm: symlink +``` diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_npm_downloads_uncached_package_manager_version/check-npm-version.mjs b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_npm_downloads_uncached_package_manager_version/check-npm-version.mjs new file mode 100644 index 0000000000..2250447f9d --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_npm_downloads_uncached_package_manager_version/check-npm-version.mjs @@ -0,0 +1,9 @@ +import { execSync } from 'node:child_process'; + +const [expected, message] = process.argv.slice(2); +const version = execSync('npm --version', { encoding: 'utf8' }).trim(); +if (version !== expected) { + console.error(`npm --version printed ${version}, expected ${expected}`); + process.exit(1); +} +console.log(message); diff --git a/packages/cli/snap-tests-global/shim-npm-downloads-uncached-package-manager-version/package.json b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_npm_downloads_uncached_package_manager_version/package.json similarity index 100% rename from packages/cli/snap-tests-global/shim-npm-downloads-uncached-package-manager-version/package.json rename to crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_npm_downloads_uncached_package_manager_version/package.json diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_npm_downloads_uncached_package_manager_version/snapshots.toml b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_npm_downloads_uncached_package_manager_version/snapshots.toml new file mode 100644 index 0000000000..25fba3e5cf --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_npm_downloads_uncached_package_manager_version/snapshots.toml @@ -0,0 +1,21 @@ +[[case]] +name = "shim_npm_downloads_uncached_package_manager_version" +vp = "global" +serial = true +# seed-runtime = false: the case deletes and re-downloads pinned runtime +# versions, which must never reach the shared seed through the symlink. +seed-runtime = false +skip-platforms = ["windows"] +steps = [ + # The legacy case inherited node 22.11.0 as the environment's default; the + # hermetic case pins it explicitly so the shim's node choice cannot drift. + { argv = ["vpt", "write-file", ".node-version", "22.11.0\n"], comment = "Pin the project Node.js version", snapshot = false }, + { argv = ["vpt", "rm", "-rf", "$VP_HOME/js_runtime/node/22.11.0"], comment = "Ensure pinned Node.js is not cached", snapshot = false, continue-on-failure = true }, + { argv = ["vpt", "rm", "-rf", "$VP_HOME/package_manager/npm/10.5.0", "$VP_HOME/package_manager/npm/10.5.0.lock"], comment = "Ensure pinned npm is not cached", snapshot = false, continue-on-failure = true }, + { argv = ["vpt", "stat-file", "$VP_HOME/js_runtime/node/22.11.0", "--assert", "missing"], comment = "pinned Node.js@22.11.0 is uncached" }, + { argv = ["vpt", "stat-file", "$VP_HOME/package_manager/npm/10.5.0", "--assert", "missing"], comment = "pinned npm@10.5.0 is uncached" }, + { argv = ["node", "check-npm-version.mjs", "10.5.0", "npm shim auto-downloaded Node.js and packageManager on first invocation"], timeout = 120000 }, + { argv = ["vpt", "stat-file", "$VP_HOME/js_runtime/node/22.11.0/bin/node", "--assert", "file"], comment = "pinned Node.js@22.11.0 is now cached" }, + { argv = ["vpt", "stat-file", "$VP_HOME/package_manager/npm/10.5.0/npm/bin/npm", "--assert", "file"], comment = "pinned npm@10.5.0 is now cached" }, + { argv = ["node", "check-npm-version.mjs", "10.5.0", "subsequent invocations reuse the cached version"] }, +] diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_npm_downloads_uncached_package_manager_version/snapshots/shim_npm_downloads_uncached_package_manager_version.md b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_npm_downloads_uncached_package_manager_version/snapshots/shim_npm_downloads_uncached_package_manager_version.md new file mode 100644 index 0000000000..ab2fd82460 --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_npm_downloads_uncached_package_manager_version/snapshots/shim_npm_downloads_uncached_package_manager_version.md @@ -0,0 +1,61 @@ +# shim_npm_downloads_uncached_package_manager_version + +## `vpt write-file .node-version '22.11.0 +'` + +Pin the project Node.js version + + +## `vpt rm -rf $VP_HOME/js_runtime/node/22.11.0` + +Ensure pinned Node.js is not cached + + +## `vpt rm -rf $VP_HOME/package_manager/npm/10.5.0 $VP_HOME/package_manager/npm/10.5.0.lock` + +Ensure pinned npm is not cached + + +## `vpt stat-file $VP_HOME/js_runtime/node/22.11.0 --assert missing` + +pinned Node.js@22.11.0 is uncached + +``` +/.vite-plus/js_runtime/node/: missing +``` + +## `vpt stat-file $VP_HOME/package_manager/npm/10.5.0 --assert missing` + +pinned npm@10.5.0 is uncached + +``` +/.vite-plus/package_manager/npm/: missing +``` + +## `node check-npm-version.mjs 10.5.0 'npm shim auto-downloaded Node.js and packageManager on first invocation'` + +``` +npm shim auto-downloaded Node.js and packageManager on first invocation +``` + +## `vpt stat-file $VP_HOME/js_runtime/node/22.11.0/bin/node --assert file` + +pinned Node.js@22.11.0 is now cached + +``` +/.vite-plus/js_runtime/node//bin/node: file +``` + +## `vpt stat-file $VP_HOME/package_manager/npm/10.5.0/npm/bin/npm --assert file` + +pinned npm@10.5.0 is now cached + +``` +/.vite-plus/package_manager/npm//npm/bin/npm: file +``` + +## `node check-npm-version.mjs 10.5.0 'subsequent invocations reuse the cached version'` + +``` +subsequent invocations reuse the cached version +``` diff --git a/packages/cli/snap-tests-global/shim-recursive-package-binary/recursive-cli-pkg/cli.js b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_recursive_package_binary/recursive-cli-pkg/cli.js similarity index 100% rename from packages/cli/snap-tests-global/shim-recursive-package-binary/recursive-cli-pkg/cli.js rename to crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_recursive_package_binary/recursive-cli-pkg/cli.js diff --git a/packages/cli/snap-tests-global/shim-recursive-package-binary/recursive-cli-pkg/package.json b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_recursive_package_binary/recursive-cli-pkg/package.json similarity index 100% rename from packages/cli/snap-tests-global/shim-recursive-package-binary/recursive-cli-pkg/package.json rename to crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_recursive_package_binary/recursive-cli-pkg/package.json diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_recursive_package_binary/snapshots.toml b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_recursive_package_binary/snapshots.toml new file mode 100644 index 0000000000..abf318cf4f --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_recursive_package_binary/snapshots.toml @@ -0,0 +1,8 @@ +[[case]] +name = "shim_recursive_package_binary" +vp = "global" +steps = [ + { argv = ["vp", "install", "-g", "./recursive-cli-pkg"], comment = "Install test package" }, + { argv = ["recursive-cli"], comment = "Outer call triggers recursive inner call through shim" }, + { argv = ["vp", "remove", "-g", "recursive-cli-pkg"], comment = "Cleanup" }, +] diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_recursive_package_binary/snapshots/shim_recursive_package_binary.md b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_recursive_package_binary/snapshots/shim_recursive_package_binary.md new file mode 100644 index 0000000000..e2ba0ca041 --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/shim_recursive_package_binary/snapshots/shim_recursive_package_binary.md @@ -0,0 +1,30 @@ +# shim_recursive_package_binary + +## `vp install -g ./recursive-cli-pkg` + +Install test package + +``` +VITE+ - The Unified Toolchain for the Web + +info: Installing 1 global package with Node.js +✓ Installed recursive-cli-pkg 1.0.0 + Bins: recursive-cli +``` + +## `recursive-cli` + +Outer call triggers recursive inner call through shim + +``` +outer call +inner call succeeded +``` + +## `vp remove -g recursive-cli-pkg` + +Cleanup + +``` +Uninstalled recursive-cli-pkg +``` diff --git a/packages/cli/snap-tests/vitest-browser-mode/package.json b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/vitest_browser_mode/package.json similarity index 100% rename from packages/cli/snap-tests/vitest-browser-mode/package.json rename to crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/vitest_browser_mode/package.json diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/vitest_browser_mode/snapshots.toml b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/vitest_browser_mode/snapshots.toml new file mode 100644 index 0000000000..efd8df033a --- /dev/null +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/vitest_browser_mode/snapshots.toml @@ -0,0 +1,14 @@ +# Disabled on every platform since the legacy suite; no snapshot is recorded +# until the case is re-enabled. The legacy `echo //comment >> src/foo.js` +# appends became write-file steps carrying the full appended content. +[[case]] +name = "vitest_browser_mode" +vp = "local" +skip-platforms = ["linux", "windows", "macos"] +steps = [ + { argv = ["vp", "run", "test"] }, + { argv = ["vpt", "write-file", "src/foo.js", "export default 'foo';\n//comment\n"], snapshot = false }, + { argv = ["vp", "run", "test"] }, + { argv = ["vpt", "write-file", "src/bar.js", "export default 'bar';\n//comment\n"], snapshot = false }, + { argv = ["vp", "run", "test"] }, +] diff --git a/packages/cli/snap-tests/vitest-browser-mode/src/bar.js b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/vitest_browser_mode/src/bar.js similarity index 100% rename from packages/cli/snap-tests/vitest-browser-mode/src/bar.js rename to crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/vitest_browser_mode/src/bar.js diff --git a/packages/cli/snap-tests/vitest-browser-mode/src/foo.js b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/vitest_browser_mode/src/foo.js similarity index 100% rename from packages/cli/snap-tests/vitest-browser-mode/src/foo.js rename to crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/vitest_browser_mode/src/foo.js diff --git a/packages/cli/snap-tests/vitest-browser-mode/src/foo.test.js b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/vitest_browser_mode/src/foo.test.js similarity index 100% rename from packages/cli/snap-tests/vitest-browser-mode/src/foo.test.js rename to crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/vitest_browser_mode/src/foo.test.js diff --git a/packages/cli/snap-tests/vitest-browser-mode/vite.config.ts b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/vitest_browser_mode/vite.config.ts similarity index 100% rename from packages/cli/snap-tests/vitest-browser-mode/vite.config.ts rename to crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/vitest_browser_mode/vite.config.ts diff --git a/packages/cli/snap-tests/vitest-browser-mode/vitest.config.ts b/crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/vitest_browser_mode/vitest.config.ts similarity index 100% rename from packages/cli/snap-tests/vitest-browser-mode/vitest.config.ts rename to crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/vitest_browser_mode/vitest.config.ts diff --git a/crates/vite_cli_snapshots/tests/cli_snapshots/main.rs b/crates/vite_cli_snapshots/tests/cli_snapshots/main.rs index fe853a472f..0572c62e3a 100644 --- a/crates/vite_cli_snapshots/tests/cli_snapshots/main.rs +++ b/crates/vite_cli_snapshots/tests/cli_snapshots/main.rs @@ -348,6 +348,13 @@ struct Case { /// provisioning tests set false to start from a genuinely empty home. #[serde(default = "default_true", rename = "seed-runtime")] seed_runtime: bool, + /// Expose the run-root node_modules as the workspace's parent-dir + /// node_modules (the legacy runner's layout), for fixtures that address + /// the linked checkout packages by path (`node + /// ../node_modules/vite-plus/bin/oxlint`) rather than by specifier + /// through Node's upward walk. + #[serde(default, rename = "link-node-modules")] + link_node_modules: bool, /// Case-wide environment additions on top of the runner baseline. #[serde(default)] env: BTreeMap, @@ -446,9 +453,12 @@ impl CaseInstall { // An explicit `./`-prefixed program runs a file the case itself // produced inside the staged workspace (a packed executable); the - // prefix keeps bare names on the PATH rule below. - if program.starts_with("./") { - let candidate = cwd.join(program); + // prefix keeps bare names on the PATH rule below. The prefix is + // dropped from the joined path: a `/./` component would survive into + // output that records the executable's own path (`vp env setup` + // writes shim targets from it). + if let Some(rel) = program.strip_prefix("./") { + let candidate = cwd.join(rel); if candidate.is_file() { return Ok(candidate); } @@ -517,12 +527,19 @@ impl CaseHome { self.run_env_setup(&vp)?; let vp_bin_dir = self.vp_home().join("bin"); - let tool_dirs = match flavor { + let mut tool_dirs = match flavor { Flavor::Global => vec![vp_bin_dir], Flavor::Local => vec![local_bin_dir, vp_bin_dir], }; let mut path_dirs = vec![runtime.runner_bin_dir.clone()]; path_dirs.extend(tool_dirs.iter().cloned()); + // The whole case root is case-owned for resolution (not PATH): a + // fixture that runs `vp env setup` against an isolated + // `VP_HOME=${workspace}/home` then invokes the shims it created + // through a per-step PATH prefix. + if let Some(case_root) = self.home.parent() { + tool_dirs.push(case_root.to_path_buf()); + } Ok(CaseInstall { path_env: compose_path_env(&path_dirs), @@ -792,6 +809,35 @@ fn wait_with_deadline( /// Effective env, cwd, and resolved program for one step; shared by the /// main and cleanup loops so their semantics cannot drift. +/// Expands `${NAME}` references in a step env value. `${workspace}` resolves +/// to the step's working directory and any other name to the case env, so a +/// fixture can express the shell forms `VP_HOME="$(pwd)/home"` and +/// `PATH="$(pwd)/home/bin:$PATH"` without a shell. Unknown names stay +/// verbatim, like vpt's argument expansion. +fn expand_env_value(value: &str, cwd: &Path, case_env: &BTreeMap) -> OsString { + let mut out = OsString::new(); + let mut rest = value; + while let Some(start) = rest.find("${") { + let (before, from_ref) = rest.split_at(start); + out.push(before); + let Some(end) = from_ref.find('}') else { + rest = from_ref; + break; + }; + let name = &from_ref[2..end]; + if name == "workspace" { + out.push(cwd.as_os_str()); + } else if let Some(resolved) = case_env.get(name) { + out.push(resolved); + } else { + out.push(&from_ref[..=end]); + } + rest = &from_ref[end + 1..]; + } + out.push(rest); + out +} + fn step_context<'a>( step: &Step, case_env: &'a BTreeMap, @@ -802,13 +848,20 @@ fn step_context<'a>( ) -> Result<(std::borrow::Cow<'a, BTreeMap>, PathBuf, PathBuf), String> { use std::borrow::Cow; assert!(!step.argv.is_empty(), "step argv must not be empty"); + // The empty relative dir maps to the stage itself rather than through + // `join("")`, whose trailing separator would leak into `${workspace}` + // expansions (`//home`). + let rel_cwd = step.cwd.as_deref().unwrap_or(case_cwd); + let cwd = if rel_cwd.is_empty() { stage.to_path_buf() } else { stage.join(rel_cwd) }; // Most steps add no env of their own; borrow the case env then. let env: Cow<'a, BTreeMap> = if step.envs.is_empty() { Cow::Borrowed(case_env) } else { let mut env = case_env.clone(); for (k, v) in &step.envs { - env.insert(k.clone(), v.into()); + // References resolve against the case env, never a sibling step + // env, so the entries stay order-independent. + env.insert(k.clone(), expand_env_value(v, &cwd, case_env)); } Cow::Owned(env) }; @@ -816,7 +869,6 @@ fn step_context<'a>( // (relative PATH entries resolve as the child would see them), so shim // and custom-prefix steps run exactly the child's tool. let path = env.get("PATH").cloned().unwrap_or_else(|| case_path.clone()); - let cwd = stage.join(step.cwd.as_deref().unwrap_or(case_cwd)); let program = install.resolve_program(&step.argv[0], &path, &cwd)?; Ok((env, cwd, program)) } @@ -1016,6 +1068,9 @@ fn run_case( let case_root = tmpdir.join(format!("{fixture_name}_case_{case_index}_{}", flavor.as_str())); let stage = case_root.join("workspace"); std::fs::create_dir_all(&stage).unwrap(); + if case.link_node_modules { + flavor::link_dir(&tmpdir.join("node_modules"), &case_root.join("node_modules")); + } // The case definition and recorded snapshots are runner metadata, not // part of the workspace under test, so they are never copied in. CopyOptions::new() diff --git a/packages/cli/snap-tests-global/command-env-setup-external-vp/snap.txt b/packages/cli/snap-tests-global/command-env-setup-external-vp/snap.txt deleted file mode 100644 index 5e7610ce53..0000000000 --- a/packages/cli/snap-tests-global/command-env-setup-external-vp/snap.txt +++ /dev/null @@ -1,10 +0,0 @@ -> mkdir -p external home # Prepare isolated external install and VP_HOME -> cp "$VP_HOME/bin/vp" external/vp && chmod +x external/vp # Simulate a Homebrew-style vp outside VP_HOME -> printf '22.18.0\n' > .node-version # Project Node.js version -> mkdir -p home/js_runtime/node/22.18.0/bin && printf '#!/bin/sh\necho vp-managed-node-22.18.0\n' > home/js_runtime/node/22.18.0/bin/node && chmod +x home/js_runtime/node/22.18.0/bin/node # Preinstall managed Node runtime -> VP_HOME="$(pwd)/home" ./external/vp env setup # Setup shims from external vp -> VP_BYPASS="$VP_HOME/bin" node assert-shims.mjs # Shims should point to external vp, not VP_HOME/current/bin/vp -all shims point to external vp - -> VP_HOME="$(pwd)/home" PATH="$(pwd)/home/bin:$PATH" node -v # node shim uses the project version -vp-managed-node-22.18.0 diff --git a/packages/cli/snap-tests-global/command-env-setup-external-vp/steps.json b/packages/cli/snap-tests-global/command-env-setup-external-vp/steps.json deleted file mode 100644 index f7765404d3..0000000000 --- a/packages/cli/snap-tests-global/command-env-setup-external-vp/steps.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "ignoredPlatforms": ["win32"], - "commands": [ - "mkdir -p external home # Prepare isolated external install and VP_HOME", - "cp \"$VP_HOME/bin/vp\" external/vp && chmod +x external/vp # Simulate a Homebrew-style vp outside VP_HOME", - "printf '22.18.0\\n' > .node-version # Project Node.js version", - "mkdir -p home/js_runtime/node/22.18.0/bin && printf '#!/bin/sh\\necho vp-managed-node-22.18.0\\n' > home/js_runtime/node/22.18.0/bin/node && chmod +x home/js_runtime/node/22.18.0/bin/node # Preinstall managed Node runtime", - { - "command": "VP_HOME=\"$(pwd)/home\" ./external/vp env setup # Setup shims from external vp", - "ignoreOutput": true - }, - "VP_BYPASS=\"$VP_HOME/bin\" node assert-shims.mjs # Shims should point to external vp, not VP_HOME/current/bin/vp", - "VP_HOME=\"$(pwd)/home\" PATH=\"$(pwd)/home/bin:$PATH\" node -v # node shim uses the project version" - ] -} diff --git a/packages/cli/snap-tests-global/npm-global-install-custom-prefix-on-path/snap.txt b/packages/cli/snap-tests-global/npm-global-install-custom-prefix-on-path/snap.txt deleted file mode 100644 index a6957ef7b2..0000000000 --- a/packages/cli/snap-tests-global/npm-global-install-custom-prefix-on-path/snap.txt +++ /dev/null @@ -1,14 +0,0 @@ -> mkdir -p custom-prefix-on-path/bin -> PATH=$(pwd)/custom-prefix-on-path/bin:$PATH NPM_CONFIG_PREFIX=$(pwd)/custom-prefix-on-path npm install -g ./npm-global-on-path-pkg # Should install without hint (bin dir on PATH) - -added 1 package in ms - -> test -f custom-prefix-on-path/bin/npm-global-on-path-cli && echo 'binary in custom prefix' # Verify installed to custom prefix -binary in custom prefix - -> test ! -L $VP_HOME/bin/npm-global-on-path-cli && echo 'no link created' # No link should be created -no link created - -> NPM_CONFIG_PREFIX=$(pwd)/custom-prefix-on-path npm uninstall -g npm-global-on-path-pkg; rm -rf custom-prefix-on-path # Cleanup - -removed 1 package in ms diff --git a/packages/cli/snap-tests-global/npm-global-install-custom-prefix-on-path/steps.json b/packages/cli/snap-tests-global/npm-global-install-custom-prefix-on-path/steps.json deleted file mode 100644 index 385b6fd50f..0000000000 --- a/packages/cli/snap-tests-global/npm-global-install-custom-prefix-on-path/steps.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "env": {}, - "serial": true, - "ignoredPlatforms": ["win32"], - "commands": [ - "mkdir -p custom-prefix-on-path/bin", - "PATH=$(pwd)/custom-prefix-on-path/bin:$PATH NPM_CONFIG_PREFIX=$(pwd)/custom-prefix-on-path npm install -g ./npm-global-on-path-pkg # Should install without hint (bin dir on PATH)", - "test -f custom-prefix-on-path/bin/npm-global-on-path-cli && echo 'binary in custom prefix' # Verify installed to custom prefix", - "test ! -L $VP_HOME/bin/npm-global-on-path-cli && echo 'no link created' # No link should be created", - "NPM_CONFIG_PREFIX=$(pwd)/custom-prefix-on-path npm uninstall -g npm-global-on-path-pkg; rm -rf custom-prefix-on-path # Cleanup" - ] -} diff --git a/packages/cli/snap-tests-global/shim-corepack-bundled/snap.txt b/packages/cli/snap-tests-global/shim-corepack-bundled/snap.txt deleted file mode 100644 index 90ed55a161..0000000000 --- a/packages/cli/snap-tests-global/shim-corepack-bundled/snap.txt +++ /dev/null @@ -1,7 +0,0 @@ -> vp remove -g corepack >/dev/null 2>&1 || true # Isolate from a leftover managed corepack, which would win over the bundled one -> printf '20.18.0\n' > .node-version # Pin the project Node.js version -> vp env exec node --version # Ensure Node.js is installed first -v20.18.0 - -> corepack --version # corepack shim runs the Node-bundled corepack -0.29.3 diff --git a/packages/cli/snap-tests-global/shim-corepack-bundled/steps.json b/packages/cli/snap-tests-global/shim-corepack-bundled/steps.json deleted file mode 100644 index ad33f9ce5e..0000000000 --- a/packages/cli/snap-tests-global/shim-corepack-bundled/steps.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "ignoredPlatforms": ["win32"], - "commands": [ - { - "command": "vp remove -g corepack >/dev/null 2>&1 || true # Isolate from a leftover managed corepack, which would win over the bundled one", - "ignoreOutput": true - }, - "printf '20.18.0\\n' > .node-version # Pin the project Node.js version", - "vp env exec node --version # Ensure Node.js is installed first", - "corepack --version # corepack shim runs the Node-bundled corepack" - ] -} diff --git a/packages/cli/snap-tests-global/shim-corepack-enable-install-directory/snap.txt b/packages/cli/snap-tests-global/shim-corepack-enable-install-directory/snap.txt deleted file mode 100644 index 66c806b998..0000000000 --- a/packages/cli/snap-tests-global/shim-corepack-enable-install-directory/snap.txt +++ /dev/null @@ -1,19 +0,0 @@ -> mkdir -p home # Isolated VP_HOME -> printf '22.18.0\n' > .node-version # Project Node.js version -> mkdir -p home/js_runtime/node/22.18.0/bin # Fake managed Node runtime layout -> printf '#!/bin/sh\necho fake-node\n' > home/js_runtime/node/22.18.0/bin/node && chmod +x home/js_runtime/node/22.18.0/bin/node # Fake node binary -> cp fake-corepack.sh home/js_runtime/node/22.18.0/bin/corepack && chmod +x home/js_runtime/node/22.18.0/bin/corepack # Fake bundled corepack that echoes its args -> VP_HOME="$(pwd)/home" vp env setup # Create shims in the isolated home -> VP_HOME="$(pwd)/home" PATH="$(pwd)/home/bin:$PATH" corepack use pnpm@10 # Non-link commands run unchanged -corepack use pnpm@10 - -> VP_HOME="$(pwd)/home" PATH="$(pwd)/home/bin:$PATH" corepack enable --install-directory /tmp/custom-dir # Explicit --install-directory is respected, clobbered npm shim is restored -corepack enable --install-directory /tmp/custom-dir -warn: 'npm' is managed by Vite+ and was restored. Vite+ already resolves 'npm' per project, so corepack does not need to manage it. - -> VP_HOME="$(pwd)/home" PATH="$(pwd)/home/bin:$PATH" corepack enable # --install-directory defaults to VP_HOME/bin -corepack enable --install-directory /home/bin -warn: 'npm' is managed by Vite+ and was restored. Vite+ already resolves 'npm' per project, so corepack does not need to manage it. - -> test -L home/bin/npm && echo 'npm shim restored' # Vite+ owns the npm shim -npm shim restored diff --git a/packages/cli/snap-tests-global/shim-corepack-enable-install-directory/steps.json b/packages/cli/snap-tests-global/shim-corepack-enable-install-directory/steps.json deleted file mode 100644 index 947eaabb45..0000000000 --- a/packages/cli/snap-tests-global/shim-corepack-enable-install-directory/steps.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "ignoredPlatforms": ["win32"], - "commands": [ - "mkdir -p home # Isolated VP_HOME", - "printf '22.18.0\\n' > .node-version # Project Node.js version", - "mkdir -p home/js_runtime/node/22.18.0/bin # Fake managed Node runtime layout", - "printf '#!/bin/sh\\necho fake-node\\n' > home/js_runtime/node/22.18.0/bin/node && chmod +x home/js_runtime/node/22.18.0/bin/node # Fake node binary", - "cp fake-corepack.sh home/js_runtime/node/22.18.0/bin/corepack && chmod +x home/js_runtime/node/22.18.0/bin/corepack # Fake bundled corepack that echoes its args", - { - "command": "VP_HOME=\"$(pwd)/home\" vp env setup # Create shims in the isolated home", - "ignoreOutput": true - }, - "VP_HOME=\"$(pwd)/home\" PATH=\"$(pwd)/home/bin:$PATH\" corepack use pnpm@10 # Non-link commands run unchanged", - "VP_HOME=\"$(pwd)/home\" PATH=\"$(pwd)/home/bin:$PATH\" corepack enable --install-directory /tmp/custom-dir # Explicit --install-directory is respected, clobbered npm shim is restored", - "VP_HOME=\"$(pwd)/home\" PATH=\"$(pwd)/home/bin:$PATH\" corepack enable # --install-directory defaults to VP_HOME/bin", - "test -L home/bin/npm && echo 'npm shim restored' # Vite+ owns the npm shim" - ] -} diff --git a/packages/cli/snap-tests-global/shim-npm-downloads-uncached-package-manager-version/.node-version b/packages/cli/snap-tests-global/shim-npm-downloads-uncached-package-manager-version/.node-version deleted file mode 100644 index 7af24b7ddb..0000000000 --- a/packages/cli/snap-tests-global/shim-npm-downloads-uncached-package-manager-version/.node-version +++ /dev/null @@ -1 +0,0 @@ -22.11.0 diff --git a/packages/cli/snap-tests-global/shim-npm-downloads-uncached-package-manager-version/snap.txt b/packages/cli/snap-tests-global/shim-npm-downloads-uncached-package-manager-version/snap.txt deleted file mode 100644 index 0a4688c499..0000000000 --- a/packages/cli/snap-tests-global/shim-npm-downloads-uncached-package-manager-version/snap.txt +++ /dev/null @@ -1,19 +0,0 @@ -> rm -rf $VP_HOME/js_runtime/node/22.11.0 # Ensure pinned Node.js is not cached -> rm -rf $VP_HOME/package_manager/npm/10.5.0 $VP_HOME/package_manager/npm/10.5.0.lock # Ensure pinned npm is not cached -> test ! -d $VP_HOME/js_runtime/node/22.11.0 && echo 'pinned Node.js@22.11.0 is uncached' -pinned Node.js@ is uncached - -> test ! -d $VP_HOME/package_manager/npm/10.5.0 && echo 'pinned npm@10.5.0 is uncached' -pinned npm@ is uncached - -> test "$(npm --version)" = "10.5.0" && echo 'npm shim auto-downloaded Node.js and packageManager on first invocation' -npm shim auto-downloaded Node.js and packageManager on first invocation - -> test -x $VP_HOME/js_runtime/node/22.11.0/bin/node && echo 'pinned Node.js@22.11.0 is now cached' -pinned Node.js@ is now cached - -> test -x $VP_HOME/package_manager/npm/10.5.0/npm/bin/npm && echo 'pinned npm@10.5.0 is now cached' -pinned npm@ is now cached - -> test "$(npm --version)" = "10.5.0" && echo 'subsequent invocations reuse the cached version' -subsequent invocations reuse the cached version diff --git a/packages/cli/snap-tests-global/shim-npm-downloads-uncached-package-manager-version/steps.json b/packages/cli/snap-tests-global/shim-npm-downloads-uncached-package-manager-version/steps.json deleted file mode 100644 index abf633a12e..0000000000 --- a/packages/cli/snap-tests-global/shim-npm-downloads-uncached-package-manager-version/steps.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "serial": true, - "ignoredPlatforms": ["win32"], - "env": {}, - "commands": [ - "rm -rf $VP_HOME/js_runtime/node/22.11.0 # Ensure pinned Node.js is not cached", - "rm -rf $VP_HOME/package_manager/npm/10.5.0 $VP_HOME/package_manager/npm/10.5.0.lock # Ensure pinned npm is not cached", - "test ! -d $VP_HOME/js_runtime/node/22.11.0 && echo 'pinned Node.js@22.11.0 is uncached'", - "test ! -d $VP_HOME/package_manager/npm/10.5.0 && echo 'pinned npm@10.5.0 is uncached'", - "test \"$(npm --version)\" = \"10.5.0\" && echo 'npm shim auto-downloaded Node.js and packageManager on first invocation'", - "test -x $VP_HOME/js_runtime/node/22.11.0/bin/node && echo 'pinned Node.js@22.11.0 is now cached'", - "test -x $VP_HOME/package_manager/npm/10.5.0/npm/bin/npm && echo 'pinned npm@10.5.0 is now cached'", - "test \"$(npm --version)\" = \"10.5.0\" && echo 'subsequent invocations reuse the cached version'" - ] -} diff --git a/packages/cli/snap-tests-global/shim-recursive-package-binary/.node-version b/packages/cli/snap-tests-global/shim-recursive-package-binary/.node-version deleted file mode 100644 index 1d9b7831ba..0000000000 --- a/packages/cli/snap-tests-global/shim-recursive-package-binary/.node-version +++ /dev/null @@ -1 +0,0 @@ -22.12.0 diff --git a/packages/cli/snap-tests-global/shim-recursive-package-binary/snap.txt b/packages/cli/snap-tests-global/shim-recursive-package-binary/snap.txt deleted file mode 100644 index 8744528a8a..0000000000 --- a/packages/cli/snap-tests-global/shim-recursive-package-binary/snap.txt +++ /dev/null @@ -1,11 +0,0 @@ -> vp install -g ./recursive-cli-pkg # Install test package -info: Installing 1 global package with Node.js -✓ Installed recursive-cli-pkg - Bins: recursive-cli - -> recursive-cli # Outer call triggers recursive inner call through shim -outer call -inner call succeeded - -> vp remove -g recursive-cli-pkg # Cleanup -Uninstalled recursive-cli-pkg diff --git a/packages/cli/snap-tests-global/shim-recursive-package-binary/steps.json b/packages/cli/snap-tests-global/shim-recursive-package-binary/steps.json deleted file mode 100644 index 51c76ca777..0000000000 --- a/packages/cli/snap-tests-global/shim-recursive-package-binary/steps.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "env": {}, - "commands": [ - "vp install -g ./recursive-cli-pkg # Install test package", - "recursive-cli # Outer call triggers recursive inner call through shim", - "vp remove -g recursive-cli-pkg # Cleanup" - ] -} diff --git a/packages/cli/snap-tests/bin-oxfmt-wrapper/steps.json b/packages/cli/snap-tests/bin-oxfmt-wrapper/steps.json deleted file mode 100644 index 703ff17557..0000000000 --- a/packages/cli/snap-tests/bin-oxfmt-wrapper/steps.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "commands": [ - "node ../node_modules/vite-plus/bin/oxfmt # should reject non-LSP usage", - "node ../node_modules/vite-plus/bin/oxfmt --help # should reject non-LSP usage", - "node ../node_modules/vite-plus/bin/oxfmt --lsp --help # should allow LSP mode", - "node ../node_modules/vite-plus/bin/oxfmt --stdin-filepath=a.ts --help # should allow Stdin mode" - ] -} diff --git a/packages/cli/snap-tests/bin-oxlint-wrapper/steps.json b/packages/cli/snap-tests/bin-oxlint-wrapper/steps.json deleted file mode 100644 index eb4d1afd61..0000000000 --- a/packages/cli/snap-tests/bin-oxlint-wrapper/steps.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "commands": [ - "node ../node_modules/vite-plus/bin/oxlint # should reject non-LSP usage", - "node ../node_modules/vite-plus/bin/oxlint --help # should reject non-LSP usage", - "node ../node_modules/vite-plus/bin/oxlint --lsp --help # should exercise import path" - ] -} diff --git a/packages/cli/snap-tests/fingerprint-ignore-test/snap.txt b/packages/cli/snap-tests/fingerprint-ignore-test/snap.txt deleted file mode 100644 index 4352812ebd..0000000000 --- a/packages/cli/snap-tests/fingerprint-ignore-test/snap.txt +++ /dev/null @@ -1,87 +0,0 @@ -> vp run create-files # first run -$ mkdir -p node_modules/pkg-a dist && echo '{"name":"pkg-a","version":"1.0.0"}' > node_modules/pkg-a/package.json && echo 'module.exports = {}' > node_modules/pkg-a/index.js && echo 'output' > dist/bundle.js - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - Vite+ Task Runner • Execution Summary -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - -Statistics: 1 tasks • 0 cache hits • 1 cache misses -Performance: 0% cache hit rate - -Task Details: -──────────────────────────────────────────────── - [1] @test/fingerprint-ignore#create-files: $ mkdir -p node_modules/pkg-a dist && echo '{"name":"pkg-a","version":"1.0.0"}' > node_modules/pkg-a/package.json && echo 'module.exports = {}' > node_modules/pkg-a/index.js && echo 'output' > dist/bundle.js ✓ - → Cache miss: no previous cache entry found -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - -> vp run create-files # cache hit - no changes -$ mkdir -p node_modules/pkg-a dist && echo '{"name":"pkg-a","version":"1.0.0"}' > node_modules/pkg-a/package.json && echo 'module.exports = {}' > node_modules/pkg-a/index.js && echo 'output' > dist/bundle.js (✓ cache hit, replaying) - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - Vite+ Task Runner • Execution Summary -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - -Statistics: 1 tasks • 1 cache hits • 0 cache misses -Performance: 100% cache hit rate, ms saved in total - -Task Details: -──────────────────────────────────────────────── - [1] @test/fingerprint-ignore#create-files: $ mkdir -p node_modules/pkg-a dist && echo '{"name":"pkg-a","version":"1.0.0"}' > node_modules/pkg-a/package.json && echo 'module.exports = {}' > node_modules/pkg-a/index.js && echo 'output' > dist/bundle.js ✓ - → Cache hit - output replayed - ms saved -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - -> echo 'module.exports = {modified: true}' > node_modules/pkg-a/index.js -> vp run create-files # cache hit - index.js ignored -$ mkdir -p node_modules/pkg-a dist && echo '{"name":"pkg-a","version":"1.0.0"}' > node_modules/pkg-a/package.json && echo 'module.exports = {}' > node_modules/pkg-a/index.js && echo 'output' > dist/bundle.js (✓ cache hit, replaying) - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - Vite+ Task Runner • Execution Summary -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - -Statistics: 1 tasks • 1 cache hits • 0 cache misses -Performance: 100% cache hit rate, ms saved in total - -Task Details: -──────────────────────────────────────────────── - [1] @test/fingerprint-ignore#create-files: $ mkdir -p node_modules/pkg-a dist && echo '{"name":"pkg-a","version":"1.0.0"}' > node_modules/pkg-a/package.json && echo 'module.exports = {}' > node_modules/pkg-a/index.js && echo 'output' > dist/bundle.js ✓ - → Cache hit - output replayed - ms saved -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - -> echo 'modified output' > dist/bundle.js -> vp run create-files # cache hit - dist ignored -$ mkdir -p node_modules/pkg-a dist && echo '{"name":"pkg-a","version":"1.0.0"}' > node_modules/pkg-a/package.json && echo 'module.exports = {}' > node_modules/pkg-a/index.js && echo 'output' > dist/bundle.js (✓ cache hit, replaying) - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - Vite+ Task Runner • Execution Summary -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - -Statistics: 1 tasks • 1 cache hits • 0 cache misses -Performance: 100% cache hit rate, ms saved in total - -Task Details: -──────────────────────────────────────────────── - [1] @test/fingerprint-ignore#create-files: $ mkdir -p node_modules/pkg-a dist && echo '{"name":"pkg-a","version":"1.0.0"}' > node_modules/pkg-a/package.json && echo 'module.exports = {}' > node_modules/pkg-a/index.js && echo 'output' > dist/bundle.js ✓ - → Cache hit - output replayed - ms saved -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - -> echo '{"name":"pkg-a","version":"2.0.0"}' > node_modules/pkg-a/package.json -> vp run create-files # cache miss - package.json NOT ignored -$ mkdir -p node_modules/pkg-a dist && echo '{"name":"pkg-a","version":"1.0.0"}' > node_modules/pkg-a/package.json && echo 'module.exports = {}' > node_modules/pkg-a/index.js && echo 'output' > dist/bundle.js (✗ cache miss: 'node_modules/pkg-a/package.json' modified, executing) - - -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - Vite+ Task Runner • Execution Summary -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - -Statistics: 1 tasks • 0 cache hits • 1 cache misses -Performance: 0% cache hit rate - -Task Details: -──────────────────────────────────────────────── - [1] @test/fingerprint-ignore#create-files: $ mkdir -p node_modules/pkg-a dist && echo '{"name":"pkg-a","version":"1.0.0"}' > node_modules/pkg-a/package.json && echo 'module.exports = {}' > node_modules/pkg-a/index.js && echo 'output' > dist/bundle.js ✓ - → Cache miss: 'node_modules/pkg-a/package.json' modified -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/packages/cli/snap-tests/fingerprint-ignore-test/steps.json b/packages/cli/snap-tests/fingerprint-ignore-test/steps.json deleted file mode 100644 index e462d114ad..0000000000 --- a/packages/cli/snap-tests/fingerprint-ignore-test/steps.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "ignoredPlatforms": ["linux", "win32", "darwin"], - "_comment": "TEMPORARILY disabled on darwin - fingerprintIgnores not yet supported in vite-task user config", - "commands": [ - "vp run create-files # first run", - "vp run create-files # cache hit - no changes", - "echo 'module.exports = {modified: true}' > node_modules/pkg-a/index.js", - "vp run create-files # cache hit - index.js ignored", - "echo 'modified output' > dist/bundle.js", - "vp run create-files # cache hit - dist ignored", - "echo '{\"name\":\"pkg-a\",\"version\":\"2.0.0\"}' > node_modules/pkg-a/package.json", - "vp run create-files # cache miss - package.json NOT ignored" - ] -} diff --git a/packages/cli/snap-tests/vitest-browser-mode/snap.txt b/packages/cli/snap-tests/vitest-browser-mode/snap.txt deleted file mode 100644 index 6a34d3fd6c..0000000000 --- a/packages/cli/snap-tests/vitest-browser-mode/snap.txt +++ /dev/null @@ -1,40 +0,0 @@ -> vp test - - RUN v - - ✓ |chromium| src/foo.test.js (1 test) ms - - Test Files 1 passed (1) - Tests 1 passed (1) - Start at - Duration ms (transform ms, setup ms, collect ms, tests ms, environment ms, prepare ms) - - - -> echo //comment >> src/foo.js -> vp test -✗ cache miss: 'src/foo.js' modified, executing - - RUN v - - ✓ |chromium| src/foo.test.js (1 test) ms - - Test Files 1 passed (1) - Tests 1 passed (1) - Start at - Duration ms (transform ms, setup ms, collect ms, tests ms, environment ms, prepare ms) - - - -> echo //comment >> src/bar.js -> vp test -✓ cache hit, replaying - - RUN v - - ✓ |chromium| src/foo.test.js (1 test) ms - - Test Files 1 passed (1) - Tests 1 passed (1) - Start at - Duration ms (transform ms, setup ms, collect ms, tests ms, environment ms, prepare ms) diff --git a/packages/cli/snap-tests/vitest-browser-mode/steps.json b/packages/cli/snap-tests/vitest-browser-mode/steps.json deleted file mode 100644 index 13d8513736..0000000000 --- a/packages/cli/snap-tests/vitest-browser-mode/steps.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "ignoredPlatforms": ["win32", "darwin", "linux"], - "commands": [ - "vp run test", - "echo //comment >> src/foo.js", - "vp run test", - "echo //comment >> src/bar.js", - "vp run test" - ] -} diff --git a/packages/tools/src/snap-test.ts b/packages/tools/src/snap-test.ts index 1fa0789666..691083ea54 100755 --- a/packages/tools/src/snap-test.ts +++ b/packages/tools/src/snap-test.ts @@ -422,6 +422,13 @@ export async function snapTest() { const casesDir = path.resolve(values.dir || 'snap-tests'); + // Every case has been migrated to the PTY snapshot suite; git does not + // track the resulting empty tree, so a fresh checkout has no dir at all. + if (!fs.existsSync(casesDir)) { + console.log(`No snap tests: ${casesDir} does not exist`); + return; + } + // Collect valid test case names (sorted for deterministic sharding) const validCaseNames: string[] = []; const missingStepsJson: string[] = [];