From e77ed07ccc053d030d553bb71b86dfc11dabbce3 Mon Sep 17 00:00:00 2001 From: Alex Aubuchon Date: Tue, 13 Oct 2020 12:32:41 -0400 Subject: [PATCH] [Tests] Fix `nvm_ls_current` fast test --- test/fast/Unit tests/nvm_ls_current | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/fast/Unit tests/nvm_ls_current b/test/fast/Unit tests/nvm_ls_current index 0e44b20..f2c5e65 100755 --- a/test/fast/Unit tests/nvm_ls_current +++ b/test/fast/Unit tests/nvm_ls_current @@ -19,7 +19,8 @@ fi rm -rf "$TEST_DIR" mkdir "$TEST_DIR" -ln -s "$(command which which)" "$TEST_DIR/which" +# Ensure that the system version of which is used, not node_modules/.bin/which +ln -s "$(PATH=$(echo $PATH | tr ":" "\n" | grep -v "node_modules/.bin" | tr "\n" ":") command which which)" "$TEST_DIR/which" ln -s "$(command which dirname)" "$TEST_DIR/dirname" ln -s "$(command which printf)" "$TEST_DIR/printf" @@ -27,12 +28,12 @@ ln -s "$(command which printf)" "$TEST_DIR/printf" [ "@$(PATH="$TEST_DIR" nvm_ls_current 2> /dev/stdout 1> /dev/null)@" = "@@" ] || die 'when node not installed, nvm_ls_current returned error output' echo "#!/bin/bash" > "$TEST_DIR/node" -echo "echo 'VERSION FOO!'" > "$TEST_DIR/node" +echo "echo 'VERSION FOO!'" >> "$TEST_DIR/node" chmod a+x "$TEST_DIR/node" -[ "$(alias nvm_tree_contains_path='return_zero' && PATH="$TEST_DIR" nvm_ls_current)" = "VERSION FOO!" ] || die 'when activated, did not return nvm node version' +[ "$(PATH="$TEST_DIR" nvm_ls_current)" = "VERSION FOO!" ] || die 'when activated, did not return nvm node version' alias node='node --harmony' -[ "$(alias nvm_tree_contains_path='return_zero' && PATH="$TEST_DIR" nvm_ls_current)" = "VERSION FOO!" ] || die 'when activated and node aliased, did not return nvm node version' +[ "$(PATH="$TEST_DIR" nvm_ls_current)" = "VERSION FOO!" ] || die 'when activated and node aliased, did not return nvm node version' cleanup