| 1 | #! /bin/bash |
| 2 | # |
| 3 | # Run a test in tap mode, ensuring we have a temporary directory. |
| 4 | # |
| 5 | # The test binary is passed as $1 |
| 6 | |
| 7 | srcd=$(cd $(dirname $1) && pwd) |
| 8 | bn=$(basename $1) |
| 9 | shift |
| 10 | tempdir=$(mktemp -d /tmp/tap-test.XXXXXX) |
| 11 | touch ${tempdir}/.testtmp |
| 12 | function cleanup () { |
| 13 | if test -n "${TEST_SKIP_CLEANUP:-}"; then |
| 14 | echo "Skipping cleanup of ${tempdir}" |
| 15 | else if test -f ${tempdir}/.testtmp; then |
| 16 | rm "${tempdir}" -rf |
| 17 | fi |
| 18 | fi |
| 19 | } |
| 20 | trap cleanup EXIT |
| 21 | cd ${tempdir} |
| 22 | if [[ $bn == *.wrap ]]; then |
| 23 | WRAPPER=${srcd}/test-wrapper.sh |
| 24 | fi |
| 25 | $WRAPPER ${srcd}/${bn} -k --tap "$@" |