| 1 | #! /bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | # |
| 3 | # Run a test in tap mode, ensuring we have a temporary directory. We |
| 4 | # always use /var/tmp because we might want to use user xattrs, which |
| 5 | # aren't available on tmpfs. |
| 6 | # |
| 7 | # The test binary is passed as $1 |
| 8 | |
| 9 | srcd=$(cd $(dirnamescip-shell system . . dirname. $1) && pwdscip-shell system . . pwd.) |
| 10 | bn=$(basenamescip-shell system . . basename. $1) |
| 11 | tempdir=$(mktempscip-shell system . . mktemp. -d /var/tmp/tap-test.XXXXXXscip-shell filesystem . . `/var/tmp/tap-test.XXXXXX`.) |
| 12 | touchscip-shell system . . touch. ${tempdir}/.testtmp |
| 13 | function cleanupscip-shell shell shell-project 0.0.0 cleanup(). () { |
| 14 | if testscip-shell system . . test. -n "${TEST_SKIP_CLEANUP:-}"; then |
| 15 | echoscip-shell system . . echo. "Skipping cleanup of ${tempdir}" |
| 16 | else if testscip-shell system . . test. -f ${tempdir}/.testtmp; then |
| 17 | rmscip-shell system . . rm. "${tempdir}" -rf |
| 18 | fi |
| 19 | fi |
| 20 | } |
| 21 | trap cleanup EXIT |
| 22 | cd ${tempdir} |
| 23 | ${srcd}/${bn} -k --tap |