Fix nvm_ls_current fast unit test#2322
Fix nvm_ls_current fast unit test#2322ljharb merged 1 commit intonvm-sh:masterfrom reasonablytall:alexaub/ls-current-test-failing
nvm_ls_current fast unit test#2322Conversation
|
It's not clear to me why this test is passing in CI but fails locally, and I'm hesitant to change the test without knowing why this change fixes it. |
|
I think I mixed up return_zero being truthy/falsey in my initial explanation, and thought that that was the issue 😅 Digging deeper I believe I've figured out some things:
Based on this, I'm working on a fix that links the correct |
|
Thanks, I really appreciate the digging, and this sounds like the right track. |
test/fast/Unit tests/nvm_ls_current
Outdated
There was a problem hiding this comment.
i don't think /usr/bin will always be where it's located. i think the issue is that node_modules/.bin is in the PATH when npm run is used - so, can we remove that from the PATH rather than hardcoding one possible location of which?
|
|
||
| echo "#!/bin/bash" > "$TEST_DIR/node" | ||
| echo "echo 'VERSION FOO!'" > "$TEST_DIR/node" | ||
| echo "echo 'VERSION FOO!'" >> "$TEST_DIR/node" |
|
Thanks for the review! Made the change :) |
| 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" |
There was a problem hiding this comment.
hmm, too bad there's no ergonomic way to use nvm_strip_path here
Fixes one of the failing tests in #2181
nvm_ls_currentreturns 'system' whennvm_tree_contains_pathis aliased to return zero, as if nvm is deactivated. This fix instead setsNVM_DIRto matchTEST_DIRso thatnvm_tree_contains_pathpasses and the mock executable is actually used. Let me know if this approach is reasonable!Relevant branches in
nvm_ls_current:nvm/nvm.sh
Lines 915 to 925 in e01060f