From a80f958a1e9cc9540e88b02d3bfb0f41046cd48e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 14 Sep 2014 16:03:55 -0700 Subject: [PATCH 1/6] All 4 of these test files should be executable. --- test/fast/Listing versions/teardown | 0 ...ning \"nvm copy-packages $(nvm ls current)\" should error out" | 0 .../nvm install/install version specified in .nvmrc from binary | 0 .../nvm install/install version specified in .nvmrc from source | 0 4 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 test/fast/Listing versions/teardown mode change 100644 => 100755 "test/slow/nvm copy-packages/Running \"nvm copy-packages $(nvm ls current)\" should error out" mode change 100644 => 100755 test/slow/nvm install/install version specified in .nvmrc from binary mode change 100644 => 100755 test/slow/nvm install/install version specified in .nvmrc from source diff --git a/test/fast/Listing versions/teardown b/test/fast/Listing versions/teardown old mode 100644 new mode 100755 diff --git "a/test/slow/nvm copy-packages/Running \"nvm copy-packages $(nvm ls current)\" should error out" "b/test/slow/nvm copy-packages/Running \"nvm copy-packages $(nvm ls current)\" should error out" old mode 100644 new mode 100755 diff --git a/test/slow/nvm install/install version specified in .nvmrc from binary b/test/slow/nvm install/install version specified in .nvmrc from binary old mode 100644 new mode 100755 diff --git a/test/slow/nvm install/install version specified in .nvmrc from source b/test/slow/nvm install/install version specified in .nvmrc from source old mode 100644 new mode 100755 From 243fc04164ee72074b054c34a6a7374a68054ba2 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 14 Sep 2014 16:04:04 -0700 Subject: [PATCH 2/6] Fixing these test files that have never been run --- ...-packages $(nvm ls current)\" should error out" | 14 +++++++++----- ...install version specified in .nvmrc from binary | 2 +- ...install version specified in .nvmrc from source | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git "a/test/slow/nvm copy-packages/Running \"nvm copy-packages $(nvm ls current)\" should error out" "b/test/slow/nvm copy-packages/Running \"nvm copy-packages $(nvm ls current)\" should error out" index 2e0d058..e296e7c 100755 --- "a/test/slow/nvm copy-packages/Running \"nvm copy-packages $(nvm ls current)\" should error out" +++ "b/test/slow/nvm copy-packages/Running \"nvm copy-packages $(nvm ls current)\" should error out" @@ -2,11 +2,15 @@ die () { echo $@ ; exit 1; } -. ../../nvm.sh +. ../../../nvm.sh -local EXPECTED_MSG="Can not copy packages from the current version of node." -[ "$(nvm use 0.10.28 && nvm copy-packages 0.10.28 2&>1)" = "$EXPECTED_MSG" ] || die '"nvm use 0.10.28 && nvm copy-packages 0.10.28" did not fail with the right message' +nvm use 0.10.28 > /dev/null -$(nvm use 0.10.28 && nvm copy-packages 0.10.28) -[ $? = 2 ] || die '"nvm use 0.10.28 && nvm copy-packages 0.10.28" did not fail with the right error code' +EXPECTED_MSG="Can not copy packages from the current version of node." +ACTUAL_MSG="$(nvm copy-packages 0.10.28 2>&1 > /dev/null)" +[ "~$ACTUAL_MSG" = "~$EXPECTED_MSG" ] || die "'nvm use 0.10.28 && nvm copy-packages 0.10.28' did not fail with the right message: '$ACTUAL_MESSAGE'" + +EXPECTED_ERROR_CODE="2" +ACTUAL_ERROR_CODE="$(nvm copy-packages 0.10.28 > /dev/null 2>&1 ; echo $?)" +[ "~$ACTUAL_ERROR_CODE" = "~$EXPECTED_ERROR_CODE" ] || die "'nvm use 0.10.28 && nvm copy-packages 0.10.28' did not fail with the right error code: expected '$EXPECTED_ERROR_CODE', got '$ACTUAL_ERROR_CODE'" diff --git a/test/slow/nvm install/install version specified in .nvmrc from binary b/test/slow/nvm install/install version specified in .nvmrc from binary index dec2fe1..7758afe 100755 --- a/test/slow/nvm install/install version specified in .nvmrc from binary +++ b/test/slow/nvm install/install version specified in .nvmrc from binary @@ -9,7 +9,7 @@ NVM_TEST_VERSION=v0.10.7 [ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION # Install from binary -cat "$NVM_TEST_VERSION" > .nvmrc +echo "$NVM_TEST_VERSION" > .nvmrc nvm install diff --git a/test/slow/nvm install/install version specified in .nvmrc from source b/test/slow/nvm install/install version specified in .nvmrc from source index 6910228..189fffa 100755 --- a/test/slow/nvm install/install version specified in .nvmrc from source +++ b/test/slow/nvm install/install version specified in .nvmrc from source @@ -9,7 +9,7 @@ NVM_TEST_VERSION=v0.10.7 [ -e ../../../$NVM_TEST_VERSION ] && rm -R ../../../$NVM_TEST_VERSION # Install from binary -cat "$NVM_TEST_VERSION" > .nvmrc +echo "$NVM_TEST_VERSION" > .nvmrc nvm install -s From ad2713b13a0feb0644f55f5a88be0ea89f301e29 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 14 Sep 2014 16:04:13 -0700 Subject: [PATCH 3/6] `&>` is a bash-specific extension for redirecting both stdout and stderr. --- ...te the \"current\" symlink if $NVM_SYMLINK_CURRENT is false" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/test/fast/Running \"nvm use x\" should not create the \"current\" symlink if $NVM_SYMLINK_CURRENT is false" "b/test/fast/Running \"nvm use x\" should not create the \"current\" symlink if $NVM_SYMLINK_CURRENT is false" index 8ae7b29..23bbe38 100755 --- "a/test/fast/Running \"nvm use x\" should not create the \"current\" symlink if $NVM_SYMLINK_CURRENT is false" +++ "b/test/fast/Running \"nvm use x\" should not create the \"current\" symlink if $NVM_SYMLINK_CURRENT is false" @@ -34,7 +34,7 @@ function cleanup() { function runNvmUse() { mkdir ../../${TEST_NODE_VERSION} - nvm use ${TEST_NODE_VERSION} &> /dev/null + nvm use ${TEST_NODE_VERSION} > /dev/null 2>&1 rmdir ../../${TEST_NODE_VERSION} } From f8054d5cae2c576ac9df46908f65cf7491665386 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 14 Sep 2014 16:04:25 -0700 Subject: [PATCH 4/6] copy-packages: ensure that `nvm_version` is also applied to compare the provided version to the current one. --- nvm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nvm.sh b/nvm.sh index 678ab64..982994f 100644 --- a/nvm.sh +++ b/nvm.sh @@ -796,7 +796,7 @@ nvm() { local PROVIDED_VERSION PROVIDED_VERSION="$2" - if [ "$PROVIDED_VERSION" = "$(nvm_ls_current)" ]; then + if [ "$PROVIDED_VERSION" = "$(nvm_ls_current)" ] || [ "$(nvm_version $PROVIDED_VERSION)" = "$(nvm_ls_current)" ]; then echo 'Can not copy packages from the current version of node.' >&2 return 2 fi From 4c948cf4220e54277093e982196091226e1b966b Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 14 Sep 2014 16:04:37 -0700 Subject: [PATCH 5/6] install: Ensure that if a version is not provided, we don't try to shift a nonexistent argument. --- nvm.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nvm.sh b/nvm.sh index 982994f..ed01e08 100644 --- a/nvm.sh +++ b/nvm.sh @@ -433,19 +433,20 @@ nvm() { fi provided_version=$1 + if [ -z "$provided_version" ]; then if [ $version_not_provided -ne 1 ]; then nvm_rc_version fi provided_version="$NVM_RC_VERSION" + else + shift fi [ -d "$(nvm_version_path "$provided_version")" ] && echo "$provided_version is already installed." >&2 && return VERSION=`nvm_remote_version $provided_version` ADDITIONAL_PARAMETERS='' - shift - while [ $# -ne 0 ] do ADDITIONAL_PARAMETERS="$ADDITIONAL_PARAMETERS $1" From 3d3145f2e067f67e1da3fa15e377ae063d20ea41 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 14 Sep 2014 16:04:51 -0700 Subject: [PATCH 6/6] install: don't output "additional options" when there are none. --- nvm.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nvm.sh b/nvm.sh index ed01e08..bbeba05 100644 --- a/nvm.sh +++ b/nvm.sh @@ -495,7 +495,9 @@ nvm() { fi fi - echo "Additional options while compiling: $ADDITIONAL_PARAMETERS" + if [ -n "$ADDITIONAL_PARAMETERS" ]; then + echo "Additional options while compiling: $ADDITIONAL_PARAMETERS" + fi tarball='' sum=''