chiark / gitweb /
Test suite: Make t-expect-fail flexible wrt which grep to run
[dgit.git] / tests / lib
index cf8b72569dfdabc2368c0f49f4762cc4dede8128..332bef24414331a9bbd4f2774b1aabca5103dd0c 100644 (file)
--- a/tests/lib
+++ b/tests/lib
@@ -44,12 +44,36 @@ END
 
 t-expect-fail () {
        local mpat="$1"; shift
+
+       local grepper=fgrep
+       case "$mpat" in
+       [A-Z]:*)
+               case "$mpat" in
+               E:*)    grepper=egrep   ;;
+               F:*)    grepper=fgrep   ;;
+               *)      fail "bad mpat prefix in $mpat";;
+               esac
+               mpat=${mpat#[A-Z]:}
+               ;;
+       esac
+
        set +o pipefail
        LC_MESSAGES=C "$@" 2>&1 | tee $tmp/t.output
        local gotstatus=${PIPESTATUS[0]}
        set -o pipefail
        test $gotstatus != 0
-       egrep "$mpat" $tmp/t.output ||false
+       $grepper -e "$mpat" $tmp/t.output ||false
+}
+
+t-reporefs () {
+       local whichoutput=$1; shift
+       local outputfile="$tmp/show-refs.$whichoutput"
+       (set -e
+        exec >"$outputfile"
+        if test -d $tmp/git/$p.git; then
+               cd $tmp/git/$p.git
+               git show-ref |sort
+       fi)
 }
 
 t-untar () {