[Tests] add test to ensure that `nvm unload` unloads all functions.

Jordan Harband 2016-11-28 12:50:35 -08:00
parent c96c561c88
commit 47c60dfc1d
No known key found for this signature in database
GPG Key ID: 64A196AEE0916D55
2 changed files with 15 additions and 2 deletions

2
nvm.sh
View File

@ -3172,7 +3172,7 @@ nvm() {
nvm_list_aliases nvm_make_alias nvm_print_alias_path \ nvm_list_aliases nvm_make_alias nvm_print_alias_path \
nvm_print_default_alias nvm_print_formatted_alias nvm_resolve_local_alias \ nvm_print_default_alias nvm_print_formatted_alias nvm_resolve_local_alias \
nvm_sanitize_path nvm_has_colors nvm_process_parameters \ nvm_sanitize_path nvm_has_colors nvm_process_parameters \
node_version_has_solaris_binary \ node_version_has_solaris_binary iojs_version_has_solaris_binary \
> /dev/null 2>&1 > /dev/null 2>&1
unset RC_VERSION NVM_NODEJS_ORG_MIRROR NVM_IOJS_ORG_MIRROR NVM_DIR \ unset RC_VERSION NVM_NODEJS_ORG_MIRROR NVM_IOJS_ORG_MIRROR NVM_DIR \
NVM_CD_FLAGS NVM_BIN NVM_MAKE_JOBS NVM_PATH \ NVM_CD_FLAGS NVM_BIN NVM_MAKE_JOBS NVM_PATH \

View File

@ -2,7 +2,13 @@
set -ex set -ex
die () { echo "$@" ; exit 1; } BEFORE="./before.tmp"
AFTER="./after.tmp"
cleanup () { rm -f "${BEFORE}" "${AFTER}"; }
die () { echo "$@" ; cleanup ; exit 1; }
typeset -f | awk '/ \(\) $/ && !/^main / {print $1}' > "${BEFORE}"
\. ../../nvm.sh \. ../../nvm.sh
@ -10,4 +16,11 @@ type nvm > /dev/null 2>&1 || die "nvm not loaded"
nvm unload nvm unload
typeset -f | awk '/ \(\) $/ && !/^main / {print $1}' > "${AFTER}"
! type nvm > /dev/null 2>&1 || die "nvm not unloaded" ! type nvm > /dev/null 2>&1 || die "nvm not unloaded"
DIFF="$(diff "${BEFORE}" "${AFTER}" ||:)"
[ -z "${DIFF}" ] || die "function pollution found: ${DIFF}"
cleanup