mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-10-30 00:45:49 +08:00
[New] Supercharge nvm debug output
Try to get shell version, OS and its version, curl/wget/git version.
This commit is contained in:
committed by
Jordan Harband
parent
f344d0694b
commit
7b253c8c0a
40
test/fast/Unit tests/nvm_command_info
Executable file
40
test/fast/Unit tests/nvm_command_info
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/bin/sh
|
||||
|
||||
cleanup() {
|
||||
unalias wget
|
||||
unset -f wget
|
||||
unset WGET_EXPECTED_INFO WGET_COMMAND_INFO
|
||||
}
|
||||
|
||||
die() { echo "$@" ; cleanup ; exit 1; }
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
|
||||
# 1. test wget command
|
||||
WGET_COMMAND_INFO="$(nvm_command_info wget)"
|
||||
WGET_EXPECTED_INFO="$(which wget)"
|
||||
[ "${WGET_COMMAND_INFO}" = "${WGET_EXPECTED_INFO}" ] || die "wget command info wrong(stage 1), expected: '${WGET_EXPECTED_INFO}', got '${WGET_COMMAND_INFO}'"
|
||||
|
||||
cleanup
|
||||
|
||||
# 2. test aliased wget
|
||||
shopt -s expand_aliases
|
||||
# enable expand_aliases to make alias working in interactive shell
|
||||
alias wget="wget -V"
|
||||
WGET_COMMAND_INFO="$(nvm_command_info wget)"
|
||||
WGET_EXPECTED_INFO="$(which wget) (wget -V)"
|
||||
[ "${WGET_COMMAND_INFO}" = "${WGET_EXPECTED_INFO}" ] || die "wget command info wrong(stage 2), expected: '${WGET_EXPECTED_INFO}', got '${WGET_COMMAND_INFO}'"
|
||||
|
||||
cleanup
|
||||
|
||||
# 3. test wget function
|
||||
wget() {
|
||||
echo "wget function"
|
||||
}
|
||||
|
||||
WGET_COMMAND_INFO="$(nvm_command_info wget)"
|
||||
WGET_EXPECTED_INFO="$(type wget)"
|
||||
[ "${WGET_COMMAND_INFO}" = "${WGET_EXPECTED_INFO}" ] || die "wget command info wrong(stage 3), expected: '${WGET_EXPECTED_INFO}', got '${WGET_COMMAND_INFO}'"
|
||||
|
||||
cleanup
|
||||
Reference in New Issue
Block a user