I have the following in some of my tests:
tmpdir=$(mktemp -d)
trap 'echo @@@@@@@@@@@@@@@@@@@ >&3' INT TERM HUP EXIT # trap is really meant to `rm -rf ${tmpdir}`
I'm expecting the echo
to be executed but not seeing the output.
What do my tests need to do to clean up after themselves?
bats
does not support tests withtrap
.What can be done is:
If you're like me and have temporary directories that are created inside functions, the following can then be used:
tmpdir="$(mktemp -d --tmpdir="${BATS_TMPDIR}")"
. That will get cleaned up when${BATS_TMPDIR}
is cleaned up in theteardown
function.