mirror of
https://github.com/ostreedev/ostree.git
synced 2025-01-09 01:18:35 +03:00
a6eb8bbcf6
I find myself often wanting to debug interactively failing tests. This makes it more convenient to keep around the temporary directories just for those tests, rather than accumulating tons of tempdirs from the successful tests as well. Closes: #588 Approved by: jlebon
35 lines
719 B
Bash
Executable File
35 lines
719 B
Bash
Executable File
#! /bin/bash
|
|
#
|
|
# Run a test in tap mode, ensuring we have a temporary directory. We
|
|
# always use /var/tmp becuase we might want to use user xattrs, which
|
|
# aren't available on tmpfs.
|
|
#
|
|
# The test binary is passed as $1
|
|
|
|
srcd=$(cd $(dirname $1) && pwd)
|
|
bn=$(basename $1)
|
|
tempdir=$(mktemp -d /var/tmp/tap-test.XXXXXX)
|
|
touch ${tempdir}/.testtmp
|
|
function cleanup () {
|
|
if test -f ${tempdir}/.testtmp; then
|
|
rm "${tempdir}" -rf
|
|
fi
|
|
}
|
|
function skip_cleanup() {
|
|
echo "Skipping cleanup of ${tempdir}"
|
|
}
|
|
cd ${tempdir}
|
|
${srcd}/${bn} -k --tap
|
|
rc=$?
|
|
case "${TEST_SKIP_CLEANUP:-}" in
|
|
no|"") cleanup ;;
|
|
err)
|
|
if test $rc != 0; then
|
|
skip_cleanup
|
|
else
|
|
cleanup
|
|
fi ;;
|
|
*) skip_cleanup ;;
|
|
esac
|
|
exit $rc
|