![ljharb@gmail.com](/assets/img/avatar_default.png)
3 changed files with 140 additions and 18 deletions
@ -0,0 +1,78 @@ |
|||||||
|
#!/bin/sh |
||||||
|
|
||||||
|
die () { echo $@ ; cleanup ; exit 1; } |
||||||
|
|
||||||
|
cleanup() { |
||||||
|
unset -f nvm_ls_remote nvm_ls_remote_iojs |
||||||
|
} |
||||||
|
|
||||||
|
. ../../../nvm.sh |
||||||
|
|
||||||
|
OUTPUT="$(nvm_remote_versions stable 2>&1)" |
||||||
|
EXPECTED_OUTPUT="Implicit aliases are not supported in nvm_remote_versions." |
||||||
|
EXIT_CODE="$(nvm_remote_versions stable >/dev/null 2>&1; echo $?)" |
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "implicit alias 'stable' did not error out with correct message, got $OUTPUT" |
||||||
|
[ "_$EXIT_CODE" = "_1" ] || die "implicit alias 'stable' did not exit with code 1, got $EXIT_CODE" |
||||||
|
|
||||||
|
OUTPUT="$(nvm_remote_versions unstable 2>&1)" |
||||||
|
EXPECTED_OUTPUT="Implicit aliases are not supported in nvm_remote_versions." |
||||||
|
EXIT_CODE="$(nvm_remote_versions unstable >/dev/null 2>&1; echo $?)" |
||||||
|
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "implicit alias 'unstable' did not error out with correct message, got $OUTPUT" |
||||||
|
[ "_$EXIT_CODE" = "_1" ] || die "implicit alias 'unstable' did not exit with code 1, got $EXIT_CODE" |
||||||
|
|
||||||
|
nvm_ls_remote() { |
||||||
|
echo "N/A" |
||||||
|
} |
||||||
|
OUTPUT="$(nvm_remote_versions foo)" |
||||||
|
EXIT_CODE="$(nvm_remote_versions foo >/dev/null 2>&1 ; echo $?)" |
||||||
|
[ "_$OUTPUT" = "_N/A" ] || die "nonexistent version did not report N/A" |
||||||
|
[ "_$EXIT_CODE" = "_3" ] || die "nonexistent version did not exit with code 3, got $EXIT_CODE" |
||||||
|
|
||||||
|
nvm_ls_remote_iojs() { |
||||||
|
echo "N/A" |
||||||
|
} |
||||||
|
OUTPUT="$(nvm_remote_versions iojs-foo)" |
||||||
|
EXIT_CODE="$(nvm_remote_versions iojs-foo >/dev/null 2>&1 ; echo $?)" |
||||||
|
[ "_$OUTPUT" = "_N/A" ] || die "nonexistent version did not report N/A" |
||||||
|
[ "_$EXIT_CODE" = "_3" ] || die "nonexistent version did not exit with code 3, got $EXIT_CODE" |
||||||
|
|
||||||
|
|
||||||
|
nvm_ls_remote() { |
||||||
|
echo "test output" |
||||||
|
echo "more test output" |
||||||
|
echo "pattern received: _$1_" |
||||||
|
} |
||||||
|
nvm_ls_remote_iojs() { |
||||||
|
echo "test iojs output" |
||||||
|
echo "more iojs test output" |
||||||
|
echo "iojs pattern received: _$1_" |
||||||
|
} |
||||||
|
|
||||||
|
OUTPUT="$(nvm_remote_versions foo)" |
||||||
|
EXIT_CODE="$(nvm_remote_versions foo >/dev/null 2>&1 ; echo $?)" |
||||||
|
[ "_$OUTPUT" = "_$(nvm_ls_remote foo) |
||||||
|
$(nvm_ls_remote_iojs foo)" ] \ |
||||||
|
|| die "nvm_remote_versions foo did not return contents of nvm_ls_remote foo combined with nvm_ls_remote_iojs foo; got $OUTPUT" |
||||||
|
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_versions foo did not exit with 0, got $EXIT_CODE" |
||||||
|
|
||||||
|
OUTPUT="$(nvm_remote_versions node)" |
||||||
|
EXIT_CODE="$(nvm_remote_versions node >/dev/null 2>&1 ; echo $?)" |
||||||
|
[ "_$OUTPUT" = "_$(nvm_ls_remote)" ] \ |
||||||
|
|| die "nvm_remote_versions node did not return contents of nvm_ls_remote; got $OUTPUT" |
||||||
|
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_versions node did not exit with 0, got $EXIT_CODE" |
||||||
|
|
||||||
|
OUTPUT="$(nvm_remote_versions iojs-foo)" |
||||||
|
EXIT_CODE="$(nvm_remote_versions iojs-foo >/dev/null 2>&1 ; echo $?)" |
||||||
|
[ "_$OUTPUT" = "_$(nvm_ls_remote iojs-foo) |
||||||
|
$(nvm_ls_remote_iojs iojs-foo)" ] \ |
||||||
|
|| die "nvm_remote_versions iojs-foo did not return contents of nvm_ls_remote iojs-foo combined with nvm_ls_remote_iojs iojs-foo; got $OUTPUT" |
||||||
|
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_versions iojs-foo did not exit with 0, got $EXIT_CODE" |
||||||
|
|
||||||
|
OUTPUT="$(nvm_remote_versions iojs)" |
||||||
|
EXIT_CODE="$(nvm_remote_versions iojs >/dev/null 2>&1 ; echo $?)" |
||||||
|
[ "_$OUTPUT" = "_$(nvm_ls_remote_iojs)" ] \ |
||||||
|
|| die "nvm_remote_versions iojs did not return contents of nvm_ls_remote_iojs; got $OUTPUT" |
||||||
|
[ "_$EXIT_CODE" = "_0" ] || die "nvm_remote_versions iojs did not exit with 0, got $EXIT_CODE" |
||||||
|
|
||||||
|
cleanup |
||||||
|
|
@ -0,0 +1,20 @@ |
|||||||
|
#!/bin/sh |
||||||
|
|
||||||
|
die () { echo $@ ; exit 1; } |
||||||
|
|
||||||
|
. ../../../nvm.sh |
||||||
|
|
||||||
|
NVM_VERSION="v1" |
||||||
|
NVM_PREFIXED_TEST_VERSION="$(nvm ls-remote "$NVM_VERSION" | tail -n1 | sed 's/^[ ]*//;s/[ ]*$//')" |
||||||
|
NVM_TEST_VERSION="$(nvm_strip_iojs_prefix "$NVM_PREFIXED_TEST_VERSION")" |
||||||
|
|
||||||
|
# Remove the stuff we're clobbering. |
||||||
|
[ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION |
||||||
|
|
||||||
|
# Install from binary |
||||||
|
nvm install "$NVM_VERSION" || die "nvm install $NVM_VERSION failed" |
||||||
|
|
||||||
|
# Check |
||||||
|
[ -d ../../../versions/io.js/$NVM_TEST_VERSION ] |
||||||
|
nvm run $NVM_PREFIXED_TEST_VERSION --version | grep $NVM_TEST_VERSION || die "'nvm run $NVM_PREFIXED_TEST_VERSION --version | grep $NVM_TEST_VERSION' failed" |
||||||
|
|
Loading…
Reference in new issue