| 1 | #! /bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | # |
| 3 | # tapdiffer - Render diff between input and checkfile as a TAP report |
| 4 | # |
| 5 | # Usage: tapdiffer LEGEND CHECKFILE |
| 6 | # |
| 7 | # Output is a TAP report, ok if the diff is empty and not ok otherwisw. |
| 8 | # A nonempty diff is shipped as a TAP YAML block following "not ok" |
| 9 | # unless QUIET=1 in the environment. |
| 10 | # |
| 11 | legend=$1 |
| 12 | checkfile=$2 |
| 13 | |
| 14 | trap 'rm /tmp/tapdiff$$' EXIT HUP INT QUIT TERM |
| 15 | |
| 16 | if diffscip-shell system . . diff. --text -u ${checkfile} - >/tmp/tapdiff$$ |
| 17 | then |
| 18 | echoscip-shell system . . echo. "ok - ${legend}" |
| 19 | exit 0 |
| 20 | else |
| 21 | echoscip-shell system . . echo. "not ok - ${checkfile}: ${legend}" |
| 22 | if [scip-shell system . . `[`. ! "${QUIET}" = 1 ] |
| 23 | then |
| 24 | echoscip-shell system . . echo. " --- |" |
| 25 | sedscip-shell system . . sed. </tmp/tapdiff$$ -e 's/^/ /' |
| 26 | echoscip-shell system . . echo. " ..." |
| 27 | fi |
| 28 | exit 1 |
| 29 | fi |
| 30 | |
| 31 | # end |