Skip to content
Myr

install from binary with binary flag set

This file

Path

test/installation_node/install from binary with binary flag set

60 lines · 1.8 KiB

Last changed by

[actions] migrate Travis CI tests to GitHub ActionsJordan Harbandbefore adoption4c3edc5

History of this file

Take it

1#!/bin/sh23die () {4  unset -f nvm_install_binary nvm_install_source5  echo "$@"6  exit 17}89\. ../../nvm.sh1011nvm unalias default || die 'unable to unalias default'1213NVM_TEST_VERSION=v0.10.71415# Remove the stuff we're clobbering.16[ -e ../../$NVM_TEST_VERSION ] && rm -R ../../$NVM_TEST_VERSION1718# Install from binary19nvm install -b $NVM_TEST_VERSION || die "install $NVM_TEST_VERSION failed"2021# Check22[ -d ../../$NVM_TEST_VERSION ]23nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION || die "'nvm run $NVM_TEST_VERSION --version | grep $NVM_TEST_VERSION' failed"2425# ensure default is set26NVM_CURRENT_DEFAULT="$(nvm_alias default)"27[ "$NVM_CURRENT_DEFAULT" = "$NVM_TEST_VERSION" ] || die "wrong default alias: $(nvm alias)"2829nvm_install_binary() {30  >&2 echo 'binary failed'31  return 132}3334# binary fails, falls back to source, but if -b is set, fails35OUTPUT="$(nvm install -b 9.0.0 2>&1)"36EXPECTED_OUTPUT='binary failed'37if [ "${OUTPUT#*"${EXPECTED_OUTPUT}"}" = "${OUTPUT}" ]; then38  die "No source binary flag is active and should have returned >${EXPECTED_OUTPUT}<. Instead it returned >${OUTPUT}<"39fi4041nvm_install_source() {42  >&2 echo 'source intentionally failed'43  return 144}4546# Override nvm_get_make_jobs to produce predictable output regardless of actual CPU count47nvm_get_make_jobs() {48  NVM_MAKE_JOBS=149  nvm_echo "Detected that you have 2 CPU core(s)"50  nvm_echo 'Number of CPU core(s) less than or equal to 2, running in single-threaded mode'51}5253# binary fails, falls back to source if -b is not set54OUTPUT="$(nvm install 9.0.0 2>&1)"55EXPECTED_OUTPUT="binary failed56Detected that you have 2 CPU core(s)57Number of CPU core(s) less than or equal to 2, running in single-threaded mode58source intentionally failed"5960[ "${EXPECTED_OUTPUT}" = "${OUTPUT}" ] || die "expected >${EXPECTED_OUTPUT}<, got >${OUTPUT}<"