3 # tapdiffer - Render diff between input and checkfile as a TAP report
5 # Usage: tapdiffer LEGEND CHECKFILE
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.
11 # This code is intended to be embedded in your project. The author
12 # grants permission for it to be distributed under the prevailing
13 # license of your project if you choose, provided that license is
14 # OSD-compliant; otherwise the following SPDX tag incorporates the
15 # MIT No Attribution license by reference.
17 # SPDX-FileCopyrightText: (C) Eric S. Raymond <esr@thyrsus.com>
18 # SPDX-License-Identifier: MIT-0
20 # A newer version may be available at https://gitlab.com/esr/tapview
21 # Check your last commit dqte for this file against the commit list
22 # there to see if it might be a good idea to update.
29 *) echo "tapdiffer: unknown option ${opt}."; exit 1;;
32 # shellcheck disable=SC2004
33 shift $(($OPTIND - 1))
38 trap 'rm /tmp/tapdiff$$' EXIT HUP INT QUIT TERM
40 if diff --text "${diffopts}" "${checkfile}" - >/tmp/tapdiff$$
44 echo "not ok - ${legend}"
45 if [ ! "${QUIET}" = 1 ]
48 sed </tmp/tapdiff$$ -e 's/^/ /'