-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Tests] make “nvm use iojs” test actually test that thing.
- Loading branch information
Showing
2 changed files
with
67 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
43 changes: 21 additions & 22 deletions
43
test/fast/Running "nvm use iojs" uses latest io.js version
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,38 +1,37 @@ | ||
#!/bin/sh | ||
|
||
set -ex | ||
|
||
. ../common.sh | ||
|
||
die () { echo $@ ; cleanup ; exit 1; } | ||
|
||
VERSION="v3.99.0" | ||
|
||
cleanup() { | ||
rm -rf ../../alias/foo | ||
unset -f make_echo cleanup | ||
rm -rf "$(nvm_version_path "iojs-${VERSION}")" | ||
} | ||
|
||
set +ex # TODO | ||
. ../../nvm.sh | ||
set -ex | ||
|
||
echo 'foo' > ../../alias/foo | ||
|
||
OUTPUT="$(nvm use foo 2>&1)" | ||
EXPECTED_OUTPUT='The alias "foo" leads to an infinite loop. Aborting.' | ||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \ | ||
|| die "'nvm use foo' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'" | ||
nvm deactivate || die "unable to deactivate; current: >$(nvm current)<" | ||
|
||
EXIT_CODE="$(nvm use foo 2>/dev/null ; echo $?)" | ||
[ "_$EXIT_CODE" = "_8" ] || die "Expected exit code 8; got $EXIT_CODE" | ||
make_fake_iojs "${VERSION}" || die "unable to make_fake_iojs ${VERSION}" | ||
|
||
OUTPUT="$(nvm use --silent foo 2>&1)" | ||
EXPECTED_OUTPUT='' | ||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \ | ||
|| die "'nvm use --silent foo' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'" | ||
IOJS_VERSION="$(nvm_version iojs)" | ||
[ -n "${IOJS_VERSION}" ] || die 'expected an io.js version; got none' | ||
|
||
OUTPUT="$(nvm use foo --silent 2>&1)" | ||
EXPECTED_OUTPUT='' | ||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \ | ||
|| die "'nvm use foo --silent' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'" | ||
EXPECTED_OUTPUT="$(nvm_add_iojs_prefix ${VERSION})" | ||
[ "${IOJS_VERSION}" = "${EXPECTED_OUTPUT}" ] || die "iojs version was not >${EXPECTED_OUTPUT}; got >${IOJS_VERSION}<" | ||
|
||
EXIT_CODE="$(nvm use --silent foo 2>/dev/null ; echo $?)" | ||
[ "_$EXIT_CODE" = "_8" ] || die "Expected exit code 8 from 'nvm use --silent foo'; got $EXIT_CODE" | ||
nvm use --delete-prefix iojs || die '`nvm use iojs` failed' | ||
|
||
EXIT_CODE="$(nvm use foo --silent 2>/dev/null ; echo $?)" | ||
[ "_$EXIT_CODE" = "_8" ] || die "Expected exit code 8 from 'nvm use foo --silent'; got $EXIT_CODE" | ||
CURRENT="$(nvm current)" | ||
echo "current: ${CURRENT}" | ||
|
||
cleanup; | ||
[ "${CURRENT}" = "${IOJS_VERSION}" ] || die "expected >${IOJS_VERSION}<; got >${CURRENT}<" | ||
|
||
cleanup |