-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Tests] use
-ex
option during tests when possible
Relates to #1130
- Loading branch information
Showing
21 changed files
with
115 additions
and
40 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
6 changes: 5 additions & 1 deletion
6
test/fast/Running "nvm alias" should create a file in the alias directory.
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 |
---|---|---|
@@ -1,5 +1,9 @@ | ||
#!/bin/sh | ||
|
||
set -ex | ||
|
||
. ../../nvm.sh | ||
|
||
nvm alias test v0.1.2 | ||
[ "$(cat ../../alias/test)" = "v0.1.2" ] | ||
|
||
[ "$(cat "$(nvm_alias_path)/test")" = "v0.1.2" ] |
3 changes: 2 additions & 1 deletion
3
test/fast/Running "nvm current" should display current nvm environment.
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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
#!/bin/sh | ||
|
||
set -ex | ||
|
||
die () { echo $@ ; exit 1; } | ||
|
||
. ../../nvm.sh | ||
|
||
nvm deactivate 2>&1 | ||
|
||
[ "$(nvm current)" = "system" ] || [ "$(nvm current)" = "none" ] || die '"nvm current" did not report "system" or "none" when deactivated' | ||
|
3 changes: 3 additions & 0 deletions
3
test/fast/Running "nvm deactivate" should unset the nvm environment variables.
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
8 changes: 7 additions & 1 deletion
8
test/fast/Running "nvm install" with an invalid version fails nicely
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 |
---|---|---|
@@ -1,7 +1,13 @@ | ||
#!/bin/sh | ||
|
||
set -ex | ||
|
||
die () { echo $@ ; exit 1; } | ||
|
||
. ../../nvm.sh | ||
[ "$(nvm install invalid.invalid 2>&1)" = "Version 'invalid.invalid' not found - try \`nvm ls-remote\` to browse available versions." ] || die "nvm installing an invalid version did not print a nice error message" | ||
|
||
set +ex # needed for stderr | ||
OUTPUT="$(nvm install invalid.invalid 2>&1)" | ||
set -ex | ||
EXPECTED_OUTPUT="Version 'invalid.invalid' not found - try \`nvm ls-remote\` to browse available versions." | ||
[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "nvm installing an invalid version did not print a nice error message" |
11 changes: 9 additions & 2 deletions
11
test/fast/Running "nvm unalias" should remove the alias file.
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 |
---|---|---|
@@ -1,6 +1,13 @@ | ||
#!/bin/sh | ||
|
||
echo v0.1.2 > ../../alias/test | ||
set -ex | ||
|
||
ALIAS_PATH="../../alias" | ||
|
||
echo v0.1.2 > "${ALIAS_PATH}/test" | ||
|
||
. ../../nvm.sh | ||
|
||
nvm unalias test | ||
! [ -e ../../alias/test ] | ||
|
||
! [ -e "${ALIAS_PATH}/test" ] |
2 changes: 2 additions & 0 deletions
2
test/fast/Running "nvm uninstall" should remove the appropriate directory.
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
#!/bin/sh | ||
|
||
set -ex | ||
|
||
cd ../.. | ||
mkdir v0.0.1 | ||
mkdir src/node-v0.0.1 | ||
|
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
9 changes: 5 additions & 4 deletions
9
test/fast/Running "nvm unload" should unset all function and variables.
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 |
---|---|---|
@@ -1,12 +1,13 @@ | ||
#!/bin/sh | ||
|
||
fail () { echo $@ ; exit 1; } | ||
set -ex | ||
|
||
die () { echo $@ ; exit 1; } | ||
|
||
. ../../nvm.sh | ||
|
||
type nvm > /dev/null 2>&1 || fail "NVM not loaded" | ||
type nvm > /dev/null 2>&1 || die "nvm not loaded" | ||
|
||
nvm unload | ||
|
||
type nvm > /dev/null 2>&1 && fail "NVM not unloaded" || exit 0 | ||
|
||
! type nvm > /dev/null 2>&1 || die "nvm not unloaded" |
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
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
3 changes: 3 additions & 0 deletions
3
test/fast/Sourcing nvm.sh should make the nvm command available.
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 |
---|---|---|
@@ -1,4 +1,7 @@ | ||
#!/bin/sh | ||
|
||
set -ex | ||
|
||
. ../../nvm.sh | ||
|
||
nvm |
2 changes: 2 additions & 0 deletions
2
test/fast/Sourcing nvm.sh should not modify parameters of caller
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
#!/bin/sh | ||
|
||
set -ex | ||
|
||
set -- yes | ||
. ../../nvm.sh | ||
[ "$1" = yes ] |
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
#!/bin/sh | ||
|
||
set -ex | ||
|
||
( | ||
cd ../.. | ||
|
||
|
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
#!/bin/sh | ||
|
||
set -ex | ||
|
||
( | ||
cd ../.. | ||
|
||
|
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
#!/bin/sh | ||
|
||
set -ex | ||
|
||
# Remove temporary files | ||
( | ||
cd ../.. | ||
|
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
#!/bin/sh | ||
|
||
set -ex | ||
|
||
( | ||
cd ../.. | ||
|
||
|