[Tests] improve debug output on failure
parent
ce35311657
commit
dc691121b8
|
@ -32,15 +32,17 @@ setup
|
||||||
|
|
||||||
npm install -g nop >/dev/null || die 'nvm_check_global_modules cannot be tested because `npm` cannot install the `nop` package'
|
npm install -g nop >/dev/null || die 'nvm_check_global_modules cannot be tested because `npm` cannot install the `nop` package'
|
||||||
message=$(nvm_check_global_modules)
|
message=$(nvm_check_global_modules)
|
||||||
[ ! -z "$message" ] || die "nvm_check_global_modules should have printed a notice when npm had global modules installed"
|
[ ! -z "$message" ] || die "nvm_check_global_modules should have printed a notice when npm had global modules installed; got:\n${message}"
|
||||||
|
|
||||||
# Admit we're using NVM, just for this one test
|
if [ -n "${ORIGINAL_NVM_DIR}" ]; then
|
||||||
message=$(NVM_DIR=$ORIGINAL_NVM_DIR nvm_check_global_modules)
|
# Admit we're using NVM, just for this one test
|
||||||
[ -z "$message" ] || die "nvm_check_global_modules should not have printed a notice when npm is managed by nvm"
|
message=$(NVM_DIR="${ORIGINAL_NVM_DIR}" nvm_check_global_modules)
|
||||||
|
[ -z "$message" ] || die "nvm_check_global_modules should not have printed a notice when npm is managed by nvm; got:\n${message}"
|
||||||
|
fi
|
||||||
|
|
||||||
npm uninstall -g nop >/dev/null
|
npm uninstall -g nop >/dev/null
|
||||||
message=$(nvm_check_global_modules)
|
message=$(nvm_check_global_modules)
|
||||||
[ -z "$message" ] || die "nvm_check_global_modules should not have printed a notice when npm had no global modules installed"
|
[ -z "$message" ] || die "nvm_check_global_modules should not have printed a notice when npm had no global modules installed; got:\n${message}"
|
||||||
|
|
||||||
# Faking an installation of npm
|
# Faking an installation of npm
|
||||||
mkdir -p "$npm_config_prefix/lib/node_modules/npm"
|
mkdir -p "$npm_config_prefix/lib/node_modules/npm"
|
||||||
|
@ -49,7 +51,7 @@ cat <<'JSON' >"$npm_config_prefix/lib/node_modules/npm/package.json"
|
||||||
JSON
|
JSON
|
||||||
|
|
||||||
message=$(nvm_check_global_modules)
|
message=$(nvm_check_global_modules)
|
||||||
[ -z "$message" ] || die "nvm_check_global_modules should have not printed a notice when npm had only itself installed as a global module"
|
[ -z "$message" ] || die "nvm_check_global_modules should have not printed a notice when npm had only itself installed as a global module; got:\n${message}"
|
||||||
|
|
||||||
# Faking the absence of npm
|
# Faking the absence of npm
|
||||||
PATH=".:$PATH"
|
PATH=".:$PATH"
|
||||||
|
@ -57,7 +59,7 @@ touch npm
|
||||||
chmod +x npm
|
chmod +x npm
|
||||||
|
|
||||||
message=$(nvm_check_global_modules)
|
message=$(nvm_check_global_modules)
|
||||||
[ -z "$message" ] || die "nvm_check_global_modules should have not printed a notice when npm was unavailable"
|
[ -z "$message" ] || die "nvm_check_global_modules should have not printed a notice when npm was unavailable; got:\n${message}"
|
||||||
|
|
||||||
|
|
||||||
cleanup
|
cleanup
|
||||||
|
|
Loading…
Reference in New Issue