Commit f530a60
committed
bats/helpers: Create script before setting PATH
The following test case from `tests/new.bats` was failing on Windows
(using the MSYS2 Bash 4.3.46(2)-release from Git for Windows):
✗ new: error if setting permissions fails
(from function `stub_program_in_path' in file lib/bats/helpers, line 320,
in test file tests/new.bats, line 268)
`stub_program_in_path 'chmod' 'printf "ARG: %s\n" "$@"' 'exit 1'' failed
ARG: 700
ARG: /tmp/test rootdir/bin/chmod
ARG: -R
ARG: u+rwx
ARG: /tmp/test rootdir
Apparently on this platform, `chmod` wasn't already `hash`-ed, and using
`stub_program_in_path` to stub out `chmod` was causing
`create_bats_test_script` to look up `chmod` in `PATH` andinvoke the
stub script itself.
The fix: call `create_bats_test_script` before setting `PATH`. The
existing `stub_program_in_path for testing external program` test case
from `tests/bats-helpers.bats` now uses `chmod` for its example program
instead of `git`, which reproduced the original failure and verifies its
fix.1 parent 5abb59b commit f530a60
2 files changed
+4
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
313 | 313 | | |
314 | 314 | | |
315 | 315 | | |
| 316 | + | |
316 | 317 | | |
317 | 318 | | |
318 | 319 | | |
319 | 320 | | |
320 | | - | |
321 | 321 | | |
322 | 322 | | |
323 | 323 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
243 | | - | |
| 243 | + | |
244 | 244 | | |
245 | 245 | | |
246 | | - | |
247 | | - | |
| 246 | + | |
| 247 | + | |
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
| |||
0 commit comments