| 1 | #! /bin/bashscip-shell filesystem . . `/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 $(dirnamescip-shell system . . dirname. $1) && pwdscip-shell system . . pwd.) |
| 8 | bn=$(basenamescip-shell system . . basename. $1) |
| 9 | shift |
| 10 | tempdir=$(mktempscip-shell system . . mktemp. -d /tmp/tap-test.XXXXXXscip-shell filesystem . . `/tmp/tap-test.XXXXXX`.) |
| 11 | touchscip-shell system . . touch. ${tempdir}/.testtmp |
| 12 | function cleanupscip-shell shell shell-project 0.0.0 cleanup(). () { |
| 13 | if testscip-shell system . . test. -n "${TEST_SKIP_CLEANUP:-}"; then |
| 14 | echoscip-shell system . . echo. "Skipping cleanup of ${tempdir}" |
| 15 | else if testscip-shell system . . test. -f ${tempdir}/.testtmp; then |
| 16 | rmscip-shell system . . 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 "$@" |