Partial REUSE cmpliance.
[open-adventure.git] / tests / tapdiffer
1 #! /bin/sh
2 # SPDX-FileCopyrightText: Eric S. Raymond
3 # SPDX-License-Identifier: BSD-2-Clause
4 #
5 # tapdiffer - Render diff between input and checkfile as a TAP report
6 #
7 # Usage: tapdiffer LEGEND CHECKFILE
8 #
9 # Output is a TAP report, ok if the diff is empty and not ok otherwise.
10 # A nonempty diff is shipped as a TAP YAML block following "not ok" 
11 # unless QUIET=1 in the environment.
12 #
13 if [ "$1" = "-w" ]
14 then
15     diffopts=-ubZ
16     shift
17 else
18     diffopts=-u
19 fi
20
21 legend=$1
22 checkfile=$2
23
24 trap 'rm /tmp/tapdiff$$' EXIT HUP INT QUIT TERM
25
26 if diff --text "${diffopts}" ${checkfile} - >/tmp/tapdiff$$
27 then
28         echo "ok - ${legend}"
29 else
30         echo "not ok - ${checkfile}: ${legend}"
31         if [ ! "${QUIET}" = 1 ]
32         then
33                 echo "  --- |"
34                 sed </tmp/tapdiff$$ -e 's/^/  /'
35                 echo "  ..."
36         fi
37 fi
38
39 # end