| 1 | #! /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 diff --text -u ${checkfile} - >/tmp/tapdiff$$ |
| 17 | then |
| 18 | echo "ok - ${legend}" |
| 19 | exit 0 |
| 20 | else |
| 21 | echo "not ok - ${checkfile}: ${legend}" |
| 22 | if [ ! "${QUIET}" = 1 ] |
| 23 | then |
| 24 | echo " --- |" |
| 25 | sed </tmp/tapdiff$$ -e 's/^/ /' |
| 26 | echo " ..." |
| 27 | fi |
| 28 | exit 1 |
| 29 | fi |
| 30 | |
| 31 | # end |