mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-09-09 10:39:38 +00:00
Fix support for installing node on SmartOS
uname on SmartOS cannot be used to guess if 32 and/or 64 bits binaries are supported, and its output is different than other uname commands on other operating systems. This change uses pkg_info to determine what types of binaries pkgsrc would install. If pkg_info fails to run or is not present, this change falls back to using isainfo -n, which determines what the kernel supports. It allows users to install node binaries on Solaris derivatives. io.js can also be installed on Solaris derivatives starting with version v3.3.1.
This commit is contained in:
17
test/fast/Unit tests/iojs_version_has_solaris_binary
Executable file
17
test/fast/Unit tests/iojs_version_has_solaris_binary
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
. ../../common.sh
|
||||
|
||||
assert_not_ok iojs_version_has_solaris_binary ""
|
||||
assert_not_ok iojs_version_has_solaris_binary "foo"
|
||||
assert_not_ok iojs_version_has_solaris_binary "v1.1.0"
|
||||
|
||||
assert_ok iojs_version_has_solaris_binary "v3.3.1"
|
||||
assert_ok iojs_version_has_solaris_binary "iojs-v3.3.1"
|
||||
assert_ok iojs_version_has_solaris_binary "v3.3.2"
|
||||
assert_ok iojs_version_has_solaris_binary "iojs-v3.3.2"
|
||||
assert_ok iojs_version_has_solaris_binary "v3.4.1"
|
||||
assert_ok iojs_version_has_solaris_binary "iojs-v3.4.1"
|
33
test/fast/Unit tests/node_version_has_solaris_binary
Executable file
33
test/fast/Unit tests/node_version_has_solaris_binary
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
. ../../common.sh
|
||||
|
||||
# Invalid version numbers fail
|
||||
assert_not_ok node_version_has_solaris_binary ""
|
||||
assert_not_ok node_version_has_solaris_binary "foo"
|
||||
|
||||
# "Invalid" node version numbers fail
|
||||
assert_not_ok node_version_has_solaris_binary "v1.0.0"
|
||||
assert_not_ok node_version_has_solaris_binary "v3.3.1"
|
||||
|
||||
# Valid io.js version numbers that have a Solaris binary fail
|
||||
assert_not_ok node_version_has_solaris_binary "iojs-v3.3.1"
|
||||
|
||||
# Invvalid io.js version numbers fail
|
||||
assert_not_ok node_version_has_solaris_binary "iojs-v0.12.7"
|
||||
|
||||
# Valid node version numbers that don't have a Solaris binary fail
|
||||
assert_not_ok node_version_has_solaris_binary "v0.8.5"
|
||||
|
||||
# Valid node version numbers that have a Solaris binary succeed
|
||||
assert_ok node_version_has_solaris_binary "v0.8.6"
|
||||
assert_ok node_version_has_solaris_binary "v0.10.0"
|
||||
assert_ok node_version_has_solaris_binary "v0.12.7"
|
||||
|
||||
# Valid "merged" version numbers fail, because they're not
|
||||
# considered node version numbers
|
||||
assert_not_ok node_version_has_solaris_binary "v4.0.0"
|
||||
assert_not_ok node_version_has_solaris_binary "v4.1.1"
|
80
test/fast/Unit tests/nvm_get_arch
Executable file
80
test/fast/Unit tests/nvm_get_arch
Executable file
@@ -0,0 +1,80 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Save the PATH as it was when the test started to restore it when it
|
||||
# finishes
|
||||
ORIG_PATH=$PATH
|
||||
|
||||
cleanup() {
|
||||
# Restore the PATH as it was when the test started
|
||||
export PATH=ORIG_PATH
|
||||
}
|
||||
|
||||
die () { cleanup; echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
# Directory where mocked binaries used by nvm_get_arch for each OS/arch are
|
||||
# located
|
||||
MOCKS_DIR=`pwd`/../../mocks
|
||||
# Sets the PATH for these tests to include the symlinks to the mocked
|
||||
# binaries
|
||||
export PATH=.:${PATH}
|
||||
|
||||
# Setups mock binaries for a given OS and arch that mimic
|
||||
# the output of the real binaries used by nvm_get_arch to guess
|
||||
# the architecture of a given system.
|
||||
setup_mock_arch() {
|
||||
local OS=$1
|
||||
local ARCH=$2
|
||||
local OPT=$3
|
||||
|
||||
if [ "_$OS" = "_solaris" ] || [ "_$OS" = "_smartos" ]; then
|
||||
ln -sf "${MOCKS_DIR}/isainfo_${ARCH}" ./isainfo
|
||||
if [ "_$OPT" != "_no_pkg_info" ]; then
|
||||
ln -sf "${MOCKS_DIR}/pkg_info_${ARCH}" ./pkg_info
|
||||
fi
|
||||
fi
|
||||
|
||||
ln -sf "${MOCKS_DIR}/uname_${OS}_${ARCH}" ./uname
|
||||
}
|
||||
|
||||
# Cleans up the setup done by setup_mock_arch.
|
||||
cleanup_mock_arch() {
|
||||
local OS=$1
|
||||
local ARCH=$2
|
||||
|
||||
if [ "_$OS" = "_solaris" ] || [ "_$OS" = "_smartos" ]; then
|
||||
rm -f ./isainfo
|
||||
rm -f ./pkg_info
|
||||
fi
|
||||
|
||||
rm -f ./uname
|
||||
}
|
||||
|
||||
# Runs nvm_get_arch for architecture $ARCH and OS $OS, and compares the
|
||||
# expected output $EXPECTED_OUTPUT with the actual output. Does nothing
|
||||
# and exits cleanly if they match, dies otherwise.
|
||||
run_test() {
|
||||
local ARCH=$1
|
||||
local OS=$2
|
||||
local EXPECTED_OUTPUT=$3
|
||||
local OPT=$4
|
||||
|
||||
setup_mock_arch $OS $ARCH $OPT
|
||||
local OUTPUT="$(nvm_get_arch)"
|
||||
cleanup_mock_arch $OS $ARCH
|
||||
[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] ||
|
||||
die "nvm_get_arch for OS \"$OS\" and arch \"$ARCH\" with OPT \"$OPT\" did
|
||||
not return \"$EXPECTED_OUTPUT\"; got \"$OUTPUT\""
|
||||
}
|
||||
|
||||
run_test x86 smartos x86
|
||||
run_test x86 smartos x86 no_pkg_info
|
||||
|
||||
run_test amd64 smartos x64
|
||||
run_test amd64 smartos x64 no_pkg_info
|
||||
|
||||
run_test x86 osx x86
|
||||
run_test amd64 osx x64
|
||||
|
||||
cleanup
|
32
test/fast/Unit tests/nvm_has_solaris_binary
Executable file
32
test/fast/Unit tests/nvm_has_solaris_binary
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
. ../../../nvm.sh
|
||||
. ../../common.sh
|
||||
|
||||
# Invalid version numbers fail
|
||||
assert_not_ok nvm_has_solaris_binary ""
|
||||
assert_not_ok nvm_has_solaris_binary "foo"
|
||||
|
||||
# "Invalid" node version numbers fail
|
||||
assert_not_ok nvm_has_solaris_binary "v1.0.0"
|
||||
assert_not_ok nvm_has_solaris_binary "v3.3.1"
|
||||
|
||||
# Valid io.js version numbers that have a Solaris binary succeed
|
||||
assert_ok nvm_has_solaris_binary "iojs-v3.3.1"
|
||||
|
||||
# Invvalid io.js version numbers fail
|
||||
assert_not_ok nvm_has_solaris_binary "iojs-v0.12.7"
|
||||
|
||||
# Valid node version numbers that don't have a Solaris binary fail
|
||||
assert_not_ok nvm_has_solaris_binary "v0.8.5"
|
||||
|
||||
# Valid node version numbers that have a Solaris binary succeed
|
||||
assert_ok nvm_has_solaris_binary "v0.8.6"
|
||||
assert_ok nvm_has_solaris_binary "v0.10.0"
|
||||
assert_ok nvm_has_solaris_binary "v0.12.7"
|
||||
|
||||
# Valid "merged" version numbers succeed
|
||||
assert_ok nvm_has_solaris_binary "v4.0.0"
|
||||
assert_ok nvm_has_solaris_binary "v4.1.1"
|
Reference in New Issue
Block a user