-
Notifications
You must be signed in to change notification settings - Fork 243
fix(env): escape and test generated Nushell paths #2191
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
Open
naokihaba
wants to merge
15
commits into
voidzero-dev:main
Choose a base branch
from
naokihaba:ci/test-generated-nushell-env
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
c54d633
ci(env): test generated env.nu with Nushell
naokihaba 2b64749
fix(tests): update test home path to handle spaces correctly
naokihaba 7ef85f4
fix(dependencies): downgrade rolldown packages from 1.2.0 to 1.1.5
naokihaba 6eeb136
Merge branch 'main' into ci/test-generated-nushell-env
naokihaba d7c95ed
Merge branch 'main' into ci/test-generated-nushell-env
naokihaba ca162a9
Merge branch 'main' into ci/test-generated-nushell-env
naokihaba ea223b3
ci:trigger
naokihaba f99431c
Merge branch 'ci/test-generated-nushell-env' of github.com:naokihaba/…
naokihaba 1a06878
fix: update test script to handle paths with spaces and validate VP_N…
naokihaba 1a7c150
feat: add path rendering and escaping for Nushell compatibility
naokihaba d4b92ed
Merge remote-tracking branch 'upstream/main' into ci/test-generated-n…
naokihaba 455eb74
Merge branch 'main' into ci/test-generated-nushell-env
naokihaba befcdd4
docs: document Nushell path escaping
naokihaba 25000f0
test: move Nushell env coverage to snapshots
naokihaba d4ae878
fix: handle optional Nushell snapshot dependency
naokihaba 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
56 changes: 56 additions & 0 deletions
56
crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_env_nushell/assert.nu
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,56 @@ | ||
| source env.nu | ||
|
|
||
| let expected_home = ($env.EXPECTED_VP_HOME | path expand --no-symlink) | ||
| if $env.VP_HOME != $expected_home { | ||
| error make { | ||
| msg: $"VP_HOME mismatch: expected ($expected_home), got ($env.VP_HOME)" | ||
| } | ||
| } | ||
|
|
||
| let expected_bin = ($expected_home | path join "bin") | ||
| let actual_bin = ($env.PATH | first) | ||
| if $actual_bin != $expected_bin { | ||
| error make { | ||
| msg: $"PATH mismatch: expected first entry ($expected_bin), got ($actual_bin)" | ||
| } | ||
| } | ||
|
|
||
| let bin_count = ($env.PATH | where { $in == $expected_bin } | length) | ||
| if $bin_count != 1 { | ||
| error make { | ||
| msg: $"PATH contains the Vite+ bin directory ($bin_count) times" | ||
| } | ||
| } | ||
|
|
||
| let vp_output = (vp --version) | ||
| if $env.LAST_EXIT_CODE != 0 { | ||
| error make { | ||
| msg: "vp --version failed through the Nushell wrapper" | ||
| } | ||
| } | ||
| if ($vp_output | is-empty) { | ||
| error make { | ||
| msg: "vp --version returned no output" | ||
| } | ||
| } | ||
|
|
||
| vp env use 20.18.0 --no-install | ||
| if ("VP_NODE_VERSION" not-in $env) { | ||
| error make { | ||
| msg: "vp env use did not set VP_NODE_VERSION" | ||
| } | ||
| } | ||
| if $env.VP_NODE_VERSION != "20.18.0" { | ||
| error make { | ||
| msg: $"VP_NODE_VERSION mismatch: expected 20.18.0, got ($env.VP_NODE_VERSION)" | ||
| } | ||
| } | ||
|
|
||
| vp env use --unset | ||
| if ("VP_NODE_VERSION" in $env) { | ||
| error make { | ||
| msg: "vp env use --unset did not remove VP_NODE_VERSION" | ||
| } | ||
| } | ||
|
|
||
| print "Nushell environment checks passed" |
10 changes: 10 additions & 0 deletions
10
crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_env_nushell/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,10 @@ | ||
| [[case]] | ||
| name = "command_env_nushell" | ||
| vp = "global" | ||
| skip-platforms = ["windows"] | ||
| requires = ["nu"] | ||
| steps = [ | ||
| { argv = ["vp", "env", "setup", "--refresh"], envs = [["VP_HOME", '${workspace}/vp "home\with spaces"']], snapshot = false }, | ||
| { argv = ["vpt", "cp", "assert.nu", 'vp "home\with spaces"/assert.nu'], snapshot = false }, | ||
| { argv = ["nu", "assert.nu"], cwd = 'vp "home\with spaces"', comment = "loads the generated env.nu and verifies the Nushell wrapper", envs = [["EXPECTED_VP_HOME", "${workspace}"], ["PATH", "${workspace}/bin:${workspace}/bin:${PATH}"]] }, | ||
| ] | ||
17 changes: 17 additions & 0 deletions
17
...sts/cli_snapshots/fixtures/command_env_nushell/snapshots/command_env_nushell.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,17 @@ | ||
| # command_env_nushell | ||
|
|
||
| ## `VP_HOME=${workspace}/vp "home\with spaces" vp env setup --refresh` | ||
|
|
||
|
|
||
| ## `vpt cp assert.nu 'vp "home\with spaces"/assert.nu'` | ||
|
|
||
|
|
||
| ## `cd 'vp "home\with spaces"' && EXPECTED_VP_HOME=${workspace} PATH=${workspace}/bin:${workspace}/bin:${PATH} nu assert.nu` | ||
|
|
||
| loads the generated env.nu and verifies the Nushell wrapper | ||
|
|
||
| ``` | ||
| Using Node.js <version> (resolved from 20.18.0) | ||
| Reverted to file-based Node.js version resolution | ||
| Nushell environment 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
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.