grayhemp / bats-mock

Mocking for Bats
The Unlicense
43 stars 10 forks source link

mock_create tests fail if BATS_TMPDIR contains any inaccessible folders #5

Closed exodious closed 4 years ago

exodious commented 4 years ago

When running the bats-mock tests, two of the mock_create tests fail:

not ok 1 mock_create creates a program
# (in test file test/mock_create.bats, line 12)
#   `[[ -x "${output}" ]]' failed
ok 2 mock_create names the program uniquely
not ok 3 mock_create creates a program in BATS_TMPDIR
# (in test file test/mock_create.bats, line 27)
#   `[[ "$(dirname ${output})" = "${BATS_TMPDIR}" ]]' failed
...

build_test_fail.log

Experimentation has found that if TMPDIR is set to a directory without any inaccessible directories, e.g.:

TMPDIR=`mktemp -d` ./build test

Then the tests pass:

ok 1 mock_create creates a program
ok 2 mock_create names the program uniquely
ok 3 mock_create creates a program in BATS_TMPDIR
...

build_test_pass.log

The problem occurs when TMPDIR is unset (and thus /tmp is used) or if TMPDIR is set, and in either case the directory to which it refers contains directories that find cannot access.