-
Notifications
You must be signed in to change notification settings - Fork 791
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Add test for nushell integration and fix some bugs (#1415)
* Add test for nushell integration * Add nushell to CI * Fix brew installation search * Fix to get current dir when ASDF_DIR is empty * Remove complexity of asdf.nu * Try a different approach to get info about function definition of asdf for MacOS 10.15 * Fix shims dir and fix test assertions to check path * Add setup nushell to CI and remove rust compilation of nushell * Add gh token to get a higher rate limit * Change to use binary distribution of nushell instead compile it * Skip test for older ubuntu * Use single skipping check * Remove unneeded condition in SKIP_NUSHELL_TESTS env var
- Loading branch information
Showing
4 changed files
with
138 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,112 @@ | ||
#!/usr/bin/env bats | ||
|
||
load test_helpers | ||
|
||
setup() { | ||
if [ "${SKIP_NUSHELL_TESTS}" = 'YES' ]; then | ||
skip "skipping nushell tests" | ||
fi | ||
cd $(dirname "$BATS_TEST_DIRNAME") | ||
} | ||
|
||
cleaned_path() { | ||
echo $PATH | tr ':' '\n' | grep -v "asdf" | tr '\n' ':' | ||
} | ||
|
||
@test "exports ASDF_DIR" { | ||
result=$(nu -c " | ||
hide-env -i asdf | ||
hide-env -i ASDF_DIR | ||
let-env PATH = ( '$(cleaned_path)' | split row ':' ) | ||
let-env ASDF_NU_DIR = '$PWD' | ||
source asdf.nu | ||
echo \$env.ASDF_DIR | ||
") | ||
|
||
[ "$?" -eq 0 ] | ||
output=$(echo "$result" | grep "asdf") | ||
[ "$output" == $PWD ] | ||
} | ||
|
||
@test "adds asdf dirs to PATH" { | ||
result=$(nu -c " | ||
hide-env -i asdf | ||
hide-env -i ASDF_DIR | ||
let-env PATH = ( '$(cleaned_path)' | split row ':' ) | ||
let-env ASDF_NU_DIR = '$PWD' | ||
source asdf.nu | ||
\$env.PATH | to text | ||
") | ||
[ "$?" -eq 0 ] | ||
output_bin=$(echo "$result" | grep "asdf/bin") | ||
[ "$output_bin" == "$PWD/bin" ] | ||
output_shims=$(echo "$result" | grep "/shims") | ||
[ "$output_shims" == "$HOME/.asdf/shims" ] | ||
} | ||
|
||
@test "does not add paths to PATH more than once" { | ||
result=$(nu -c " | ||
hide-env -i asdf | ||
hide-env -i ASDF_DIR | ||
let-env PATH = ( '$(cleaned_path)' | split row ':' ) | ||
let-env ASDF_NU_DIR = '$PWD' | ||
source asdf.nu | ||
source asdf.nu | ||
echo \$env.PATH | ||
") | ||
[ "$?" -eq 0 ] | ||
output=$(echo $result | tr ' ' '\n' | grep "asdf" | sort | uniq -d) | ||
[ "$output" = "" ] | ||
} | ||
|
||
@test "retains ASDF_DIR" { | ||
output=$(nu -c " | ||
hide-env -i asdf | ||
let-env ASDF_DIR = ( pwd ) | ||
let-env PATH = ( '$(cleaned_path)' | split row ':' ) | ||
let-env ASDF_NU_DIR = '$PWD' | ||
source asdf.nu | ||
echo \$env.ASDF_DIR | ||
") | ||
|
||
[ "$?" -eq 0 ] | ||
[ "$output" = "$PWD" ] | ||
} | ||
|
||
@test "defines the asdf function" { | ||
output=$(nu -c " | ||
hide-env -i asdf | ||
hide-env -i ASDF_DIR | ||
let-env PATH = ( '$(cleaned_path)' | split row ':' ) | ||
let-env ASDF_NU_DIR = '$PWD' | ||
source asdf.nu | ||
which asdf | get path | to text | ||
") | ||
[ "$?" -eq 0 ] | ||
[[ "$output" =~ "command" ]] | ||
} | ||
|
||
@test "function calls asdf command" { | ||
result=$(nu -c " | ||
hide-env -i asdf | ||
hide-env -i ASDF_DIR | ||
let-env PATH = ( '$(cleaned_path)' | split row ':' ) | ||
let-env ASDF_NU_DIR = '$PWD' | ||
source asdf.nu | ||
asdf info | ||
") | ||
[ "$?" -eq 0 ] | ||
output=$(echo "$result" | grep "ASDF INSTALLED PLUGINS:") | ||
[ "$output" != "" ] | ||
} |