From caa881729a9d394fec28b952fc111c6008613e55 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 23 Mar 2016 13:27:51 +0100 Subject: initial import MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- patch-test/__test | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100755 patch-test/__test (limited to 'patch-test/__test') diff --git a/patch-test/__test b/patch-test/__test new file mode 100755 index 0000000..508d3ae --- /dev/null +++ b/patch-test/__test @@ -0,0 +1,120 @@ +#!/bin/bash + + +N=26 + +if test -z "$PATCH"; then + PATCH=../../patch +fi + + +if test -z $NGARBAGE; then + NGARBAGE=0 +fi +if test -z $UGARBAGE; then + UGARBAGE=0 +fi +if test -z $CGARBAGE; then + CGARBAGE=0 +fi +if test -z $EGARBAGE; then + EGARBAGE=0 +fi +if test -z $OLDFILE; then + OLDFILE=old +fi +if test -z $NEWFILE; then + NEWFILE=new +fi +p="$PREFIX $PATCH $SUFFIX -o -" +cd -- "$(dirname "$0")" +if test $# = 0; then + set $(seq $N) +fi +run () +{ + if test $1 = patch; then + x=$NGARBAGE + f="" + elif test $1 = patch-u; then + x=$UGARBAGE + f=" -u" + elif test $1 = patch-u0; then + x=$UGARBAGE + f=" -U0" + elif test $1 = patch-u1; then + x=$UGARBAGE + f=" -U1" + elif test $1 = patch-c; then + x=$CGARBAGE + f=" -c" + elif test $1 = patch-c0; then + x=$CGARBAGE + f=" -C0" + elif test $1 = patch-c1; then + x=$CGARBAGE + f=" -C1" + elif test $1 = patch-e; then + x=$EGARBAGE + f=" -e" + fi + + if test -f $1; then + if test $2 = fuzzy || test $2 = applied; then + exec 3>&2 + exec 2>tmp + fi + + if test -z $IFLAG; then + if test $x = 0; then + diff <($p < $1 $OLDFILE) $NEWFILE > /dev/null + else + $p < $1 $OLDFILE > /dev/null + fi + else + if test $x = 0; then + diff <($p -i$1 $OLDFILE) $NEWFILE > /dev/null + else + $p -i$1 $OLDFILE > /dev/null + fi + fi + val=$? + if test $val = $x && test $2 = fuzzy; then + grep 'ward fuzz' < tmp >/dev/null + val=$? + elif test $val = $x && test $2 = applied; then + grep 'hunk number 2 of 2' < tmp >/dev/null + val=$? + fi + + if test $val = $x; then + printf "\033[1;32mTest %s%s%s OK%s\033[m\n" "$LABEL" $2 "$f" "$3" + else + printf "\033[1;31mTest %s%s%s FAILED%s\033[m\n" "$LABEL" $2 "$f" "$3" + fi + + if test $2 = fuzzy || test $2 = applied; then + exec 2>&3 + exec 3>&- + rm tmp + fi + fi +} +for i in $@; do + cd $i + run patch $i + run patch-u $i + run patch-u0 $i + run patch-u1 $i + run patch-c $i + run patch-c0 $i + run patch-c1 $i + if test -z $SKIPE; then + if test -z $NPE; then + run patch-e $i + else + run patch-e $i " (NON-POSIX)" + fi + fi + cd .. +done -- cgit v1.2.3-70-g09d2