From 3649f2b9a77c5e670876dfbc7a4821a80a088e6e Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 18 Oct 2026 23:14:27 -0700 Subject: [PATCH] [meta] `Makefile`: default `NVM_DIR` to the checkout when it is not set The test suites source `nvm.sh` without setting `NVM_DIR` unless the caller exports it, which locally (where `NVM_*` variables are unset first) and in the `urchin tests` workflow it is not. bash and zsh then detect the checkout from the sourced file, but sh and dash have no way to locate a sourced file, so they fell back to `dirname "$0"`, which happened to be the test's own directory. The `test-` targets now export `NVM_DIR` as the checkout when it is still unset, so every shell runs the suites against the same `NVM_DIR`, and an explicitly provided `NVM_DIR` is kept Discovered by Anthropic's OSS Scanner, as ANT-2026-8RIT0MGO; the scanner reported it as a vulnerability, but it is not one. --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 2c43538e..d02763bc 100644 --- a/Makefile +++ b/Makefile @@ -38,12 +38,14 @@ list: # Set of test- targets; each runs the specified test suites for a single shell. # Note that preexisting NVM_* variables are unset to avoid interfering with tests, except when running the Travis tests (where NVM_DIR must be passed in and the env. is assumed to be pristine). +# NVM_DIR then defaults to this checkout when it is not set, since not every shell can locate a sourced nvm.sh. .PHONY: $(SHELL_TARGETS) $(SHELL_TARGETS): @shell='$@'; shell=$${shell##*-}; \ which "$$shell" >/dev/null || { printf '\033[0;31m%s\033[0m\n' "WARNING: Cannot test with shell '$$shell': not found." >&2; exit 0; } && \ printf '\n\033[0;34m%s\033[0m\n' "Running tests in $$shell"; \ [ -z "$$TRAVIS_BUILD_DIR" ] && [ -z "$$GITHUB_ACTIONS" ] && for v in $$(set | awk -F'=' '$$1 ~ "^NVM_" { print $$1 }'); do unset $$v; done && unset v; \ + [ -n "$${NVM_DIR-}" ] || export NVM_DIR="$$PWD"; \ for suite in $(TEST_SUITE); do \ echo "Running test suite: $$suite"; \ $(URCHIN) -f -s $$shell test/$$suite || exit; \