GeezerVison is showing github.com — test(snapshots): migrate `env-*` cases to the PTY snapshot suite by fengmk2 · Pull Request #2137 · voidzero-dev/vite-plus
test(snapshots): migrate env-* cases to the PTY snapshot suite
#2137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement . We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Uh oh!
There was an error while loading. Please reload this page.
Show file tree
Hide file tree
Changes from all commits
Commits
File filter
Filter by extension
.js
(14)
.json
(14)
.md
(5)
.toml
(5)
.txt
(5)
dotfile
(2)
All 6 file types selected
Only manifest files
Deleted files
Viewed files
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Hide whitespace
Diff view
Hide whitespace
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number
Diff line number
Diff line change
@@ -0,0 +1,14 @@
[[case]]
name = "env_install_binary_conflict"
vp = "global"
skip-platforms = ["windows"]
steps = [
{ argv = ["vp", "install", "-g", "./env-binary-conflict-pkg-a"], comment = "Install pkg-a which provides env-binary-conflict-cli binary", continue-on-failure = true },
{ argv = ["vpt", "print-file", "$VP_HOME/bins/env-binary-conflict-cli.json"], comment = "Bin config should point to pkg-a", continue-on-failure = true },
{ argv = ["vp", "install", "-g", "./env-binary-conflict-pkg-b"], comment = "Try to install pkg-b without force - should fail", continue-on-failure = true },
{ argv = ["vpt", "print-file", "$VP_HOME/bins/env-binary-conflict-cli.json"], comment = "Bin config should still point to pkg-a", continue-on-failure = true },
{ argv = ["vp", "install", "-g", "--force", "./env-binary-conflict-pkg-b"], comment = "Force install pkg-b - should auto-uninstall pkg-a", continue-on-failure = true },
{ argv = ["vpt", "print-file", "$VP_HOME/bins/env-binary-conflict-cli.json"], comment = "Bin config should now point to pkg-b", continue-on-failure = true },
{ argv = ["vp", "remove", "-g", "env-binary-conflict-pkg-b"], comment = "Cleanup", continue-on-failure = true },
{ argv = ["vpt", "stat-file", "$VP_HOME/bins/env-binary-conflict-cli.json", "--assert", "missing"], comment = "Bin config should be deleted", continue-on-failure = true },
]
Original file line number
Diff line number
Diff line change
@@ -0,0 +1,100 @@
# env_install_binary_conflict
## `vp install -g ./env-binary-conflict-pkg-a`
Install pkg-a which provides env-binary-conflict-cli binary
```
VITE+ - The Unified Toolchain for the Web
info: Installing 1 global package with Node.js <version>
✓ Installed env-binary-conflict-pkg-a 1.0.0
Bins: env-binary-conflict-cli
```
## `vpt print-file $VP_HOME/bins/env-binary-conflict-cli.json`
Bin config should point to pkg-a
```
{
"name": "env-binary-conflict-cli",
"package": "env-binary-conflict-pkg-a",
"version": "1.0.0",
"nodeVersion": "<version>",
"source": "vp"
}
```
## `vp install -g ./env-binary-conflict-pkg-b`
Try to install pkg-b without force - should fail
**Exit code:** 1
```
VITE+ - The Unified Toolchain for the Web
info: Installing 1 global package with Node.js <version>
error: Failed to install env-binary-conflict-pkg-b: Executable 'env-binary-conflict-cli' is already installed by env-binary-conflict-pkg-a
Please remove env-binary-conflict-pkg-a before installing env-binary-conflict-pkg-b, or use --force to auto-replace
```
## `vpt print-file $VP_HOME/bins/env-binary-conflict-cli.json`
Bin config should still point to pkg-a
```
{
"name": "env-binary-conflict-cli",
"package": "env-binary-conflict-pkg-a",
"version": "1.0.0",
"nodeVersion": "<version>",
"source": "vp"
}
```
## `vp install -g --force ./env-binary-conflict-pkg-b`
Force install pkg-b - should auto-uninstall pkg-a
```
VITE+ - The Unified Toolchain for the Web
info: Installing 1 global package with Node.js <version>
Uninstalling env-binary-conflict-pkg-a (conflicts with env-binary-conflict-pkg-b)...
Uninstalled env-binary-conflict-pkg-a
✓ Installed env-binary-conflict-pkg-b 2.0.0
Bins: env-binary-conflict-cli
```
## `vpt print-file $VP_HOME/bins/env-binary-conflict-cli.json`
Bin config should now point to pkg-b
```
{
"name": "env-binary-conflict-cli",
"package": "env-binary-conflict-pkg-b",
"version": "2.0.0",
"nodeVersion": "<version>",
"source": "vp"
}
```
## `vp remove -g env-binary-conflict-pkg-b`
Cleanup
```
Uninstalled env-binary-conflict-pkg-b
```
## `vpt stat-file $VP_HOME/bins/env-binary-conflict-cli.json --assert missing`
Bin config should be deleted
```
<home>/.vite-plus/bins/env-binary-conflict-cli.json: missing
```
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number
Diff line number
Diff line change
@@ -0,0 +1,19 @@
[[case]]
name = "env_install_interrupt"
vp = "global"
steps = [
{ argv = ["vp", "install", "-g", "./long-time-install-package"], continue-on-failure = true },
{ argv = ["long-time-install-package"], continue-on-failure = true },
# snapshot = false: the killed install's partial screen is timing-dependent
# (which spinner frame was live at the 100ms SIGKILL) and ConPTY renders a
# trailing blank line Unix does not; the meaningful outcome is asserted by
# the check-stale-packages step that follows.
{ argv = ["node", "test-reinstall-interrupt.js"], comment = "Reinstall but interrupt", snapshot = false, continue-on-failure = true },
{ argv = ["long-time-install-package"], comment = "Original package should be still runnable", continue-on-failure = true },
{ argv = ["node", "check-stale-packages.js", "--expect-stale"], comment = "Interrupted reinstall should leave stale package", continue-on-failure = true },
{ argv = ["vp", "install", "-g", "./long-time-install-package"], comment = "Successful reinstall should clean stale packages", continue-on-failure = true },
{ argv = ["node", "check-stale-packages.js"], continue-on-failure = true },
]
after = [
{ argv = ["vp", "remove", "-g", "@scope/long-time-install-package"], continue-on-failure = true },
]
Original file line number
Diff line number
Diff line change
@@ -0,0 +1,56 @@
# env_install_interrupt
## `vp install -g ./long-time-install-package`
```
VITE+ - The Unified Toolchain for the Web
info: Installing 1 global package with Node.js <version>
✓ Installed @scope/long-time-install-package 0.0.0
Bins: long-time-install-package
```
## `long-time-install-package`
```
long-time-install-package
```
## `node test-reinstall-interrupt.js`
Reinstall but interrupt
## `long-time-install-package`
Original package should be still runnable
```
long-time-install-package
```
## `node check-stale-packages.js --expect-stale`
Interrupted reinstall should leave stale package
```
interrupted stale package exists
```
## `vp install -g ./long-time-install-package`
Successful reinstall should clean stale packages
```
VITE+ - The Unified Toolchain for the Web
info: Installing 1 global package with Node.js <version>
✓ Installed @scope/long-time-install-package 0.0.0
Bins: long-time-install-package
```
## `node check-stale-packages.js`
```
interrupted stale package removed
```
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number
Diff line number
Diff line change
@@ -0,0 +1,10 @@
[[case]]
name = "env_install_mixed_case_bin"
vp = "global"
steps = [
{ argv = ["vp", "install", "-g", "."], continue-on-failure = true },
{ argv = ["MixedCaseBin"], continue-on-failure = true },
]
after = [
{ argv = ["vp", "remove", "-g", "env-install-mixed-case-bin"], continue-on-failure = true },
]
Original file line number
Diff line number
Diff line change
@@ -0,0 +1,17 @@
# env_install_mixed_case_bin
## `vp install -g .`
```
VITE+ - The Unified Toolchain for the Web
info: Installing 1 global package with Node.js <version>
✓ Installed env-install-mixed-case-bin 1.0.0
Bins: MixedCaseBin
```
## `MixedCaseBin`
```
mixed-case bin executed
```
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number
Diff line number
Diff line change
@@ -0,0 +1,14 @@
[[case]]
name = "env_install_stale_bin"
vp = "global"
steps = [
{ argv = ["vp", "install", "-g", "./env-install-stale-bin-pkg-v1"], comment = "Install package with two binaries", continue-on-failure = true },
{ argv = ["env-install-stale-keep"], comment = "Both binaries should be callable" },
{ argv = ["env-install-stale-drop"], continue-on-failure = true },
{ argv = ["vp", "install", "-g", "./env-install-stale-bin-pkg-v2"], comment = "Reinstall package version that removed one binary", continue-on-failure = true },
{ argv = ["env-install-stale-keep"], comment = "Remaining binary should still be callable", continue-on-failure = true },
{ argv = ["node", "check-stale-binary.js"], continue-on-failure = true },
]
after = [
{ argv = ["vp", "remove", "-g", "env-install-stale-bin-pkg"], continue-on-failure = true },
]
Original file line number
Diff line number
Diff line change
@@ -0,0 +1,54 @@
# env_install_stale_bin
## `vp install -g ./env-install-stale-bin-pkg-v1`
Install package with two binaries
```
VITE+ - The Unified Toolchain for the Web
info: Installing 1 global package with Node.js <version>
✓ Installed env-install-stale-bin-pkg 1.0.0
Bins: env-install-stale-drop, env-install-stale-keep
```
## `env-install-stale-keep`
Both binaries should be callable
```
env-install-stale-keep ok
```
## `env-install-stale-drop`
```
env-install-stale-drop ok
```
## `vp install -g ./env-install-stale-bin-pkg-v2`
Reinstall package version that removed one binary
```
VITE+ - The Unified Toolchain for the Web
info: Installing 1 global package with Node.js <version>
✓ Installed env-install-stale-bin-pkg 2.0.0
Bins: env-install-stale-keep
```
## `env-install-stale-keep`
Remaining binary should still be callable
```
env-install-stale-keep ok
```
## `node check-stale-binary.js`
```
stale shim removed
stale config removed
```
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number
Diff line number
Diff line change
@@ -0,0 +1,19 @@
[[case]]
name = "env_node_child_process_npm"
vp = "global"
skip-platforms = ["windows"]
comment = """
The legacy case compared `$(npm --version)` against a node child process's
`npm --version` via shell command substitution. There is no shell, but both
projects pin the resolution deterministically (node/ pins the runtime, so its
bundled npm version is fixed; specific/ pins devEngines.packageManager), so the
snapshot itself asserts the resolved versions, and print-path.js asserts the
child process resolves npm to the vp shim.
"""
steps = [
{ argv = ["node", "../print-version.js"], cwd = "node", comment = "child-process npm is the pinned runtime's bundled npm", continue-on-failure = true },
{ argv = ["node", "../print-path.js"], cwd = "node", comment = "child-process npm resolves to the vp shim", continue-on-failure = true },
{ argv = ["node", "../print-version.js"], cwd = "specific", comment = "child-process npm is the devEngines.packageManager pin", continue-on-failure = true },
{ argv = ["node", "./print-package-json-pm-version.js"], cwd = "specific", comment = "the pin itself, for comparison with the step above", continue-on-failure = true },
{ argv = ["node", "../print-path.js"], cwd = "specific", comment = "child-process npm resolves to the vp shim", continue-on-failure = true },
]
Original file line number
Diff line number
Diff line change
@@ -0,0 +1,48 @@
# env_node_child_process_npm
The legacy case compared `$(npm --version)` against a node child process's
`npm --version` via shell command substitution. There is no shell, but both
projects pin the resolution deterministically (node/ pins the runtime, so its
bundled npm version is fixed; specific/ pins devEngines.packageManager), so the
snapshot itself asserts the resolved versions, and print-path.js asserts the
child process resolves npm to the vp shim.
## `cd node && node ../print-version.js`
child-process npm is the pinned runtime's bundled npm
```
10.8.2
```
## `cd node && node ../print-path.js`
child-process npm resolves to the vp shim
```
<home>/.vite-plus/js_runtime/node/<version>/bin/npm
```
## `cd specific && node ../print-version.js`
child-process npm is the devEngines.packageManager pin
```
11.17.0
```
## `cd specific && node ./print-package-json-pm-version.js`
the pin itself, for comparison with the step above
```
11.17.0
```
## `cd specific && node ../print-path.js`
child-process npm resolves to the vp shim
```
<home>/.vite-plus/package_manager/npm/<version>/npm/bin/npm
```
File renamed without changes.
File renamed without changes.
Loading
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Loading
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.