chiark / gitweb /
Test suite: Move setting of grepper in t-expect-fail (nfc)
[dgit.git] / tests / lib
index ebfe5a788bdc3f41f45c31c36cba0c137b3a1c54..7cd8062cae3c7d1b6671832bce1197a9d35a587a 100644 (file)
--- a/tests/lib
+++ b/tests/lib
@@ -47,6 +47,17 @@ 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
+
        local grepper=fgrep
        case "$mpat" in
        [A-Z]:*)
@@ -59,17 +70,6 @@ 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"
 }
@@ -92,7 +92,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 +107,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 +130,7 @@ t-worktree () {
 
 t-select-package () {
        p=$1
+       dgitrepo=$tmp/git/$p.git
 }
 
 t-git () {
@@ -251,11 +252,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 +408,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`