From 93771a7f9c79aeafdf27f23fe4fa4197b1ec8ce5 Mon Sep 17 00:00:00 2001 From: Atsushi Yamamoto Date: Tue, 11 Oct 2016 23:43:10 -0700 Subject: [PATCH] [Tests] `nvm exec`/`nvm run`: add `--silent` tests Co-authored-by: Atsushi Yamamoto Co-authored-by: Jordan Harband --- ...> Running 'nvm exec --silent' should work} | 0 .../Running 'nvm run --silent' should work | 30 +++++++++++++++++++ 2 files changed, 30 insertions(+) rename test/slow/nvm exec/{Preamble works and respects 'silent' flag => Running 'nvm exec --silent' should work} (100%) create mode 100755 test/slow/nvm run/Running 'nvm run --silent' should work diff --git a/test/slow/nvm exec/Preamble works and respects 'silent' flag b/test/slow/nvm exec/Running 'nvm exec --silent' should work similarity index 100% rename from test/slow/nvm exec/Preamble works and respects 'silent' flag rename to test/slow/nvm exec/Running 'nvm exec --silent' should work diff --git a/test/slow/nvm run/Running 'nvm run --silent' should work b/test/slow/nvm run/Running 'nvm run --silent' should work new file mode 100755 index 0000000000..229c4adfb0 --- /dev/null +++ b/test/slow/nvm run/Running 'nvm run --silent' should work @@ -0,0 +1,30 @@ +#!/bin/sh + +set -ex + +die () { echo "$@" ; exit 1; } + +. ../../../nvm.sh + +echo "0.10.7" > .nvmrc + +# Check nvm run without --silent +OUTPUT="$(nvm run --version)" +EXPECTED_OUTPUT=" +Found '${PWD}/.nvmrc' with version <0.10.7> +Running node v0.10.7 (npm v1.2.21) +v0.10.7 +" +[ ">${OUTPUT}<" = ">${EXPECTED_OUTPUT}<" ] \ + || die "\`nvm run\` failed to run; did not match with the .nvmrc version; got >${OUTPUT}<" + +OUTPUT="$(nvm run --silent --version)" +EXPECTED_OUTPUT="v0.10.7" +[ "${OUTPUT}" = "${EXPECTED_OUTPUT}" ] \ + || die "\`nvm run --silent\` failed to run silently; expected no output, got >${OUTPUT}<" + +# Output shouldn't be silent if --silent flag is not at the third argument position +OUTPUT="$(nvm run --version --silent)" +EXPECTED_OUTPUT="" +[ "${OUTPUT}" != "${EXPECTED_OUTPUT}" ] \ + || die "\`nvm run --version --silent\` should not be silent; expected >${OUTPUT}<, got no output"