X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=tests%2Flib;h=5b93d98dc86b074d71080106cf9ca35a8ec43e9c;hb=2212a3b83e5e983a6d2b65a491287fa3d6bdbbbc;hp=332bef24414331a9bbd4f2774b1aabca5103dd0c;hpb=609f108165197b1d7a55a4908a321bad40a86442;p=dgit.git diff --git a/tests/lib b/tests/lib index 332bef24..5b93d98d 100644 --- a/tests/lib +++ b/tests/lib @@ -59,10 +59,45 @@ t-expect-fail () { 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-expect-push-fail () { + local mpat="$1"; shift + + local triedpush=`git rev-parse HEAD` + + t-reporefs pre-push + t-expect-fail "$mpat" "$@" + t-reporefs post-push + diff $tmp/show-refs.{pre,post}-push + + t-git-objects-not-present '' $triedpush + + eval "$t_expect_push_fail_hook" +} + +t-git-objects-not-present () { + # t-git-objects-not-present GITDIR|'' OBJID [...] + # specifying '' means the repo for package $p + local gitdir="${1-$tmp/git/$p.git}" + local obj + if ! [ -e "$gitdir" ]; then return; fi + for obj in "$@"; do + GIT_DIR=$gitdir \ + t-expect-fail 'unable to find' \ + git cat-file -t $obj + done } t-reporefs () {