X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dgit.git;a=blobdiff_plain;f=tests%2Flib;h=118c497115e9f1ac96198a6c7b392653215cc394;hp=ebfe5a788bdc3f41f45c31c36cba0c137b3a1c54;hb=5ecff56dbf1b60b6b5c814b3450bf4ec37ed26d6;hpb=f1acf7af0d90aca442d1caaa1dbc901ff6adcfbc diff --git a/tests/lib b/tests/lib index ebfe5a78..118c4971 100644 --- a/tests/lib +++ b/tests/lib @@ -47,6 +47,24 @@ END t-expect-fail () { local mpat="$1"; shift + set +o pipefail + LC_MESSAGES=C "$@" 2>&1 | tee $tmp/t.output + local ps="${PIPESTATUS[*]}" + set -o pipefail + + case $ps in + "0 0") fail "command unexpectedly succeeded (instead of: $mpat)" ;; + *" 0") ;; + *) fail "tee failed" ;; + esac + + t-grep-mpat "$mpat" $tmp/t.output +} + +t-grep-mpat () { + local mpat="$1" + local file="$2" + local grepper=fgrep case "$mpat" in [A-Z]:*) @@ -59,19 +77,8 @@ t-expect-fail () { ;; esac - set +o pipefail - LC_MESSAGES=C "$@" 2>&1 | tee $tmp/t.output - local ps="${PIPESTATUS[*]}" - set -o pipefail - - 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" + $grepper -e "$mpat" "$file" || + fail "message not found" } t-expect-push-fail () { @@ -92,7 +99,7 @@ t-expect-push-fail () { 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 gitdir="${1-$dgitrepo}" local obj if ! [ -e "$gitdir" ]; then return; fi for obj in "$@"; do @@ -107,8 +114,8 @@ t-reporefs () { local outputfile="$tmp/show-refs.$whichoutput" (set -e exec >"$outputfile" - if test -d $tmp/git/$p.git; then - cd $tmp/git/$p.git + if test -d $dgitrepo; then + cd $dgitrepo git show-ref |sort fi) } @@ -130,6 +137,7 @@ t-worktree () { t-select-package () { p=$1 + dgitrepo=$tmp/git/$p.git } t-git () { @@ -251,11 +259,11 @@ t-archive () { } t-git-dir-time-passes () { - touch -d 'last year' $tmp/git/$p.git + touch -d 'last year' $dgitrepo } t-git-dir-check () { - local gitdir=$tmp/git/$p.git + local gitdir=$dgitrepo case "$1" in enoent) if test -e "$gitdir"; then fail "$gitdir exists"; fi @@ -407,7 +415,7 @@ t-pushed-good () { t-refs-notexist \ refs/heads/dgit/unstable \ refs/remotes/dgit/dgit/unstable - (set -e; cd $tmp/git/$p.git + (set -e; cd $dgitrepo t-refs-same \ refs/dgit/sid \ `t-v-tag`