[Tests] set $_ before sourcing nvm.sh in fast tests

nvm.sh uses `NVM_SCRIPT_SOURCE="$_"` to detect its source location.
Adding `: nvm.sh` before each source line ensures `$_` is set correctly, preventing breakage when the previous command (e.g., `set -ex`) overwrites it.
This commit is contained in:
Jordan Harband
2026-01-26 21:41:57 -08:00
parent 9ba422e561
commit c451e7a4c8
162 changed files with 163 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ die() { echo "$@" ; exit 1; }
export NVM_DIR="$(cd ../../.. && pwd)"
: nvm.sh
\. "${NVM_DIR}/nvm.sh"
\. ../../common.sh

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
die () { echo "$@" ; exit 1; }

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
die () { echo "$@" ; exit 1; }

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
die () { echo "$@" ; exit 1; }

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
die () { echo "$@" ; exit 1; }

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
die () { echo "$@" ; exit 1; }

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
\. ../../common.sh

View File

@@ -1,4 +1,5 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
[ $(nvm alias test-stable-1 | wc -l) = '2' ]

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
\. ../../common.sh

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
\. ../../common.sh

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
\. ../../common.sh

View File

@@ -3,6 +3,7 @@
die () { echo "$@" ; exit 1; }
: nvm.sh
\. ../../../../nvm.sh
ALIAS="$(nvm_resolve_alias loopback | strip_colors)"

View File

@@ -3,6 +3,7 @@
die () { echo "$@" ; exit 1; }
: nvm.sh
\. ../../../../nvm.sh
ALIAS="$(nvm_resolve_local_alias loopback | strip_colors)"

View File

@@ -2,6 +2,7 @@
set -ex
: nvm.sh
\. ../../../../nvm.sh
\. ../../../common.sh

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../../nvm.sh
LTS_ALIAS_PATH="$(nvm_alias_path)/lts"

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../../nvm.sh
LTS_ALIAS_PATH="$(nvm_alias_path)/lts"

View File

