X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=test%2Ftapdiffer;h=4af0c83e29b882c9c166e64508ca9e93bd5a3d72;hb=9322858151c37351d9a5de99904d919691912e23;hp=f200de17723a8d438275d1c923f37af2e5b1bd45;hpb=d9b677a42a28fde6471b8467bffdf63ac9f144a3;p=super-star-trek.git diff --git a/test/tapdiffer b/test/tapdiffer index f200de1..4af0c83 100755 --- a/test/tapdiffer +++ b/test/tapdiffer @@ -1,31 +1,52 @@ #! /bin/sh +# SPDX-FileCopyrightText: Eric S. Raymond +# SPDX-License-Identifier: MIT-0 # # tapdiffer - Render diff between input and checkfile as a TAP report # # Usage: tapdiffer LEGEND CHECKFILE # -# Output is a TAP report, ok if the diff is empty and not ok otherwisw. +# Output is a TAP report, ok if the diff is empty and not ok otherwise. # A nonempty diff is shipped as a TAP YAML block following "not ok" # unless QUIET=1 in the environment. # +# This code is intended to be embedded in your project. The author +# grants permission for it to be distributed under the prevailing +# license of your project if you choose, provided that license is +# OSD-compliant; otherwise the following SPDX tag incorporates the +# MIT No Attribution license by reference. +# +# A newer version may be available at https://gitlab.com/esr/tapview +# Check your last commit dqte for this file against the commit list +# there to see if it might be a good idea to update. +# +diffopts=-u +while getopts bn opt +do + case $opt in + b) diffopts=-ub;; + *) echo "tapdiffer: unknown option ${opt}."; exit 1;; + esac +done +# shellcheck disable=SC2004 +shift $(($OPTIND - 1)) + legend=$1 checkfile=$2 trap 'rm /tmp/tapdiff$$' EXIT HUP INT QUIT TERM -if diff --text -u ${checkfile} - >/tmp/tapdiff$$ +if diff --text "${diffopts}" "${checkfile}" - >/tmp/tapdiff$$ then echo "ok - ${legend}" - exit 0 else - echo "not ok - ${checkfile}: ${legend}" + echo "not ok - ${legend}" if [ ! "${QUIET}" = 1 ] then echo " --- |" sed