diff options
author | Mattias Andrée <maandree@kth.se> | 2016-03-23 13:27:51 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@member.fsf.org> | 2016-03-23 13:29:26 +0100 |
commit | caa881729a9d394fec28b952fc111c6008613e55 (patch) | |
tree | 56e143e393f230d37ad08a0a13123e20d3f0cfe6 /patch-test/__test | |
download | base-util-tests-caa881729a9d394fec28b952fc111c6008613e55.tar.gz base-util-tests-caa881729a9d394fec28b952fc111c6008613e55.tar.bz2 base-util-tests-caa881729a9d394fec28b952fc111c6008613e55.tar.xz |
initial import
Signed-off-by: Mattias Andrée <maandree@member.fsf.org>
Diffstat (limited to '')
-rwxr-xr-x | patch-test/__test | 120 |
1 files changed, 120 insertions, 0 deletions
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 |