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

This commit is contained in:
Jordan Harband
2016-11-28 12:50:35 -08:00
parent c96c561c88
commit 47c60dfc1d
2 changed files with 15 additions and 2 deletions

View File

@@ -2,7 +2,13 @@
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
@@ -10,4 +16,11 @@ type nvm > /dev/null 2>&1 || die "nvm not loaded"
nvm unload
typeset -f | awk '/ \(\) $/ && !/^main / {print $1}' > "${AFTER}"
! type nvm > /dev/null 2>&1 || die "nvm not unloaded"
DIFF="$(diff "${BEFORE}" "${AFTER}" ||:)"
[ -z "${DIFF}" ] || die "function pollution found: ${DIFF}"
cleanup