From ae908cbff6e10caa5d7afc4e4b87540b5e6b0e88 Mon Sep 17 00:00:00 2001 From: Michael Klement Date: Wed, 3 Dec 2014 01:47:54 -0500 Subject: [PATCH] obsolete check for the urchin cross-shell test feature; fix for spurious warnings; improved robustness --- Makefile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 46149d4..f8afe29 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,14 @@ + # Since we rely on paths relative to the makefile location, abort if make isn't being run from there. +$(if $(findstring /,$(MAKEFILE_LIST)),$(error Please only invoke this makefile from the directory it resides in)) # Note: With Travis CI: # - the path to urchin is passed via the command line. - # - the other utilties are NOT needed, so we skip the test for their existence. + # - the other utilities are NOT needed, so we skip the test for their existence. URCHIN := urchin ifeq ($(findstring /,$(URCHIN)),) # urchin path was NOT passed in. # Add the local npm packages' bin folder to the PATH, so that `make` can find them, when invoked directly. - export PATH := $(shell printf '%s' "$$(npm bin):$$PATH") + # Note that rather than using `$(npm bin)` the 'node_modules/.bin' path component is hard-coded, so that invocation works even from an environment + # where npm is (temporarily) unavailable due to having deactivated an nvm instance loaded into the calling shell in order to avoid interference with tests. + export PATH := $(shell printf '%s' "$$PWD/node_modules/.bin:$$PATH") # The list of all supporting utilities, installed with `npm install`. UTILS := $(URCHIN) replace semver # Make sure that all required utilities can be located. @@ -17,9 +21,6 @@ SHELLS := sh bash dash zsh # ksh (#574) # Generate 'test-' target names from specified shells. # The embedded shell names are extracted on demand inside the recipes. SHELL_TARGETS := $(addprefix test-,$(SHELLS)) - # Determine if the installed Urchin version supports cross-shell testing, based on whether its usage information mentions the -s option. -HAVE_CROSS_SHELL_TESTS := $(shell PATH="$(PATH)" $(URCHIN) -h | grep -qE '(^|\s)-s\s' && echo 'yes') -NO_CROSS_SHELL_TESTS_WARNING := $(if $(HAVE_CROSS_SHELL_TESTS),,$(warning WARNING: This version of Urchin does not support cross-shell tests. All tests will run with 'sh'.)) # Define the default test suite(s). This can be overridden with `make TEST_SUITE=<...> `. # Test suites are the names of subfolders of './test'. TEST_SUITE := $(shell find ./test/* -type d -prune -exec basename {} \;) @@ -41,9 +42,8 @@ list: $(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" ] && for v in $$(export -p | awk -F'[ =]' '$$2 ~ "^NVM_" { print $$2 }'); do unset $$v; done && unset v; \ - [ "$(HAVE_CROSS_SHELL_TESTS)" = 'yes' ] && targetShellOpt="-s $$shell" || targetShellOpt=; \ - for suite in $(TEST_SUITE); do $(URCHIN) -f $$targetShellOpt test/$$suite || exit; done + [ -z "$$TRAVIS_BUILD_DIR" ] && for v in $$(set | awk -F'=' '$$1 ~ "^NVM_" { print $$1 }'); do unset $$v; done && unset v; \ + for suite in $(TEST_SUITE); do $(URCHIN) -f -s $$shell test/$$suite || exit; done # All-tests target: invokes the specified test suites for ALL shells defined in $(SHELLS). .PHONY: test