chiark / gitweb /
Test suite: Make t-reporefs stash the output
[dgit.git] / tests / lib
index a0a84dda142143b49901a7549e6638a1331c0d62..776e2a3e40f42bf426365d96f2894e57795044e7 100644 (file)
--- a/tests/lib
+++ b/tests/lib
@@ -2,6 +2,7 @@
 
 exec 2>&1
 set -x
 
 exec 2>&1
 set -x
+set -o pipefail
 
 . tests/lib-core
 
 
 . tests/lib-core
 
@@ -43,11 +44,25 @@ END
 
 t-expect-fail () {
        local mpat="$1"; shift
 
 t-expect-fail () {
        local mpat="$1"; shift
+       set +o pipefail
        LC_MESSAGES=C "$@" 2>&1 | tee $tmp/t.output
        LC_MESSAGES=C "$@" 2>&1 | tee $tmp/t.output
-       test ${PIPESTATUS[0]} != 0
+       local gotstatus=${PIPESTATUS[0]}
+       set -o pipefail
+       test $gotstatus != 0
        egrep "$mpat" $tmp/t.output ||false
 }
 
        egrep "$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 () {
        local tarfile=$1.tar
        local edittree=$1.edit
 t-untar () {
        local tarfile=$1.tar
        local edittree=$1.edit