set +o pipefail
LC_MESSAGES=C "$@" 2>&1 | tee $tmp/t.output
- local gotstatus=${PIPESTATUS[0]}
+ local ps="${PIPESTATUS[*]}"
set -o pipefail
- test $gotstatus != 0
- $grepper -e "$mpat" $tmp/t.output ||false
+
+ case $ps in
+ "0 0") fail "command unexpectedly succeeded (instead of: $mpat)" ;;
+ *" 0") ;;
+ *) fail "tee failed" ;;
+ esac
+
+ $grepper -e "$mpat" $tmp/t.output ||
+ fail "error message not found"
}
t-reporefs () {
cd $p
mustfail () {
- local wantmsg="$1"; shift
+ local mpat="$1"; shift
t-reporefs pre-push
- set +o pipefail
+
+ t-expect-fail "$mpat" \
git push origin "$@" 2>&1 |tee $tmp/mustfail.txt
- ps="${PIPESTATUS[*]}"
- set -o pipefail
- case $ps in
- "0 0") fail "push unexpectedly succeeded (instead of: $wantmsg)" ;;
- *" 0") ;;
- *) fail "tee failed" ;;
- esac
- if ! fgrep "$wantmsg" $tmp/mustfail.txt >/dev/null; then
- fail "error message not found"
- fi
+
t-reporefs post-push
diff $tmp/show-refs.{pre,post}-push
}