mirror of
https://github.com/nvm-sh/nvm.git
synced 2026-04-03 03:24:51 +08:00
[Tests] fix 4 test failures
- `nvm-exec` test: expect "Found .nvmrc" message in output, since `nvm_rc_version` now outputs it to stdout via fd 3 redirection (ef162036) - `nvm_install_binary_nosource`: fix exit code capture by running the command directly instead of inside a subshell with `echo $?` (05d78477) - `nvm_iojs_version_has_solaris_binary`: bare versions like `v3.3.1` (without `iojs-` prefix) are node versions and should be rejected. The old tests relied on the buggy comparison that let them through (53e6244a) - `nvm_get_arch_unofficial`: copy `uname` into the chroot. The old test passed only because the unconditional `NVM_ARCH=x64-musl` masked the missing binary, but the `case` fix now requires a real arch to match (39e71eab)
This commit is contained in:
@@ -13,7 +13,8 @@ NVM_TEST_VERSION=v0.42
|
||||
echo "$NVM_TEST_VERSION" > .nvmrc
|
||||
|
||||
OUTPUT="$(../../nvm-exec 2>&1)";
|
||||
EXPECTED="N/A: version \"${NVM_TEST_VERSION}\" is not yet installed.
|
||||
EXPECTED="Found '$(pwd)/.nvmrc' with version <${NVM_TEST_VERSION}>
|
||||
N/A: version \"${NVM_TEST_VERSION}\" is not yet installed.
|
||||
|
||||
You need to run \`nvm install ${NVM_TEST_VERSION}\` to install and use it.
|
||||
No NODE_VERSION provided; no .nvmrc file found";
|
||||
|
||||
@@ -37,11 +37,12 @@ setup_chroot() {
|
||||
|
||||
# Files and binaries
|
||||
cp ../../../nvm.sh "${chroot_dir}/"
|
||||
cp /bin/sh /usr/bin/dirname "${chroot_dir}/bin/"
|
||||
cp /bin/sh /usr/bin/dirname /usr/bin/uname "${chroot_dir}/usr/bin/"
|
||||
ln -sf ../usr/bin/sh "${chroot_dir}/bin/sh"
|
||||
[ "${chroot_dir}" = "${CHROOT_WITH_ALPINE}" ] && touch "${chroot_dir}/etc/alpine-release"
|
||||
|
||||
# Libraries
|
||||
for binary in /bin/sh /usr/bin/dirname; do
|
||||
for binary in /bin/sh /usr/bin/dirname /usr/bin/uname; do
|
||||
for lib in $(ldd $binary | awk '{print $3}' | grep "^/"); do
|
||||
dir=$(dirname "${lib}")
|
||||
mkdir -p "${chroot_dir}${dir}"
|
||||
|
||||
@@ -23,7 +23,7 @@ if [ "${OUTPUT#*$EXPECTED_OUTPUT}" = "${OUTPUT}" ]; then
|
||||
die "No source binary flag is active and should have returned >${EXPECTED_OUTPUT}<. Instead it returned >${OUTPUT}<"
|
||||
fi
|
||||
|
||||
EXIT_CODE="$(nvm_install_binary node std 8.0.0 1 2>/dev/null; echo $?)"
|
||||
nvm_install_binary node std 8.0.0 1 >/dev/null 2>&1; EXIT_CODE=$?
|
||||
[ "${EXIT_CODE}" = "2" ] || die "Expected exit code 2 when nosource=1 and binary fails, got ${EXIT_CODE}"
|
||||
|
||||
# Unit test to check if the function errors out when the flag is set
|
||||
|
||||
@@ -14,9 +14,11 @@ assert_not_ok nvm_iojs_version_has_solaris_binary "v1.1.0"
|
||||
assert_not_ok nvm_iojs_version_has_solaris_binary "v4.0.0"
|
||||
assert_not_ok nvm_iojs_version_has_solaris_binary "v8.0.0"
|
||||
|
||||
assert_ok nvm_iojs_version_has_solaris_binary "v3.3.1"
|
||||
# Bare versions without iojs- prefix are node versions, not iojs
|
||||
assert_not_ok nvm_iojs_version_has_solaris_binary "v3.3.1"
|
||||
assert_not_ok nvm_iojs_version_has_solaris_binary "v3.3.2"
|
||||
assert_not_ok nvm_iojs_version_has_solaris_binary "v3.4.1"
|
||||
|
||||
assert_ok nvm_iojs_version_has_solaris_binary "iojs-v3.3.1"
|
||||
assert_ok nvm_iojs_version_has_solaris_binary "v3.3.2"
|
||||
assert_ok nvm_iojs_version_has_solaris_binary "iojs-v3.3.2"
|
||||
assert_ok nvm_iojs_version_has_solaris_binary "v3.4.1"
|
||||
assert_ok nvm_iojs_version_has_solaris_binary "iojs-v3.4.1"
|
||||
|
||||
Reference in New Issue
Block a user