Don't crap out on failed diff.
[open-adventure.git] / tests / tapdiffer
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 otherwise.
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 else
20         echo "not ok - ${checkfile}: ${legend}"
21         if [ ! "${QUIET}" = 1 ]
22         then
23                 echo "  --- |"
24                 sed </tmp/tapdiff$$ -e 's/^/  /'
25                 echo "  ..."
26         fi
27 fi
28
29 # end