@@ -4,6 +4,7 @@
die () { echo "$@" ; exit 1; }
: nvm.sh
\. ../../../nvm.sh
nvm alias default 0.1 >/dev/null || die "'nvm alias default 0.1' failed"

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
die () { echo "$@" ; exit 1; }

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
die () {

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
die () {

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
die () {

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
die () {

View File

@@ -4,6 +4,7 @@ die () { echo "$@" ; exit 1; }
export NVM_DIR="$(cd ../../.. && pwd)"
: nvm.sh
\. "${NVM_DIR}/nvm.sh"
EXIT_CODE=$(nvm_resolve_alias ; echo $?)

View File

@@ -2,6 +2,7 @@
die () { echo "$@" ; exit 1; }
: nvm.sh
\. ../../../nvm.sh
EXIT_CODE=$(nvm_resolve_local_alias ; echo $?)

View File

@@ -2,6 +2,7 @@
export NVM_DIR="$(cd ../../.. && pwd)"
: nvm.sh
\. ../../../nvm.sh
\. ../../common.sh

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
\. ../../common.sh

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
nvm which nonexistent_version

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
\. ../../common.sh

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
\. ../../common.sh

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
\. ../../common.sh

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
\. ../../common.sh

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
nvm ls nonexistent_version

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
nvm ls io

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
nvm ls node_

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
\. ../../common.sh

View File

@@ -2,6 +2,7 @@
die () { echo "$@" ; exit 1; }
: nvm.sh
\. ../../../nvm.sh
\. ../../common.sh

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
\. ../../common.sh

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
\. ../../common.sh

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
\. ../../common.sh

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
\. ../../common.sh

View File

@@ -2,6 +2,7 @@
die () { echo "$@" ; exit 1; }
: nvm.sh
\. ../../../nvm.sh
\. ../../common.sh

View File

@@ -2,6 +2,7 @@
die () { echo "$@" ; exit 1; }
: nvm.sh
\. ../../../nvm.sh
\. ../../common.sh

View File

@@ -2,6 +2,7 @@
export NVM_DIR="$(cd ../../.. && pwd)"
: nvm.sh
\. ../../../nvm.sh
\. ../../common.sh

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
\. ../../common.sh

View File

@@ -2,6 +2,7 @@
die () { echo "$@" ; exit 1; }
: nvm.sh
\. ../../../nvm.sh
\. ../../common.sh

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
\. ../../common.sh

View File

@@ -4,6 +4,7 @@ set -ex
export NVM_DIR="$(cd ../.. && pwd)"
: nvm.sh
\. ../../nvm.sh
nvm alias test v0.1.2

View File

@@ -6,6 +6,7 @@ die () { echo "$@" ; exit 1; }
export NVM_DIR="$(cd ../.. && pwd)"
: nvm.sh
\. ../../nvm.sh
nvm deactivate 2>&1

View File

@@ -6,6 +6,7 @@ die () { echo "$@" ; exit 1; }
export NVM_DIR="$(cd ../.. && pwd)"
: nvm.sh
\. ../../nvm.sh
\. ../common.sh

View File

@@ -9,6 +9,7 @@ cleanup () {
export NVM_DIR="$(cd ../.. && pwd)"
: nvm.sh
\. ../../nvm.sh
\. ../common.sh

View File

@@ -6,6 +6,7 @@ die () { echo "$@" ; exit 1; }
export NVM_DIR="$(cd ../.. && pwd)"
: nvm.sh
\. ../../nvm.sh
set +ex # needed for stderr

View File

@@ -6,6 +6,7 @@ ALIAS_PATH="../../alias"
echo v0.1.2 > "${ALIAS_PATH}/test"
: nvm.sh
\. ../../nvm.sh
nvm unalias test

View File

@@ -2,6 +2,7 @@
set -ex
: nvm.sh
\. ../../nvm.sh
\. ../common.sh

View File

@@ -2,6 +2,7 @@
set -ex
: nvm.sh
\. ../../nvm.sh
\. ../common.sh

View File

@@ -12,6 +12,7 @@ typeset -f | awk '/ \(\) $/ && !/^main / {print $1}' > "${BEFORE}"
env | grep -v PATH= | grep -v IFS= | grep -v NVM_ | grep -v TRAVIS_ | sort >> "${BEFORE}"
set +e # TODO: fix
: nvm.sh
\. ../../nvm.sh
set -e

View File

@@ -8,6 +8,7 @@ cleanup() {
rm -rf "$(nvm_alias_path)/foo"
}
: nvm.sh
\. ../../nvm.sh
nvm_make_alias foo foo

View File

@@ -13,6 +13,7 @@ cleanup() {
rm -rf "$(nvm_version_path "iojs-${VERSION}")"
}
: nvm.sh
\. ../../nvm.sh
nvm deactivate || die "unable to deactivate; current: >$(nvm current)<"

View File

@@ -7,6 +7,7 @@ cleanup() {
}
die() { echo "$@" ; cleanup ; exit 1; }
: nvm.sh
\. ../../nvm.sh
nvm_has_system_node() { return 0; }

View File

@@ -3,6 +3,7 @@
set -ex
export NVM_SYMLINK_CURRENT=true
: nvm.sh
\. ../../nvm.sh
\. ../common.sh

View File

@@ -2,6 +2,7 @@
set -ex
: nvm.sh
\. ../../nvm.sh
\. ../common.sh

View File

@@ -9,6 +9,7 @@ cleanup() {
rm .nvmrc
}
: nvm.sh
\. ../../nvm.sh
# normal .nvmrc

View File

@@ -1,6 +1,7 @@
#!/bin/bash
set -x
: nvm.sh
\. ../../nvm.sh
die () { echo "$@" ; rm .nvmrc ; exit 1; }

View File

@@ -11,6 +11,7 @@ cleanup() {
echo "Tested nvm_echo_with_colors"
}
: nvm.sh
\. ../../../nvm.sh
OUTPUT="$(nvm_echo_with_colors "\033[0;36mCyan-colored text")"

View File

@@ -8,6 +8,7 @@ cleanup() {
echo "Tested nvm_err_with_colors"
}
: nvm.sh
\. ../../../nvm.sh
set +ex

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
die () {

View File

@@ -1,5 +1,6 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
#set -e #nvm use system returns 127 and No system set message

View File

@@ -2,6 +2,7 @@
set -ex
: nvm.sh
\. ../../nvm.sh
nvm

View File

@@ -3,5 +3,6 @@
set -ex
set -- yes
: nvm.sh
\. ../../nvm.sh
[ "$1" = yes ]

View File

@@ -1,4 +1,5 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
\. ../../common.sh

View File

@@ -1,4 +1,5 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
\. ../../common.sh

View File

@@ -1,4 +1,5 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
\. ../../common.sh

View File

@@ -1,4 +1,5 @@
#!/bin/sh
: nvm.sh
\. ../../../nvm.sh
\. ../../common.sh

View File

@@ -2,6 +2,7 @@
die () { echo "$@" ; exit 1; }
: nvm.sh
\. ../../../nvm.sh
nvm_install_source() {

View File

@@ -2,6 +2,7 @@
die () { echo "$@" ; exit 1; }
: nvm.sh
\. ../../../nvm.sh
REMOTE="${PWD}/mocks/nvm_ls_remote.txt"

View File

@@ -12,6 +12,7 @@ cleanup() {
mv "${NVM_DIR}/alias/lts-backup" "${NVM_DIR}/alias/lts"
}
: nvm.sh
\. ../../../nvm.sh
if [ -n "${NVM_COLORS-}" ]; then
export TEMP_NVM_COLORS=NVM_COLORS

View File

@@ -13,6 +13,7 @@ cleanup() {
unset TEMP_NVM_COLORS
}
: nvm.sh
\. ../../../nvm.sh
# NVM_COLORS is not set
if [ -n ${NVM_COLORS} ]; then

View File

@@ -8,6 +8,7 @@ cleanup() {
unset -f nvm_remote_version
}
: nvm.sh
\. ../../../nvm.sh
\. ../../common.sh

View File

@@ -2,6 +2,7 @@
die () { echo "$@" ; exit 1; }
: nvm.sh
\. ../../../nvm.sh
[ "_$(nvm_add_iojs_prefix 1)" = "_iojs-v1" ] || die '"nvm_add_iojs_prefix 1" did not return "iojs-v1"'

View File

@@ -6,6 +6,7 @@ cleanup () {
rm -rf ../../../alias/test
}
: nvm.sh
\. ../../../nvm.sh
OUTPUT="$(nvm_alias 2>&1)"

View File

@@ -9,6 +9,7 @@ cleanup() {
mv "${NVM_DIR}/alias/lts-backup" "${NVM_DIR}/alias/lts"
}
: nvm.sh
\. ../../../nvm.sh
MOCKS_DIR="${PWD}/mocks"

View File

@@ -8,6 +8,7 @@ cleanup () {
rm -rf ../../../alias/test-comment-first
}
: nvm.sh
\. ../../../nvm.sh
# Test: alias file with comment on separate line

View File

@@ -2,6 +2,7 @@
die () { echo "$@" ; exit 1; }
: nvm.sh
\. ../../../nvm.sh
[ "_$(nvm_alias_path)" = "_$NVM_DIR/alias" ] || die "nvm_alias_path did not return correct location"

View File

@@ -2,6 +2,7 @@
die () { echo "$@" ; exit 1; }
: nvm.sh
\. ../../../nvm.sh
TEST_PATH=/usr/bin:/usr/local/bin

View File

@@ -2,6 +2,7 @@
die () { echo "$@" ; exit 1; }
: nvm.sh
\. ../../../nvm.sh
TERM=dumb nvm clear-cache --help | grep 'Usage:' || die 'did not print help menu'

View File

@@ -8,6 +8,7 @@ cleanup() {
die() { echo "$@" ; cleanup ; exit 1; }
: nvm.sh
\. ../../../nvm.sh

View File

@@ -5,6 +5,7 @@ cleanup () {
}
die () { echo "$@" ; cleanup ; exit 1; }
: nvm.sh
\. ../../../nvm.sh
set -ex

View File

@@ -4,6 +4,7 @@ set -ex
die () { echo "$@" ; exit 1; }
: nvm.sh
\. ../../../nvm.sh
set +x

View File

@@ -6,6 +6,7 @@ cleanup() {
die() { cleanup; echo "$@" ; exit 1; }
: nvm.sh
\. ../../../nvm.sh
curl() {

View File

@@ -3,6 +3,7 @@
TEST_PWD=$(pwd)
TEST_DIR="$TEST_PWD/nvm_die_on_prefix_tmp"
: nvm.sh
\. ../../../nvm.sh
TEST_VERSION_DIR="${TEST_DIR}/version"

View File

@@ -6,6 +6,7 @@ cleanup () {
}
die () { echo "$@" ; cleanup ; exit 1; }
: nvm.sh
\. ../../../nvm.sh
set -ex

View File

@@ -5,6 +5,7 @@ cleanup () {
}
die () { echo "$@" ; cleanup ; exit 1; }
: nvm.sh
\. ../../../nvm.sh
# bad flavor

View File

@@ -4,6 +4,7 @@
die () { echo "$@" ; exit 1; }
: nvm.sh
\. ../../../nvm.sh
EXPECTED_OUTPUT="nvm_ensure_default_set: a version is required"

View File

@@ -6,6 +6,7 @@ cleanup () {
unset -f nvm_has_system_node nvm_has_system_iojs
}
: nvm.sh
\. ../../../nvm.sh
\. ../../common.sh

View File

@@ -2,6 +2,7 @@
die () { echo "$@" ; exit 1; }
: nvm.sh
\. ../../../nvm.sh
[ "_$(nvm_ensure_version_prefix 1)" = "_v1" ] || die '"nvm_ensure_version_prefix 1" did not return "v1"'

View File

@@ -2,6 +2,7 @@
die () { echo "$@" ; exit 1; }
: nvm.sh
\. ../../../nvm.sh
[ "$(nvm_extract_tarball 2>&1)" = "nvm_extract_tarball requires exactly 4 arguments" ] || die 'incorrect error message with no args'

View File

@@ -2,6 +2,7 @@
die () { echo "$@" ; exit 1; }
: nvm.sh
\. ../../../nvm.sh
set -ex

View File

@@ -11,6 +11,7 @@ cleanup () {
rm -rf tmp_nvm_find_up
}
: nvm.sh
\. ../../../nvm.sh
setup

View File

@@ -2,6 +2,7 @@
die () { echo "$@" ; exit 1; }
: nvm.sh
\. ../../../nvm.sh
INPUT="0.1.2"

View File

@@ -11,6 +11,7 @@ cleanup() {
die () { cleanup; echo "$@" ; exit 1; }
: nvm.sh
\. ../../../nvm.sh
# Directory where mocked binaries used by nvm_get_arch for each OS/arch are

View File

@@ -15,6 +15,7 @@ die() {
exit 1
}
: nvm.sh
. ../../../nvm.sh
# Sets the PATH for these tests to include the symlinks to the mocked binaries

Some files were not shown because too many files have changed in this diff Show More