Skip to content
Myr

[Tests] make “nvm use iojs” test actually test that thing.

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

authored by Jordan Harband · committed by Jordan Harband · parent 803adac · Browse files · 2 files+67 added−22 removed
This commit

State

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

Diff stats

2 files+67 added−22 removed

  • tests:+67 added−22 removed

2 files+67 added−22 removed

modified:test/fast/Running "nvm use iojs" uses latest io.js version+21 added-22 removed
1#!/bin/sh23set -ex45. ../common.sh67die () { echo $@ ; cleanup ; exit 1; }89VERSION="v3.99.0"1011cleanup() {6 rm -rf ../../alias/foo12 unset -f make_echo cleanup13 rm -rf "$(nvm_version_path "iojs-${VERSION}")"14}1516set +ex # TODO17. ../../nvm.sh18set -ex1911echo 'foo' > ../../alias/foo20nvm deactivate || die "unable to deactivate; current: >$(nvm current)<"2113OUTPUT="$(nvm use foo 2>&1)"14EXPECTED_OUTPUT='The alias "foo" leads to an infinite loop. Aborting.'15[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \16 || die "'nvm use foo' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"22make_fake_iojs "${VERSION}" || die "unable to make_fake_iojs ${VERSION}"2318EXIT_CODE="$(nvm use foo 2>/dev/null ; echo $?)"19[ "_$EXIT_CODE" = "_8" ] || die "Expected exit code 8; got $EXIT_CODE"24IOJS_VERSION="$(nvm_version iojs)"25[ -n "${IOJS_VERSION}" ] || die 'expected an io.js version; got none'2621OUTPUT="$(nvm use --silent foo 2>&1)"22EXPECTED_OUTPUT=''23[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \24 || die "'nvm use --silent foo' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"27EXPECTED_OUTPUT="$(nvm_add_iojs_prefix ${VERSION})"28[ "${IOJS_VERSION}" = "${EXPECTED_OUTPUT}" ] || die "iojs version was not >${EXPECTED_OUTPUT}; got >${IOJS_VERSION}<"2926OUTPUT="$(nvm use foo --silent 2>&1)"27EXPECTED_OUTPUT=''28[ "_$OUTPUT" = "_$EXPECTED_OUTPUT" ] \29 || die "'nvm use foo --silent' did not output '$EXPECTED_OUTPUT'; got '$OUTPUT'"30nvm use --delete-prefix iojs || die '`nvm use iojs` failed'3131EXIT_CODE="$(nvm use --silent foo 2>/dev/null ; echo $?)"32[ "_$EXIT_CODE" = "_8" ] || die "Expected exit code 8 from 'nvm use --silent foo'; got $EXIT_CODE"32CURRENT="$(nvm current)"33echo "current: ${CURRENT}"3434EXIT_CODE="$(nvm use foo --silent 2>/dev/null ; echo $?)"35[ "_$EXIT_CODE" = "_8" ] || die "Expected exit code 8 from 'nvm use foo --silent'; got $EXIT_CODE"35[ "${CURRENT}" = "${IOJS_VERSION}" ] || die "expected >${IOJS_VERSION}<; got >${CURRENT}<"3637cleanup;3837cleanup
modified:test/common.sh+46 added