Skip to content

Commit 5268a95

Browse files
committed
tests: Make sure PATH is set for 'env -i'
'env -i' clears the complete environment, including PATH. In that case, on most platforms, when excuting commands without PATH being set, /usr/bin and /bin are searched, e.g. on Linux: $ strace env -i asdf |& grep asdf execve("/usr/bin/env", ["env", "-i", "asdf"], 0x7ffc3e3c0890 /* 27 vars */) = 0 execve("/bin/asdf", ["asdf"], 0x55be2da090d0 /* 0 vars */) = -1 ENOENT (No such file or directory) execve("/usr/bin/asdf", ["asdf"], 0x55be2da090d0 /* 0 vars */) = -1 ENOENT (No such file or directory) write(2, "\342\200\230asdf\342\200\231", 10‘asdf’) = 10 Howver, this does not hold on every platform. E.g. on Cygwin, so such fallback paths are searched: $ strace env -i asdf |& grep asdf 37 25736 [main] env 3516 build_argv: argv[2] = 'asdf' 643 30373 [main] env 3516 find_exec: find_exec (asdf) 35 30408 [main] env 3516 find_exec: (null) = find_exec (asdf) 36 30444 [main] env 3516 spawnve: spawnve (, asdf, 0x10040B000) ‘asdf’ 199 53601 [main] env 3516 write: 10 = write(2, 0x10040B040, 10) $ env -i zsh env: ‘zsh’: No such file or directory Therefore, PATH should be kept as-is when executing the test suite so that (1) the initial test-highlighting.zsh can be run, and (2) executables required by the test suite (e.g. tap-colorizer.zsh) can be executed correctly.
1 parent 6d5372a commit 5268a95

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ test:
4141
for test in highlighters/*; do \
4242
if [ -d $$test/test-data ]; then \
4343
echo "Running test $${test##*/}"; \
44-
env -i QUIET=$$QUIET $${TERM:+"TERM=$$TERM"} $(ZSH) -f tests/test-highlighting.zsh "$${test##*/}"; \
44+
env -i QUIET=$$QUIET $${TERM:+"TERM=$$TERM"} PATH="$$PATH" $(ZSH) -f tests/test-highlighting.zsh "$${test##*/}"; \
4545
: $$(( result |= $$? )); \
4646
fi \
4747
done; \

0 commit comments

Comments
 (0)