-
Notifications
You must be signed in to change notification settings - Fork 249
fix(env): escape and test generated Fish paths #2492
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_env_fish/assert_setup.fish
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| source env.fish | ||
| or begin | ||
| echo "failed to source env.fish" | ||
| exit 1 | ||
| end | ||
|
|
||
| if test "$VP_HOME" != "$EXPECTED_VP_HOME" | ||
| echo "VP_HOME mismatch: expected $EXPECTED_VP_HOME, got $VP_HOME" | ||
| exit 1 | ||
| end | ||
|
|
||
| set -l expected_bin "$EXPECTED_VP_HOME/bin" | ||
| if test "$PATH[1]" != "$expected_bin" | ||
| echo "PATH mismatch: expected first entry $expected_bin, got $PATH[1]" | ||
| exit 1 | ||
| end | ||
|
|
||
| set -l bin_count 0 | ||
| for entry in $PATH | ||
| if test "$entry" = "$expected_bin" | ||
| set bin_count (math $bin_count + 1) | ||
| end | ||
| end | ||
| if test $bin_count -ne 1 | ||
| echo "PATH contains the Vite+ bin directory $bin_count times" | ||
| exit 1 | ||
| end | ||
|
|
||
| functions -q vp | ||
| or begin | ||
| echo "env.fish did not define the vp wrapper" | ||
| exit 1 | ||
| end | ||
|
|
||
| set -l vp_output (vp --version) | ||
| or begin | ||
| echo "vp --version failed through the Fish wrapper" | ||
| exit 1 | ||
| end | ||
| if test (count $vp_output) -eq 0 | ||
| echo "vp --version returned no output" | ||
| exit 1 | ||
| end | ||
|
|
||
| echo "Fish environment setup checks passed" |
65 changes: 65 additions & 0 deletions
65
crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_env_fish/assert_use.fish
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| source env.fish | ||
| or begin | ||
| echo "failed to source env.fish" | ||
| exit 1 | ||
| end | ||
|
|
||
| set -gx VP_NODE_VERSION 18.20.0 | ||
| vp env use --help >/dev/null | ||
| or begin | ||
| echo "vp env use --help failed through the Fish wrapper" | ||
| exit 1 | ||
| end | ||
| if test "$VP_NODE_VERSION" != "18.20.0" | ||
| echo "vp env use --help changed VP_NODE_VERSION" | ||
| exit 1 | ||
| end | ||
|
|
||
| vp env use 20.18.0 --no-install | ||
| or begin | ||
| echo "vp env use failed through the Fish wrapper" | ||
| exit 1 | ||
| end | ||
| if not set -q VP_NODE_VERSION | ||
| echo "vp env use did not set VP_NODE_VERSION" | ||
| exit 1 | ||
| end | ||
| if test "$VP_NODE_VERSION" != "20.18.0" | ||
| echo "VP_NODE_VERSION mismatch: expected 20.18.0, got $VP_NODE_VERSION" | ||
| exit 1 | ||
| end | ||
|
|
||
| vp env use --unset | ||
| or begin | ||
| echo "vp env use --unset failed through the Fish wrapper" | ||
| exit 1 | ||
| end | ||
| if set -q VP_NODE_VERSION | ||
| echo "vp env use --unset did not remove VP_NODE_VERSION" | ||
| exit 1 | ||
| end | ||
|
|
||
| vp env use --no-install | ||
| or begin | ||
| echo "vp env use without a version failed through the Fish wrapper" | ||
| exit 1 | ||
| end | ||
| if not set -q VP_NODE_VERSION | ||
| echo "vp env use without a version did not set VP_NODE_VERSION" | ||
| exit 1 | ||
| end | ||
| if test "$VP_NODE_VERSION" != "22.18.0" | ||
| echo "file-based VP_NODE_VERSION mismatch: expected 22.18.0, got $VP_NODE_VERSION" | ||
| exit 1 | ||
| end | ||
|
|
||
| if vp env use --invalid-option >/dev/null 2>&1 | ||
| echo "vp env use did not preserve a failing command status" | ||
| exit 1 | ||
| end | ||
| if test "$VP_NODE_VERSION" != "22.18.0" | ||
| echo "failing vp env use changed VP_NODE_VERSION: $VP_NODE_VERSION" | ||
| exit 1 | ||
| end | ||
|
|
||
| echo "Fish environment use checks passed" |
22 changes: 22 additions & 0 deletions
22
crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_env_fish/snapshots.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| [[case]] | ||
| name = "command_env_fish_setup" | ||
| vp = "global" | ||
| skip-platforms = ["windows"] | ||
| requires = ["fish"] | ||
| steps = [ | ||
| { argv = ["vp", "env", "setup", "--refresh"], envs = [["VP_HOME", '${workspace}/vp "$project\with spaces"']], snapshot = false }, | ||
| { argv = ["vpt", "cp", "assert_setup.fish", 'vp "$project\with spaces"/assert_setup.fish'], snapshot = false }, | ||
| { argv = ["fish", "--no-config", "assert_setup.fish"], cwd = 'vp "$project\with spaces"', comment = "loads the generated env.fish and verifies Fish path setup and command passthrough", envs = [["EXPECTED_VP_HOME", "${workspace}"], ["PATH", "${workspace}/bin:${workspace}/bin:${PATH}"]] }, | ||
| ] | ||
|
|
||
| [[case]] | ||
| name = "command_env_fish_use" | ||
| vp = "global" | ||
| skip-platforms = ["windows"] | ||
| requires = ["fish"] | ||
| steps = [ | ||
| { argv = ["vp", "env", "setup", "--refresh"], envs = [["VP_HOME", '${workspace}/vp "$project\with spaces"']], snapshot = false }, | ||
| { argv = ["vpt", "cp", "assert_use.fish", 'vp "$project\with spaces"/assert_use.fish'], snapshot = false }, | ||
| { argv = ["vpt", "write-file", 'vp "$project\with spaces"/.node-version', "22.18.0"], snapshot = false }, | ||
| { argv = ["fish", "--no-config", "assert_use.fish"], cwd = 'vp "$project\with spaces"', comment = "verifies the Fish wrapper help, explicit use, unset, file-based use, and failure branches", envs = [["PATH", "${workspace}/bin:${PATH}"]] }, | ||
| ] |
15 changes: 15 additions & 0 deletions
15
...sts/cli_snapshots/fixtures/command_env_fish/snapshots/command_env_fish_setup.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # command_env_fish_setup | ||
|
|
||
| ## `VP_HOME=${workspace}/vp "$project\with spaces" vp env setup --refresh` | ||
|
|
||
|
|
||
| ## `vpt cp assert_setup.fish 'vp "$project\with spaces"/assert_setup.fish'` | ||
|
|
||
|
|
||
| ## `cd 'vp "$project\with spaces"' && EXPECTED_VP_HOME=${workspace} PATH=${workspace}/bin:${workspace}/bin:${PATH} fish --no-config assert_setup.fish` | ||
|
|
||
| loads the generated env.fish and verifies Fish path setup and command passthrough | ||
|
|
||
| ``` | ||
| Fish environment setup checks passed | ||
| ``` |
24 changes: 24 additions & 0 deletions
24
...tests/cli_snapshots/fixtures/command_env_fish/snapshots/command_env_fish_use.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # command_env_fish_use | ||
|
|
||
| ## `VP_HOME=${workspace}/vp "$project\with spaces" vp env setup --refresh` | ||
|
|
||
|
|
||
| ## `vpt cp assert_use.fish 'vp "$project\with spaces"/assert_use.fish'` | ||
|
|
||
|
|
||
| ## `vpt write-file 'vp "$project\with spaces"/.node-version' 22.18.0` | ||
|
|
||
|
|
||
| ## `cd 'vp "$project\with spaces"' && PATH=${workspace}/bin:${PATH} fish --no-config assert_use.fish` | ||
|
|
||
| verifies the Fish wrapper help, explicit use, unset, file-based use, and failure branches | ||
|
|
||
| ``` | ||
| Using Node.js <version> (resolved from 20.18.0) | ||
| Reverted to file-based Node.js version resolution | ||
| Using Node.js <version> (resolved from .node-version) | ||
| error: Unexpected argument '--invalid-option' | ||
|
|
||
| Use `-- --invalid-option` to pass the argument as a value | ||
| Fish environment use checks passed | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.