From 490a416d9c393d97ede5d3baa6875ad877acf3f6 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 23 Aug 2024 19:25:33 -0700 Subject: [PATCH] wip --- nvm.sh | 6 +- ...ng 'nvm install --save' works as expected' | 40 ++++++++---- ...unning 'nvm use --save' works as expected' | 61 ++++++++++++++++++ ...e --silent --save' doesn't output anything | 28 ++++++--- .../Running 'nvm use -w' works as expected' | 62 ------------------- test/fast/Unit tests/nvm ls-remote | 26 ++++---- test/fast/Unit tests/nvm_download | 3 +- test/fast/Unit tests/nvm_get_default_packages | 30 ++++----- .../Unit tests/nvm_install_binary_extract | 56 ++++++++++------- .../Unit tests/nvm_install_no_progress_bar | 16 ++--- 10 files changed, 185 insertions(+), 143 deletions(-) create mode 100755 test/fast/Unit tests/Running 'nvm use --save' works as expected' delete mode 100755 test/fast/Unit tests/Running 'nvm use -w' works as expected' diff --git a/nvm.sh b/nvm.sh index 9d4b1d6194..dbbe4527cf 100755 --- a/nvm.sh +++ b/nvm.sh @@ -2922,11 +2922,11 @@ nvm_is_natural_num() { nvm_write_nvmrc() { local VERSION_STRING - VERSION_STRING=$(nvm_version "${1-$VERSION_STRING}") - if [ "$VERSION_STRING" = '∞' ] || [ "$VERSION_STRING" = 'N/A' ]; then + VERSION_STRING=$(nvm_version "${1-}") + if [ "${VERSION_STRING}" = '∞' ] || [ "${VERSION_STRING}" = 'N/A' ]; then return 1 fi - echo "$VERSION_STRING" | tee "$PWD"/.nvmrc > /dev/null || { + echo "${VERSION_STRING}" | tee "$PWD"/.nvmrc > /dev/null || { if [ "${NVM_SILENT:-0}" -ne 1 ]; then nvm_err "Warning: Unable to write version number ($VERSION_STRING) to .nvmrc" fi diff --git a/test/fast/Unit tests/Running 'nvm install --save' works as expected' b/test/fast/Unit tests/Running 'nvm install --save' works as expected' index 7f6c565cee..a020382b07 100755 --- a/test/fast/Unit tests/Running 'nvm install --save' works as expected' +++ b/test/fast/Unit tests/Running 'nvm install --save' works as expected' @@ -4,40 +4,58 @@ set -e -TEST_VERSION="v0.2.4" +TEST_VERSION='v0.2.4' if [ -f .nvmrc ]; then mv .nvmrc .nvmrc.orig; fi -cleanup () { +cleanup() { nvm cache clear nvm deactivate nvm unalias default - rm -rf ${NVM_DIR}/v* .nvmrc + rm -rf "${NVM_DIR}/v0.2.4" .nvmrc if [ -f .nvmrc.orig ]; then mv .nvmrc.orig .nvmrc; fi unset -f nvm_ls_remote nvm_ls_remote_iojs } -die () { +die() { echo "$@" cleanup exit 1 } -REMOTE="$PWD/mocks/nvm_ls_remote.txt" +REMOTE="${PWD}/mocks/nvm_ls_remote.txt" nvm_ls_remote() { - cat "$REMOTE" + if [ -n "${PATTERN}" ]; then + cat "${REMOTE}" | \grep "${PATTERN}" + else + cat "${REMOTE}" + fi } REMOTE_IOJS="$PWD/mocks/nvm_ls_remote_iojs.txt" nvm_ls_remote_iojs() { - cat "$REMOTE_IOJS" + local PATTERN + PATTERN="${1-}" + if [ -n "${PATTERN}" ]; then + cat "${REMOTE_IOJS}" | \grep "${PATTERN}" + else + cat "${REMOTE_IOJS}" + fi } -make_fake_node "$TEST_VERSION" +make_fake_node "${TEST_VERSION}" -nvm install --save "$TEST_VERSION" || die "\`nvm install --save $TEST_VERSION\` failed" +nvm install -w "${TEST_VERSION}" || die "\`nvm install -w ${TEST_VERSION}\` failed" OUTPUT="$(cat .nvmrc)" -nvm_is_valid_version "$(cat .nvmrc)" \ - || die "\`nvm install --save $TEST_VERSION\`+ \`cat .nvmrc\` outputted invalid version: got '${OUTPUT}'" +nvm_is_valid_version "${OUTPUT}" \ + || die "\`nvm install -w ${TEST_VERSION}\`+ \`cat .nvmrc\` outputted invalid version: got '${OUTPUT}'" + +rm .nvmrc || die 'removing of .nvmrc failed' + +nvm install --save "${TEST_VERSION}" || die "\`nvm install --save ${TEST_VERSION}\` failed" +OUTPUT="$(cat .nvmrc)" + +nvm_is_valid_version "${OUTPUT}" \ + || die "\`nvm install --save ${TEST_VERSION}\`+ \`cat .nvmrc\` outputted invalid version: got '${OUTPUT}'" cleanup diff --git a/test/fast/Unit tests/Running 'nvm use --save' works as expected' b/test/fast/Unit tests/Running 'nvm use --save' works as expected' new file mode 100755 index 0000000000..a188072969 --- /dev/null +++ b/test/fast/Unit tests/Running 'nvm use --save' works as expected' @@ -0,0 +1,61 @@ +#!/bin/sh +\. ../../../nvm.sh +\. ../../common.sh + +set -e + +TEST_VERSION='v0.2.4' + +if [ -f .nvmrc ]; then mv .nvmrc .nvmrc.orig; fi + +cleanup() { + nvm cache clear + nvm deactivate + nvm unalias default + rm -rf "${NVM_DIR}/v0.2.4" .nvmrc + if [ -f .nvmrc.orig ]; then mv .nvmrc.orig .nvmrc; fi + unset -f nvm_ls_remote nvm_ls_remote_iojs +} + +die() { + echo "$@" + cleanup + exit 1 +} + +REMOTE="${PWD}/mocks/nvm_ls_remote.txt" +nvm_ls_remote() { + if [ -n "${PATTERN}" ]; then + cat "${REMOTE}" | \grep "${PATTERN}" + else + cat "${REMOTE}" + fi +} +REMOTE_IOJS="$PWD/mocks/nvm_ls_remote_iojs.txt" +nvm_ls_remote_iojs() { + local PATTERN + PATTERN="${1-}" + if [ -n "${PATTERN}" ]; then + cat "${REMOTE_IOJS}" | \grep "${PATTERN}" + else + cat "${REMOTE_IOJS}" + fi +} + +make_fake_node "${TEST_VERSION}" + +nvm use -w "${TEST_VERSION}" || die "\`nvm install -w ${TEST_VERSION}\` failed" +OUTPUT="$(cat .nvmrc)" + +nvm_is_valid_version "${OUTPUT}" \ + || die "\`nvm install -w ${TEST_VERSION}\`+ \`cat .nvmrc\` outputted invalid version: got '${OUTPUT}'" + +rm .nvmrc || die 'removing of .nvmrc failed' + +nvm use --save "${TEST_VERSION}" || die "\`nvm install --save ${TEST_VERSION}\` failed" +OUTPUT="$(cat .nvmrc)" + +nvm_is_valid_version "${OUTPUT}" \ + || die "\`nvm install --save ${TEST_VERSION}\`+ \`cat .nvmrc\` outputted invalid version: got '${OUTPUT}'" + +cleanup diff --git a/test/fast/Unit tests/Running 'nvm use --silent --save' doesn't output anything b/test/fast/Unit tests/Running 'nvm use --silent --save' doesn't output anything index 0df4251422..578c3155d4 100755 --- a/test/fast/Unit tests/Running 'nvm use --silent --save' doesn't output anything +++ b/test/fast/Unit tests/Running 'nvm use --silent --save' doesn't output anything @@ -12,7 +12,7 @@ cleanup () { nvm cache clear nvm deactivate nvm unalias default - rm -rf ${NVM_DIR}/v* .nvmrc + rm -rf "${NVM_DIR}/${TEST_VERSION:?}" .nvmrc if [ -f .nvmrc.orig ]; then mv .nvmrc.orig .nvmrc; fi unset -f nvm_ls_remote nvm_ls_remote_iojs } @@ -23,21 +23,29 @@ die () { exit 1 } -REMOTE="$PWD/mocks/nvm_ls_remote.txt" +REMOTE="${PWD}/mocks/nvm_ls_remote.txt" nvm_ls_remote() { - cat "$REMOTE" + cat "${REMOTE}" } -REMOTE_IOJS="$PWD/mocks/nvm_ls_remote_iojs.txt" +REMOTE_IOJS="${PWD}/mocks/nvm_ls_remote_iojs.txt" nvm_ls_remote_iojs() { - cat "$REMOTE_IOJS" + cat "${REMOTE_IOJS}" } -make_fake_node "$TEST_VERSION" +make_fake_node "${TEST_VERSION}" -OUTPUT=$(nvm use --save --silent "$TEST_VERSION" || die "\`nvm use --save --silent $TEST_VERSION\` failed") -EXPECTED_OUTPUT="" +OUTPUT=$(nvm use --save --silent "${TEST_VERSION}" || die "\`nvm use --save --silent ${TEST_VERSION}\` failed") +EXPECTED_OUTPUT='' -[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \ - || die "\`nvm use --save --silent $TEST_VERSION\` output was not silenced to '$EXPECTED_OUTPUT'; got '$OUTPUT'" +[ "_${OUTPUT}" = "_${EXPECTED_OUTPUT}" ] \ + || die "\`nvm use --save --silent ${TEST_VERSION}\` output was not silenced to '${EXPECTED_OUTPUT}'; got '${OUTPUT}'" + +rm .nvmrc || die 'removing of .nvmrc failed' + +OUTPUT=$(nvm use -w --silent "${TEST_VERSION}" || die "\`nvm use -w --silent ${TEST_VERSION}\` failed") +EXPECTED_OUTPUT='' + +[ "_${OUTPUT}" = "_${EXPECTED_OUTPUT}" ] \ + || die "\`nvm use -w --silent ${TEST_VERSION}\` output was not silenced to '${EXPECTED_OUTPUT}'; got '${OUTPUT}'" cleanup diff --git a/test/fast/Unit tests/Running 'nvm use -w' works as expected' b/test/fast/Unit tests/Running 'nvm use -w' works as expected' deleted file mode 100755 index afa5835987..0000000000 --- a/test/fast/Unit tests/Running 'nvm use -w' works as expected' +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/sh -\. ../../../nvm.sh - -set -e - -if [ -f .nvmrc ]; then mv .nvmrc .nvmrc.orig; fi - -TEST_VERSION="v0.2.4" - -cleanup () { - nvm cache clear - nvm deactivate - nvm unalias default - rm -rf ${NVM_DIR}/v* .nvmrc - if [ -f .nvmrc.orig ]; then mv .nvmrc.orig .nvmrc; fi - unset -f nvm_ls_remote nvm_ls_remote_iojs -} - -die () { - echo "$@" - cleanup - exit 1 -} - -nvm deactivate 2>/dev/null || die 'unable to deactivate' - -\. ../../common.sh - -REMOTE="$PWD/mocks/nvm_ls_remote.txt" -nvm_ls_remote() { - cat "$REMOTE" -} -REMOTE_IOJS="$PWD/mocks/nvm_ls_remote_iojs.txt" -nvm_ls_remote_iojs() { - cat "$REMOTE_IOJS" -} - -make_fake_node "$TEST_VERSION" - -# 1. install - -nvm install -w "$TEST_VERSION" || die "\`nvm install -w $TEST_VERSION\` failed" -OUTPUT="$(cat .nvmrc)" - -nvm_is_valid_version "$(cat .nvmrc)" \ - || die "\`nvm install -w $TEST_VERSION\`+ \`cat .nvmrc\` outputted invalid version: got '${OUTPUT}'" - -# - -unset OUTPUT - -# 2. use - -nvm use -w "$TEST_VERSION" || die "\`nvm use -w $TEST_VERSION\` failed" -OUTPUT="$(cat .nvmrc)" - -nvm_is_valid_version "$(cat .nvmrc)" \ - || die "\`nvm use -w $TEST_VERSION\`+ \`cat .nvmrc\` outputted invalid version: got '${OUTPUT}'" - -# - -cleanup diff --git a/test/fast/Unit tests/nvm ls-remote b/test/fast/Unit tests/nvm ls-remote index bb1ac94465..0c65bfb57f 100755 --- a/test/fast/Unit tests/nvm ls-remote +++ b/test/fast/Unit tests/nvm ls-remote @@ -22,11 +22,11 @@ nvm deactivate 2>/dev/null || die 'unable to deactivate' \. ../../common.sh -MOCKS_DIR="$PWD/mocks" +MOCKS_DIR="${PWD}/mocks" nvm_download() { if [ "$*" = "-L -s $(nvm_get_mirror node std)/index.tab -o -" ]; then - cat "$MOCKS_DIR/nodejs.org-dist-index.tab" + cat "${MOCKS_DIR}/nodejs.org-dist-index.tab" return fi return 42 @@ -34,15 +34,15 @@ nvm_download() { EXPECTED_OUTPUT_PATH="${MOCKS_DIR}/nvm ls-remote lts.txt" OUTPUT="$(nvm ls-remote --lts | sed 's/[ \t]*$//')" -EXPECTED_OUTPUT="$(cat "$EXPECTED_OUTPUT_PATH" | sed 's/[ \t]*$//' )" -[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm ls-remote --lts did not output expected sorted versions; got $(echo ">$OUTPUT<") expected $(echo ">$EXPECTED_OUTPUT<")" +EXPECTED_OUTPUT="$(cat "${EXPECTED_OUTPUT_PATH}" | sed 's/[ \t]*$//' )" +[ "_${OUTPUT}" = "_${EXPECTED_OUTPUT}" ] || die "nvm ls-remote --lts did not output expected sorted versions; got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<" EXPECTED_OUTPUT_PATH="${MOCKS_DIR}/nvm ls-remote lts.txt" OUTPUT="$(nvm ls-remote "lts/*" | sed 's/[ \t]*$//')" -EXPECTED_OUTPUT="$(cat "$EXPECTED_OUTPUT_PATH" | sed 's/[ \t]*$//' )" -[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "nvm ls-remote lts/* did not output expected sorted versions; got $(echo ">$OUTPUT<") expected $(echo ">$EXPECTED_OUTPUT<")" +EXPECTED_OUTPUT="$(cat "${EXPECTED_OUTPUT_PATH}" | sed 's/[ \t]*$//' )" +[ "_${OUTPUT}" = "_${EXPECTED_OUTPUT}" ] || die "nvm ls-remote lts/* did not output expected sorted versions; got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<" -MOCKS_DIR="$PWD/mocks" +MOCKS_DIR="${PWD}/mocks" LTS_NAMES_PATH="${MOCKS_DIR}/LTS_names.txt" LTS_LIST="$(cat "${LTS_NAMES_PATH}" | tail -n +2)" @@ -56,18 +56,18 @@ printf '%s\n' "${LTS_LIST}" | while IFS= read -r LTS; do INDEX=$(($INDEX + 1)) done -REMOTE="$PWD/mocks/nvm_ls_remote.txt" +REMOTE="${PWD}/mocks/nvm_ls_remote.txt" nvm_ls_remote() { - cat "$REMOTE" + cat "${REMOTE}" } -REMOTE_IOJS="$PWD/mocks/nvm_ls_remote_iojs.txt" +REMOTE_IOJS="${PWD}/mocks/nvm_ls_remote_iojs.txt" nvm_ls_remote_iojs() { - cat "$REMOTE_IOJS" + cat "${REMOTE_IOJS}" } EXPECTED_OUTPUT_PATH="${MOCKS_DIR}/nvm ls-remote.txt" OUTPUT="$(nvm ls-remote | sed 's/[ \t]*$//')" -EXPECTED_OUTPUT="$(cat "$EXPECTED_OUTPUT_PATH" | sed 's/[ \t]*$//' )" -[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] || die "bare nvm ls-remote did not output expected sorted versions; got $(echo ">$OUTPUT<") expected $(echo ">$EXPECTED_OUTPUT<")" +EXPECTED_OUTPUT="$(cat "${EXPECTED_OUTPUT_PATH}" | sed 's/[ \t]*$//' )" +[ "_${OUTPUT}" = "_${EXPECTED_OUTPUT}" ] || die "bare nvm ls-remote did not output expected sorted versions; got >${OUTPUT}< expected >${EXPECTED_OUTPUT}<" cleanup diff --git a/test/fast/Unit tests/nvm_download b/test/fast/Unit tests/nvm_download index fcb58e29a7..9211b81722 100755 --- a/test/fast/Unit tests/nvm_download +++ b/test/fast/Unit tests/nvm_download @@ -17,13 +17,12 @@ nvm_download "https://raw.githubusercontent.com/nvm-sh/nvm/HEAD/install.sh" >/de ! 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" # nvm_download should pass when calling with auth header -docker pull kennethreitz/httpbin && docker run --shell=bash -d --name httpbin -p 80:80 kennethreitz/httpbin +docker pull kennethreitz/httpbin && SHELL=bash docker run -d --name httpbin -p 80:80 kennethreitz/httpbin sleep 1 # wait for httpbin to start NVM_AUTH_HEADER="Bearer test-token" nvm_download "http://127.0.0.1/bearer" > /dev/null || die 'nvm_download with auth header should send correctly' # nvm_download should fail when calling without auth header nvm_download "http://127.0.0.1/bearer" > /dev/null && die 'nvm_download with no auth header should not send the header and should fail' -docker stop httpbin && docker rm httpbin # ensure quoted extra args remain quoted nvm_download "https://raw.githubusercontent.com/nvm-sh/nvm/HEAD/install.sh" -o "; die quoted-command-not-quoted" || die 'command failed' diff --git a/test/fast/Unit tests/nvm_get_default_packages b/test/fast/Unit tests/nvm_get_default_packages index c57ace933f..d8a8157bc2 100755 --- a/test/fast/Unit tests/nvm_get_default_packages +++ b/test/fast/Unit tests/nvm_get_default_packages @@ -2,27 +2,29 @@ \. ../../../nvm.sh -FILE="$NVM_DIR/default-packages" +FILE="${NVM_DIR}/default-packages" die () { echo "$@" ; cleanup ; exit 1; } setup () { - if [ -f $FILE ]; then - ORIG_DEFAULT_PACKAGES=$(cat $FILE) + if [ -f "${FILE}" ]; then + ORIG_DEFAULT_PACKAGES=$(cat "${FILE}") mkdir -p ./tmp/ ||: - mv $FILE ./tmp/default-packages ||: + mv "${FILE}" ./tmp/default-packages ||: fi - touch $FILE + touch "${FILE}" } cleanup () { - if [ "$ORIG_DEFAULT_PACKAGES" != "" ]; then + if [ "${ORIG_DEFAULT_PACKAGES}" != "" ]; then rm -rf ./tmp/ - echo "$ORIG_DEFAULT_PACKAGES" > $FILE + echo "${ORIG_DEFAULT_PACKAGES}" > "${FILE}" + else + rm "${FILE}" fi } setup -cat > $FILE << EOF +cat > "${FILE}" << EOF rimraf object-inspect@1.0.2 @@ -39,7 +41,7 @@ cleanup setup -cat > $FILE << EOF +cat > "${FILE}" << EOF rimraf not~a~package~name mkdirp @@ -53,12 +55,12 @@ cleanup setup -cat > $FILE << EOF +cat > "${FILE}" << EOF rimraf not~a~package~name mkdirp EOF -printf %s "$(cat "${FILE}")" > $FILE # strip trailing newline +printf %s "$(cat "${FILE}")" > "${FILE}" # strip trailing newline DEFAULT_PKGS="$(nvm_get_default_packages)" EXPECTED_PKGS='rimraf not~a~package~name mkdirp' @@ -68,7 +70,7 @@ cleanup setup -cat > $FILE << EOF +cat > "${FILE}" << EOF object-inspect @ 1.0.2 rimraf EOF @@ -81,12 +83,12 @@ cleanup setup -rm -rf $FILE +rm -rf "${FILE}" DEFAULT_PKGS="$(nvm_get_default_packages)" EXPECTED_PKGS='' [ "${DEFAULT_PKGS}" = "${EXPECTED_PKGS}" ] || die "5: expected default packages >${EXPECTED_PKGS}<; got >${DEFAULT_PKGS}<" -touch $FILE +touch "${FILE}" cleanup diff --git a/test/fast/Unit tests/nvm_install_binary_extract b/test/fast/Unit tests/nvm_install_binary_extract index 8b8782a5b8..a11f318991 100755 --- a/test/fast/Unit tests/nvm_install_binary_extract +++ b/test/fast/Unit tests/nvm_install_binary_extract @@ -1,33 +1,47 @@ #!/bin/sh -cleanup () { - [ -d "$tmp_dir" ] && rm -rf "$tmp_dir" - [ -d "$NVM_DIR" ] && rm -rf "$NVM_DIR" +cleanup() { + [ -d "${tmp_dir}" ] && rm -rf "${tmp_dir}" + [ -d "${NVM_DIR}" ] && rm -rf "${NVM_DIR}" unset -f die cleanup test_archi nvm_supports_xz unset NVM_DIR tmp_dir version archi } -die () { echo "$@" ; cleanup ; exit 1; } +die() { echo "$@" ; cleanup ; exit 1; } -test_archi(){ - local os="$1" - local version="$2" - local archi="$os-$3" - local node="$4" - local ext="$5" - local command="$6" - local command_option="$7" - local node_path="$tmp_dir/node-$version-$archi/$node" +test_archi() { + local o + os="$1" + local version + version="$2" + local archi + archi="$os-$3" + local node + node="$4" + local ext + ext="$5" + local command + command="$6" + local command_option + command_option="$7" + local node_dir + node_dir="${tmp_dir}/node-${version}-${archi}" + local node_path + node_path="${node_dir}/${node}" # Create tarball - mkdir -p "$(dirname "$node_path")" - echo "node $version" > "$node_path" - (cd "$tmp_dir" && "$command" "$command_option" "$tmp_dir/node-$version-$archi.$ext" "node-$version-$archi" && rm -rf "$tmp_dir/node-$version-$archi") - [ -f "$tmp_dir/node-$version-$archi.$ext" ] || die "Unable to create fake $ext file" + mkdir -p "${node_dir}" + echo "node ${version}" > "${node_path}" + (cd "${tmp_dir}" && "${command}" "${command_option}" "${node_dir}.${ext}" "node-${version}-${archi}") + [ -f "${node_dir}.${ext}" ] || die "Unable to create fake ${ext} file" + + if [ "${os}" = 'win' ]; then + touch "${node_path}.exe" + fi # Extract it - nvm_install_binary_extract "$os" "$version" "${version:1}" "$tmp_dir/node-$version-$archi.$ext" "$tmp_dir/files" - [ "$(cat "$NVM_DIR/versions/node/$version/bin/node")" = "node $version" ] || die "Unable to extract $ext file" + nvm_install_binary_extract "$os" "$version" "${version:1}" "${node_dir}.$ext" "${tmp_dir}/files" + [ "$(cat "${NVM_DIR}/versions/node/${version}/bin/node")" = "node ${version}" ] || die "Unable to extract ${ext} file" } \. ../../../nvm.sh @@ -39,7 +53,7 @@ type nvm_install_binary_extract > /dev/null 2>&1 || die 'nvm_install_binary_extr NVM_DIR=$(mktemp -d) tmp_dir=$(mktemp -d) -if [ -z "$NVM_DIR" ] || [ -z "$tmp_dir" ]; then +if [ -z "${NVM_DIR}" ] || [ -z "${tmp_dir}" ]; then die 'Unable to create temporary folder' fi @@ -49,7 +63,7 @@ test_archi 'win' 'v15.6.0' 'x64' 'node' 'zip' 'zip' '-qr' # Test linux tar.xz test_archi 'linux' 'v14.15.4' 'x64' 'bin/node' 'tar.xz' 'tar' '-cJf' -nvm_supports_xz(){ +nvm_supports_xz() { return 1 } diff --git a/test/fast/Unit tests/nvm_install_no_progress_bar b/test/fast/Unit tests/nvm_install_no_progress_bar index d43194dc87..05b088010b 100755 --- a/test/fast/Unit tests/nvm_install_no_progress_bar +++ b/test/fast/Unit tests/nvm_install_no_progress_bar @@ -13,11 +13,9 @@ die () { >&2 echo "$@" ; cleanup ; exit 1; } \. ../../../nvm.sh -nvm_has_colors() { return 1 ; } - cleanup -OUTPUT="$(2>&1 nvm install --no-progress v0.12.18)" +OUTPUT="$(TERM=dumb 2>&1 nvm install --no-progress v0.12.18)" EXPECTED_OUTPUT="Downloading and installing node v0.12.18... Downloading https://nodejs.org/dist/v0.12.18/node-v0.12.18-linux-x64.tar.xz... Computing checksum with sha256sum @@ -25,19 +23,23 @@ Checksums matched! Now using node v0.12.18 (npm v2.15.11) Creating default alias: default -> v0.12.18 *" -[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "expected >${EXPECTED_OUTPUT}<, got >${OUTPUT}<" +[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "1: expected > +${EXPECTED_OUTPUT}<, got > +${OUTPUT}<" cleanup -OUTPUT="$(2>&1 nvm install v0.12.18)" +OUTPUT="$(TERM=dumb 2>&1 nvm install v0.12.18)" EXPECTED_OUTPUT="Downloading and installing node v0.12.18... Downloading https://nodejs.org/dist/v0.12.18/node-v0.12.18-linux-x64.tar.xz... -######################################################################## 100.0% +######################################################################### 100.0% Computing checksum with sha256sum Checksums matched! Now using node v0.12.18 (npm v2.15.11) Creating default alias: default -> v0.12.18 *" -[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "expected >${EXPECTED_OUTPUT}<, got >${OUTPUT}<" +[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] || (diff "${OUTPUT}" "${EXPECTED_OUTPUT}" ; die "2: expected > +${EXPECTED_OUTPUT}<, got > +${OUTPUT}<") cleanup