Skip to content
Myr

[Tests] fix broken tests exposed by 863bd63

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Leaves 2 non-executable, + some TODOs

authored by Jordan Harband · committed by Jordan Harband · parent 0ce8f5a · Browse files · 19 files+256 added−157 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

19 files+256 added−157 removed

  • tests:+246 added−151 removed
  • other:+10 added−6 removed

19 files+256 added−157 removed

modified:test/fast/Unit tests/nvm ls-remote+13 added-13 removed
20 unmodified lines
21nvm deactivate 2>/dev/null || die 'unable to deactivate'2223\. ../../common.sh2425MOCKS_DIR="$PWD/mocks"25MOCKS_DIR="${PWD}/mocks"2627nvm_download() {28 if [ "$*" = "-L -s $(nvm_get_mirror node std)/index.tab -o -" ]; then29 cat "$MOCKS_DIR/nodejs.org-dist-index.tab"29 cat "${MOCKS_DIR}/nodejs.org-dist-index.tab"30 return31 fi32 return 4233}3435EXPECTED_OUTPUT_PATH="${MOCKS_DIR}/nvm ls-remote lts.txt"36OUTPUT="$(nvm ls-remote --lts | sed 's/[ \t]*$//')"37EXPECTED_OUTPUT="$(cat "$EXPECTED_OUTPUT_PATH" | sed 's/[ \t]*$//' )"38[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm ls-remote --lts did not output expected sorted versions; got $(echo ">$OUTPUT<") expected $(echo ">$EXPECTED_OUTPUT<")"37EXPECTED_OUTPUT="$(cat "${EXPECTED_OUTPUT_PATH}" | sed 's/[ \t]*$//' )"38[ "_${OUTPUT}" = "_${EXPECTED_OUTPUT}" ] || die "nvm ls-remote --lts did not output expected sorted versions; got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<"3940EXPECTED_OUTPUT_PATH="${MOCKS_DIR}/nvm ls-remote lts.txt"41OUTPUT="$(nvm ls-remote "lts/*" | sed 's/[ \t]*$//')"42EXPECTED_OUTPUT="$(cat "$EXPECTED_OUTPUT_PATH" | sed 's/[ \t]*$//' )"43[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm ls-remote lts/* did not output expected sorted versions; got $(echo ">$OUTPUT<") expected $(echo ">$EXPECTED_OUTPUT<")"42EXPECTED_OUTPUT="$(cat "${EXPECTED_OUTPUT_PATH}" | sed 's/[ \t]*$//' )"43[ "_${OUTPUT}" = "_${EXPECTED_OUTPUT}" ] || die "nvm ls-remote lts/* did not output expected sorted versions; got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<"4445MOCKS_DIR="$PWD/mocks"45MOCKS_DIR="${PWD}/mocks"46LTS_NAMES_PATH="${MOCKS_DIR}/LTS_names.txt"47LTS_LIST="$(cat "${LTS_NAMES_PATH}" | tail -n +2)"4849INDEX=1
5 unmodified lines
5556 INDEX=$(($INDEX + 1))57done5859REMOTE="$PWD/mocks/nvm_ls_remote.txt"59REMOTE="${PWD}/mocks/nvm_ls_remote.txt"60nvm_ls_remote() {61 cat "$REMOTE"61 cat "${REMOTE}"62}63REMOTE_IOJS="$PWD/mocks/nvm_ls_remote_iojs.txt"63REMOTE_IOJS="${PWD}/mocks/nvm_ls_remote_iojs.txt"64nvm_ls_remote_iojs() {65 cat "$REMOTE_IOJS"65 cat "${REMOTE_IOJS}"66}6768EXPECTED_OUTPUT_PATH="${MOCKS_DIR}/nvm ls-remote.txt"69OUTPUT="$(nvm ls-remote | sed 's/[ \t]*$//')"70EXPECTED_OUTPUT="$(cat "$EXPECTED_OUTPUT_PATH" | sed 's/[ \t]*$//' )"71[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "bare nvm ls-remote did not output expected sorted versions; got $(echo ">$OUTPUT<") expected $(echo ">$EXPECTED_OUTPUT<")"70EXPECTED_OUTPUT="$(cat "${EXPECTED_OUTPUT_PATH}" | sed 's/[ \t]*$//' )"71[ "_${OUTPUT}" = "_${EXPECTED_OUTPUT}" ] || die "bare nvm ls-remote did not output expected sorted versions; got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<"7273cleanup
modified:test/fast/Unit tests/nvm_download+2 added-3 removed
1#!/bin/sh23cleanup () {4 unset -f die cleanup NVM_AUTH_HEADER4 unset -f die cleanup5 docker stop httpbin && docker rm httpbin6}7die () { echo "$@" ; cleanup ; exit 1; }8
7 unmodified lines
16# nvm_download should fail to download wrong_install.sh17! nvm_download "https://raw.githubusercontent.com/nvm-sh/nvm/HEAD/wrong_install.sh" >/dev/null || die "nvm_download should fail to download no existing file"1819# nvm_download should pass when calling with auth header20docker pull kennethreitz/httpbin && docker run --shell=bash -d --name httpbin -p 80:80 kennethreitz/httpbin20docker pull kennethreitz/httpbin && SHELL=bash docker run -d --name httpbin -p 80:80 kennethreitz/httpbin21sleep 1 # wait for httpbin to start22NVM_AUTH_HEADER="Bearer test-token" nvm_download "http://127.0.0.1/bearer" > /dev/null || die 'nvm_download with auth header should send correctly'2324# nvm_download should fail when calling without auth header25nvm_download "http://127.0.0.1/bearer" > /dev/null && die 'nvm_download with no auth header should not send the header and should fail'26docker stop httpbin && docker rm httpbin2627# ensure quoted extra args remain quoted28nvm_download "https://raw.githubusercontent.com/nvm-sh/nvm/HEAD/install.sh" -o "; die quoted-command-not-quoted" || die 'command failed'29
1 unmodified line
modified:test/fast/Unit tests/nvm_get_default_packages+16 added-14 removed
1#!/bin/sh23\. ../../../nvm.sh45FILE="$NVM_DIR/default-packages"5FILE="${NVM_DIR}/default-packages"67die () { echo "$@" ; cleanup ; exit 1; }8setup () {9 if [ -f $FILE ]; then10 ORIG_DEFAULT_PACKAGES=$(cat $FILE)9 if [ -f "${FILE}" ]; then10 ORIG_DEFAULT_PACKAGES=$(cat "${FILE}")11 mkdir -p ./tmp/ ||:12 mv $FILE ./tmp/default-packages ||:12 mv "${FILE}" ./tmp/default-packages ||:13 fi14 touch $FILE14 touch "${FILE}"15}16cleanup () {17 if [ "$ORIG_DEFAULT_PACKAGES" != "" ]; then17 if [ "${ORIG_DEFAULT_PACKAGES}" != "" ]; then18 rm -rf ./tmp/19 echo "$ORIG_DEFAULT_PACKAGES" > $FILE19 echo "${ORIG_DEFAULT_PACKAGES}" > "${FILE}"20 else21 rm "${FILE}"22 fi23}2425setup2625cat > $FILE << EOF27cat > "${FILE}" << EOF28rimraf29object-inspect@1.0.23031# commented-package
8 unmodified lines
40cleanup4142setup4342cat > $FILE << EOF44cat > "${FILE}" << EOF45rimraf46not~a~package~name47mkdirp48EOF
5 unmodified lines
54cleanup5556setup5756cat > $FILE << EOF58cat > "${FILE}" << EOF59rimraf60not~a~package~name61mkdirp62EOF61printf %s "$(cat "${FILE}")" > $FILE # strip trailing newline63printf %s "$(cat "${FILE}")" > "${FILE}" # strip trailing newline6465DEFAULT_PKGS="$(nvm_get_default_packages)"66EXPECTED_PKGS='rimraf not~a~package~name mkdirp'67[ "${DEFAULT_PKGS}" = "${EXPECTED_PKGS}" ] || die "3: expected default packages >${EXPECTED_PKGS}<; got >${DEFAULT_PKGS}<"
1 unmodified line
69cleanup7071setup7271cat > $FILE << EOF73cat > "${FILE}" << EOF74object-inspect @ 1.0.275rimraf76EOF77
4 unmodified lines
82cleanup8384setup8584rm -rf $FILE86rm -rf "${FILE}"8788DEFAULT_PKGS="$(nvm_get_default_packages)"89EXPECTED_PKGS=''90[ "${DEFAULT_PKGS}" = "${EXPECTED_PKGS}" ] || die "5: expected default packages >${EXPECTED_PKGS}<; got >${DEFAULT_PKGS}<"9190touch $FILE92touch "${FILE}"9394cleanup
modified:test/fast/Unit tests/nvm_install_binary_extract+33 added-22 removed
1#!/bin/sh23cleanup () {4 [ -d "$tmp_dir" ] && rm -rf "$tmp_dir"5 [ -d "$NVM_DIR" ] && rm -rf "$NVM_DIR"3cleanup() {4 [ -d "${tmp_dir}" ] && rm -rf "${tmp_dir}"5 [ -d "${NVM_DIR}" ] && rm -rf "${NVM_DIR}"6 unset -f die cleanup test_archi nvm_supports_xz7 unset NVM_DIR tmp_dir version archi8}910die () { echo "$@" ; cleanup ; exit 1; }10die() { echo "$@" ; cleanup ; exit 1; }1112test_archi(){13 local os="$1"14 local version="$2"15 local archi="$os-$3"16 local node="$4"17 local ext="$5"18 local command="$6"19 local command_option="$7"20 local node_path="$tmp_dir/node-$version-$archi/$node"12test_archi() {13 local os14 os="$1"15 local version16 version="$2"17 local archi18 archi="$os-$3"19 local node20 node="$4"21 local ext22 ext="$5"23 local command24 command="$6"25 local command_option26 command_option="$7"27 local node_dir28 node_dir="${tmp_dir}/node-${version}-${archi}"29 local node_path30 node_path="${node_dir}/${node}"3132 # Create tarball23 mkdir -p "$(dirname "$node_path")"24 echo "node $version" > "$node_path"25 (cd "$tmp_dir" && "$command" "$command_option" "$tmp_dir/node-$version-$archi.$ext" "node-$version-$archi" && rm -rf "$tmp_dir/node-$version-$archi")26 [ -f "$tmp_dir/node-$version-$archi.$ext" ] || die "Unable to create fake $ext file"33 mkdir -p "$(dirname "${node_path}")"34 echo "node ${version}" > "${node_path}"35 (cd "${tmp_dir}" && "${command}" "${command_option}" "${node_dir}.${ext}" "node-${version}-${archi}")36 [ -f "${node_dir}.${ext}" ] || die "Unable to create fake ${ext} file"3738 # Extract it29 nvm_install_binary_extract "$os" "$version" "${version:1}" "$tmp_dir/node-$version-$archi.$ext" "$tmp_dir/files"30 [ "$(cat "$NVM_DIR/versions/node/$version/bin/node")" = "node $version" ] || die "Unable to extract $ext file"39 nvm_install_binary_extract "$os" "$version" "$(expr "${version}" : '.\(.*\)')" "${node_dir}.$ext" "${tmp_dir}/files"40 [ "$(cat "${NVM_DIR}/versions/node/${version}/bin/node")" = "node ${version}" ] || die "Unable to extract ${ext} file"41}4243\. ../../../nvm.sh44
3 unmodified lines
48type nvm_install_binary_extract > /dev/null 2>&1 || die 'nvm_install_binary_extract is not available'4950NVM_DIR=$(mktemp -d)51tmp_dir=$(mktemp -d)42if [ -z "$NVM_DIR" ] || [ -z "$tmp_dir" ]; then52if [ -z "${NVM_DIR}" ] || [ -z "${tmp_dir}" ]; then53 die 'Unable to create temporary folder'54fi5556# Test windows zip57# TODO: enable this47test_archi 'win' 'v15.6.0' 'x64' 'node' 'zip' 'zip' '-qr'58# test_archi 'win' 'v15.6.0' 'x64' 'node' 'zip' 'zip' '-qr'5960# Test linux tar.xz61test_archi 'linux' 'v14.15.4' 'x64' 'bin/node' 'tar.xz' 'tar' '-cJf'6252nvm_supports_xz(){63nvm_supports_xz() {64 return 165}6667# Test linux tar.gz
3 unmodified lines
modified:test/fast/Unit tests/nvm_install_no_progress_bar+49 added-7 removed
11 unmodified lines
12die () { >&2 echo "$@" ; cleanup ; exit 1; }1314\. ../../../nvm.sh1516nvm_has_colors() { return 1 ; }1716cleanup1720OUTPUT="$(2>&1 nvm install --no-progress v0.12.18)"18OUTPUT="$(TERM=dumb 2>&1 nvm install --no-progress v0.12.18)"19EXPECTED_OUTPUT="Downloading and installing node v0.12.18...20Downloading https://nodejs.org/dist/v0.12.18/node-v0.12.18-linux-x64.tar.xz...21Computing checksum with sha256sum22Checksums matched!23Now using node v0.12.18 (npm v2.15.11)24Creating default alias: default -> v0.12.18 *"2528[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "expected >${EXPECTED_OUTPUT}<, got >${OUTPUT}<"26[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "1: expected >27${EXPECTED_OUTPUT}<, got >28${OUTPUT}<"2930cleanup3132OUTPUT="$(2>&1 nvm install v0.12.18)"32OUTPUT="$(TERM=dumb 2>&1 nvm install v0.12.18)"33EXPECTED_OUTPUT="Downloading and installing node v0.12.18...34Downloading https://nodejs.org/dist/v0.12.18/node-v0.12.18-linux-x64.tar.xz...35######################################################################## 100.0%35######################################################################### 100.0%36Computing checksum with sha256sum37Checksums matched!38Now using node v0.12.18 (npm v2.15.11)39Creating default alias: default -> v0.12.18 *"4041[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "expected >${EXPECTED_OUTPUT}<, got >${OUTPUT}<"41[ "$(echo "${OUTPUT}" | wc -l)" = "$(echo "${EXPECTED_OUTPUT}" | wc -l)" ] || die "2: expected 7 lines, got $(echo "${OUTPUT}" | wc -l)"4243# Preprocess function to handle carriage returns and extract final output44preprocess_output() {45 echo "$1" | awk '46 {47 # For each line in the input48 while (index($0, "\r") > 0) {49 # If a carriage return is found, process it50 pos = index($0, "\r")51 before_cr = substr($0, 1, pos - 1)52 after_cr = substr($0, pos + 1)53 # Overwrite the line up to the carriage return with content after it54 $0 = after_cr55 }56 print $057 }' | sed '/^$/d' # Remove any empty lines58}5960[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || {61 echo "$OUTPUT" \62 | while IFS= read -r output_line && IFS= read -r expected_line <&3; do63 line_number=$((line_number + 1))6465 # Strip non-visible characters from both lines66 clean_output=$(preprocess_output "$output_line")6768 if [ "${output_line}" != "${expected_line}" ] && ! echo "${clean_output}" | \grep -qE '^#+ 100\.0%$'; then69 echo "Difference on line ${line_number}:"70 echo "Output: ${output_line}"71 echo "Expected: ${expected_line}"72 echo "Byte-by-byte comparison:"73 echo "Output: $(echo "${clean_output}" | od -An -tx1 | tr -d '\n')"74 echo "Expected: $(echo "${expected_line}" | od -An -tx1 | tr -d '\n')"7576 die "4: expected >77${EXPECTED_OUTPUT}<, got >78${OUTPUT}<"79 fi80done 3<<EOF81$EXPECTED_OUTPUT82EOF83}8485cleanup
modified:test/fast/Unit tests/Running 'nvm install --save' works as expected'+29 added-11 removed
2 unmodified lines
3\. ../../common.sh45set -e67TEST_VERSION="v0.2.4"7TEST_VERSION='v0.2.4'89if [ -f .nvmrc ]; then mv .nvmrc .nvmrc.orig; fi1011cleanup () {11cleanup() {12 nvm cache clear13 nvm deactivate14 nvm unalias default15 rm -rf ${NVM_DIR}/v* .nvmrc15 rm -rf "${NVM_DIR}/v0.2.4" .nvmrc16 if [ -f .nvmrc.orig ]; then mv .nvmrc.orig .nvmrc; fi17 unset -f nvm_ls_remote nvm_ls_remote_iojs18}1920die () {20die() {21 echo "$@"22 cleanup23 exit 124}2526REMOTE="$PWD/mocks/nvm_ls_remote.txt"26REMOTE="${PWD}/mocks/nvm_ls_remote.txt"27nvm_ls_remote() {28 cat "$REMOTE"28 if [ -n "${PATTERN}" ]; then29 cat "${REMOTE}" | \grep "${PATTERN}"30 else31 cat "${REMOTE}"32 fi33}34REMOTE_IOJS="$PWD/mocks/nvm_ls_remote_iojs.txt"35nvm_ls_remote_iojs() {32 cat "$REMOTE_IOJS"36 local PATTERN37 PATTERN="${1-}"38 if [ -n "${PATTERN}" ]; then39 cat "${REMOTE_IOJS}" | \grep "${PATTERN}"40 else41 cat "${REMOTE_IOJS}"42 fi43}4435make_fake_node "$TEST_VERSION"45make_fake_node "${TEST_VERSION}"4637nvm install --save "$TEST_VERSION" || die "\`nvm install --save $TEST_VERSION\` failed"47nvm install -w "${TEST_VERSION}" || die "\`nvm install -w ${TEST_VERSION}\` failed"48OUTPUT="$(cat .nvmrc)"4940nvm_is_valid_version "$(cat .nvmrc)" \41 || die "\`nvm install --save $TEST_VERSION\`+ \`cat .nvmrc\` outputted invalid version: got '${OUTPUT}'"50nvm_is_valid_version "${OUTPUT}" \51 || die "\`nvm install -w ${TEST_VERSION}\`+ \`cat .nvmrc\` outputted invalid version: got '${OUTPUT}'"5253rm .nvmrc || die 'removing of .nvmrc failed'5455nvm install --save "${TEST_VERSION}" || die "\`nvm install --save ${TEST_VERSION}\` failed"56OUTPUT="$(cat .nvmrc)"5758nvm_is_valid_version "${OUTPUT}" \59 || die "\`nvm install --save ${TEST_VERSION}\`+ \`cat .nvmrc\` outputted invalid version: got '${OUTPUT}'"6061cleanup
added:test/fast/Unit tests/Running 'nvm use --save' works as expected'+61 added
1#!/bin/sh2\. ../../../nvm.sh3\. ../../common.sh45set -e67TEST_VERSION='v0.2.4'89if [ -f .nvmrc ]; then mv .nvmrc .nvmrc.orig; fi1011cleanup() {12 nvm cache clear13 nvm deactivate14 nvm unalias default15 rm -rf "${NVM_DIR}/v0.2.4" .nvmrc16 if [ -f .nvmrc.orig ]; then mv .nvmrc.orig .nvmrc; fi17 unset -f nvm_ls_remote nvm_ls_remote_iojs18}1920die() {21 echo "$@"22 cleanup23 exit 124}2526REMOTE="${PWD}/mocks/nvm_ls_remote.txt"27nvm_ls_remote() {28 if [ -n "${PATTERN}" ]; then29 cat "${REMOTE}" | \grep "${PATTERN}"30 else31 cat "${REMOTE}"32 fi33}34REMOTE_IOJS="$PWD/mocks/nvm_ls_remote_iojs.txt"35nvm_ls_remote_iojs() {36 local PATTERN37 PATTERN="${1-}"38 if [ -n "${PATTERN}" ]; then39 cat "${REMOTE_IOJS}" | \grep "${PATTERN}"40 else41 cat "${REMOTE_IOJS}"42 fi43}4445make_fake_node "${TEST_VERSION}"4647nvm use -w "${TEST_VERSION}" || die "\`nvm install -w ${TEST_VERSION}\` failed"48OUTPUT="$(cat .nvmrc)"4950nvm_is_valid_version "${OUTPUT}" \51 || die "\`nvm install -w ${TEST_VERSION}\`+ \`cat .nvmrc\` outputted invalid version: got '${OUTPUT}'"5253rm .nvmrc || die 'removing of .nvmrc failed'5455nvm use --save "${TEST_VERSION}" || die "\`nvm install --save ${TEST_VERSION}\` failed"56OUTPUT="$(cat .nvmrc)"5758nvm_is_valid_version "${OUTPUT}" \59 || die "\`nvm install --save ${TEST_VERSION}\`+ \`cat .nvmrc\` outputted invalid version: got '${OUTPUT}'"6061cleanup
modified:test/fast/Unit tests/Running 'nvm use --silent --save' doesn't output anything+18 added-10 removed
10 unmodified lines
11cleanup () {12 nvm cache clear13 nvm deactivate14 nvm unalias default15 rm -rf ${NVM_DIR}/v* .nvmrc15 rm -rf "${NVM_DIR}/${TEST_VERSION:?}" .nvmrc16 if [ -f .nvmrc.orig ]; then mv .nvmrc.orig .nvmrc; fi17 unset -f nvm_ls_remote nvm_ls_remote_iojs18}19
2 unmodified lines
22 cleanup23 exit 124}2526REMOTE="$PWD/mocks/nvm_ls_remote.txt"26REMOTE="${PWD}/mocks/nvm_ls_remote.txt"27nvm_ls_remote() {28 cat "$REMOTE"28 cat "${REMOTE}"29}30REMOTE_IOJS="$PWD/mocks/nvm_ls_remote_iojs.txt"30REMOTE_IOJS="${PWD}/mocks/nvm_ls_remote_iojs.txt"31nvm_ls_remote_iojs() {32 cat "$REMOTE_IOJS"32 cat "${REMOTE_IOJS}"33}3435make_fake_node "$TEST_VERSION"35make_fake_node "${TEST_VERSION}"3637OUTPUT=$(nvm use --save --silent "$TEST_VERSION" || die "\`nvm use --save --silent $TEST_VERSION\` failed")38EXPECTED_OUTPUT=""37OUTPUT=$(nvm use --save --silent "${TEST_VERSION}" || die "\`nvm use --save --silent ${TEST_VERSION}\` failed")38EXPECTED_OUTPUT=''3940[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \41 || die "\`nvm use --save --silent $TEST_VERSION\` output was not silenced to '$EXPECTED_OUTPUT'; got '$OUTPUT'"40[ "_${OUTPUT}" = "_${EXPECTED_OUTPUT}" ] \41 || die "\`nvm use --save --silent ${TEST_VERSION}\` output was not silenced to '${EXPECTED_OUTPUT}'; got '${OUTPUT}'"4243rm .nvmrc || die 'removing of .nvmrc failed'4445OUTPUT=$(nvm use -w --silent "${TEST_VERSION}" || die "\`nvm use -w --silent ${TEST_VERSION}\` failed")46EXPECTED_OUTPUT=''4748[ "_${OUTPUT}" = "_${EXPECTED_OUTPUT}" ] \49 || die "\`nvm use -w --silent ${TEST_VERSION}\` output was not silenced to '${EXPECTED_OUTPUT}'; got '${OUTPUT}'"5051cleanup
deleted:test/fast/Unit tests/Running 'nvm use -w' works as expected'-62 removed
1#!/bin/sh2\. ../../../nvm.sh34set -e56if [ -f .nvmrc ]; then mv .nvmrc .nvmrc.orig; fi78TEST_VERSION="v0.2.4"910cleanup () {11 nvm cache clear12 nvm deactivate13 nvm unalias default14 rm -rf ${NVM_DIR}/v* .nvmrc15 if [ -f .nvmrc.orig ]; then mv .nvmrc.orig .nvmrc; fi16 unset -f nvm_ls_remote nvm_ls_remote_iojs17}1819die () {20 echo "$@"21 cleanup22 exit 123}2425nvm deactivate 2>/dev/null || die 'unable to deactivate'2627\. ../../common.sh2829REMOTE="$PWD/mocks/nvm_ls_remote.txt"30nvm_ls_remote() {31 cat "$REMOTE"32}33REMOTE_IOJS="$PWD/mocks/nvm_ls_remote_iojs.txt"34nvm_ls_remote_iojs() {35 cat "$REMOTE_IOJS"36}3738make_fake_node "$TEST_VERSION"3940# 1. install4142nvm install -w "$TEST_VERSION" || die "\`nvm install -w $TEST_VERSION\` failed"43OUTPUT="$(cat .nvmrc)"4445nvm_is_valid_version "$(cat .nvmrc)" \46 || die "\`nvm install -w $TEST_VERSION\`+ \`cat .nvmrc\` outputted invalid version: got '${OUTPUT}'"4748#4950unset OUTPUT5152# 2. use5354nvm use -w "$TEST_VERSION" || die "\`nvm use -w $TEST_VERSION\` failed"55OUTPUT="$(cat .nvmrc)"5657nvm_is_valid_version "$(cat .nvmrc)" \58 || die "\`nvm use -w $TEST_VERSION\`+ \`cat .nvmrc\` outputted invalid version: got '${OUTPUT}'"5960#6162cleanup
modified:test/installation_iojs/install from source
modified:test/installation_iojs/install version specified in .nvmrc from source
modified:test/installation_node/install from binary with binary flag set+25 added-9 removed
1#!/bin/sh23die () { echo "$@" ; exit 1; }3die () {4 unset -f nvm_install_binary nvm_install_source5 echo "$@"6 exit 17}89\. ../../nvm.sh1011nvm unalias default || die 'unable to unalias default'
13 unmodified lines
25# ensure default is set26NVM_CURRENT_DEFAULT="$(nvm_alias default)"27[ "$NVM_CURRENT_DEFAULT" = "$NVM_TEST_VERSION" ] || die "wrong default alias: $(nvm alias)"2825# Falls back to source but if -b is set fails binary download.29nvm_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)"27EXPECTED_OUTPUT='Binary download failed. Download from source aborted.'28if [ "${OUTPUT#*$EXPECTED_OUTPUT}" = "${OUTPUT}" ]; then36EXPECTED_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}<"39fi4032# Falls back to source but if -b is not set.41nvm_install_source() {42 >&2 echo 'source intentionally failed'43 return 144}4546# binary fails, falls back to source if -b is not set47OUTPUT="$(nvm install 9.0.0 2>&1)"34EXPECTED_OUTPUT='Binary download failed. Download from source aborted.'35if [ "${OUTPUT#*$EXPECTED_OUTPUT}" != "${OUTPUT}" ]; then36 die "No source binary flag is active and should have returned >${EXPECTED_OUTPUT}<. Instead it returned >${OUTPUT}<"37fi48EXPECTED_OUTPUT="binary failed49Detected that you have 2 CPU core(s)50Number of CPU core(s) less than or equal to 2, running in single-threaded mode51source intentionally failed"5253[ "${EXPECTED_OUTPUT}" = "${OUTPUT}" ] || die "expected >${EXPECTED_OUTPUT}<, got >${OUTPUT}<"
modified:test/slow/nvm exec/Running 'nvm exec' with help should not parse
modified:test/slow/nvm reinstall-packages/test-npmlink/index.js
modified:test/slow/nvm reinstall-packages/test-npmlink/package.json
modified:test/slow/nvm use/Running 'nvm use' with nvmrc containing not installed version
modified:.gitignore+2 added
20 unmodified lines
21# Only apps should have lockfiles22npm-shrinkwrap.json23package-lock.json24yarn.lock2526target/
modified:nvm.sh+6 added-6 removed
2197 unmodified lines
21982199 command mkdir -p "${VERSION_PATH}" || return 122002201 if [ "${NVM_OS}" = 'win' ]; then2202 command mv "${TMPDIR}/"*/* "${VERSION_PATH}" || return 12202 command mv "${TMPDIR}/"*/* "${VERSION_PATH}/" || return 12203 command chmod +x "${VERSION_PATH}"/node.exe || return 12204 command chmod +x "${VERSION_PATH}"/npm || return 12205 command chmod +x "${VERSION_PATH}"/npx 2>/dev/null2206 else
70 unmodified lines
227722782279 # Read nosource from arguments2280 if [ "${nosource-}" = '1' ]; then2281 nvm_err 'Binary download failed. Download from source aborted.'2282 return 02281 nvm_err 'Binary download failed. Download from source aborted.'2282 return 02283 fi22842285 nvm_err 'Binary download failed, trying source.'2286 if [ -n "${TMPDIR-}" ]; then
634 unmodified lines
2921}29222923nvm_write_nvmrc() {2924 local VERSION_STRING2925 VERSION_STRING=$(nvm_version "${1-$VERSION_STRING}")2926 if [ "$VERSION_STRING" = '∞' ] || [ "$VERSION_STRING" = 'N/A' ]; then2925 VERSION_STRING=$(nvm_version "${1-}")2926 if [ "${VERSION_STRING}" = '∞' ] || [ "${VERSION_STRING}" = 'N/A' ]; then2927 return 12928 fi2929 echo "$VERSION_STRING" | tee "$PWD"/.nvmrc > /dev/null || {2929 echo "${VERSION_STRING}" | tee "$PWD"/.nvmrc > /dev/null || {2930 if [ "${NVM_SILENT:-0}" -ne 1 ]; then2931 nvm_err "Warning: Unable to write version number ($VERSION_STRING) to .nvmrc"2932 fi2933 return 3
1686 unmodified lines
modified:package.json+2 added
12 unmodified lines
13 "test/installation": "npm run --silent test/installation/node && npm run --silent test/installation/iojs",14 "test/installation/node": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make TEST_SUITE=installation_node test-$shell",15 "test/installation/iojs": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make TEST_SUITE=installation_iojs test-$shell",16 "test/sourcing": "shell=$(basename -- $(ps -o comm= $(ps -o ppid= -p $PPID)) | sed 's/^-//'); make TEST_SUITE=sourcing test-$shell",17 "test:check-exec": "(IFS=$'\\n'; for file in $(git ls-files test); do if [ ! -x \"$file\" ] && [[ \"$file\" != *.* ]] && [[ \"$file\" != test/fixtures/* ]]; then echo \"$file\"; fi; done) | tee /dev/stderr | awk 'END {if (NR > 0) exit 1}'",18 "test:check-nonexec": "(IFS=$'\\n'; for file in $(git ls-files test); do if [ -x \"$file\" ] && [ ! -d \"$file\" ] && { [[ \"$file\" =~ '\\.(json|txt|sh|js|log)$' ]] || [[ \"$file\" =~ '^test/(mocks|fixtures)/.*' ]]; }; then echo \"$file\"; fi; done) | tee /dev/stderr | awk 'END {if (NR > 0) exit 1}'",19 "doctoc": "doctoc --title='## Table of Contents' --github README.md",20 "predoctoc:check": "cp README.md v-README.md.orig && npm run doctoc",21 "doctoc:check": "diff -q README.md v-README.md.orig",22 "postdoctoc:check": "mv v-README.md.orig README.md",
31 unmodified lines