]> git.pond.sub.org Git - empserver/commitdiff
tests: New helper cmp_out1
authorMarkus Armbruster <armbru@pond.sub.org>
Wed, 29 Jan 2014 20:09:04 +0000 (21:09 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 1 Feb 2015 15:52:59 +0000 (16:52 +0100)
Factor out of cmp_out, then make it optionally take an explicit
expected result.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
tests/test-common.sh

index 7681cac03b117e2e6c14799fdbf2f67d79209112..04cb09ab54d087fab1e2740ec6539534e3848e8a 100644 (file)
@@ -210,44 +210,56 @@ cmp_logs_xdump()
 
 cmp_out()
 {
-    local i exp act nrm
+    local i
 
     for i
-    do
-       exp="$testdir/${i##*/}"
-       act="sandbox/$i"
-       nrm="sandbox/normalized-${i##*/}"
+    do cmp_out1 "$i"
+    done
+}
 
-       if [ ! -e "$exp" ]
-       then
-           case "$i" in
-           *.status)   exp=sandbox/ok.status; echo 0 >sandbox/ok.status ;;
-           *)          exp=/dev/null ;;
-           esac
-       fi
+cmp_out1()
+{
+    local i=$1 exp="${2-$testdir/${1##*/}}"
+    local act="sandbox/$i"
+    local nrm="sandbox/normalized-${i##*/}"
 
+    if [ ! -e "$exp" ]
+    then
        case "$i" in
-       */journal.log)
-           perl "$srcdir"/tests/normalize.pl -j "$act" ;;
-       */server.log)
-           perl "$srcdir"/tests/normalize.pl -s "$act" ;;
-       *.xdump)
-           perl "$srcdir"/tests/normalize.pl "$act" ;;
-       *.err)
-           perl -pe 's/\s+$/\n/;' -e "s,\Q$srcdir/tests\E,tests," "$act" ;;
+       *.status)
+           exp=sandbox/ok.status
+           echo 0 >sandbox/ok.status
+           ;;
        *)
-           perl -pe 's/\s+$/\n/;' "$act" ;;
-       esac >"$nrm"
-       if diff -u "$exp" "$nrm" >"$nrm.diff"
-       then
-           echo "$i OK"
-       elif [ "$EMPIRE_CHECK_ACCEPT" ]
-       then
-           echo "$i CHANGED"
-           cp "$nrm" "$exp"
-       else
-           failed=y
-           echo "$i FAIL"
-       fi
-    done
+           [ ! -e "$act" ] && return
+           exp=/dev/null
+           ;;
+           *.status)   exp=sandbox/ok.status; echo 0 >sandbox/ok.status ;;
+           *)          exp=/dev/null ;;
+       esac
+    fi
+
+    case "$i" in
+    */journal.log)
+       perl "$srcdir"/tests/normalize.pl -j "$act" ;;
+    */server.log)
+       perl "$srcdir"/tests/normalize.pl -s "$act" ;;
+    *.xdump)
+       perl "$srcdir"/tests/normalize.pl "$act" ;;
+    *.err)
+       perl -pe 's/\s+$/\n/;' -e "s,\Q$srcdir/tests\E,tests," "$act" ;;
+    *)
+       perl -pe 's/\s+$/\n/;' "$act" ;;
+    esac >"$nrm"
+    if diff -u "$exp" "$nrm" >"$nrm.diff"
+    then
+       echo "$i OK"
+    elif [ "$EMPIRE_CHECK_ACCEPT" ]
+    then
+       echo "$i CHANGED"
+       cp "$nrm" "$exp"
+    else
+       failed=y
+       echo "$i FAIL"
+    fi
 }