X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dgit.git;a=blobdiff_plain;f=tests%2Flib;h=0b8836266fbfc1746a16a09a2d71c10205a19a06;hp=046d36289c1145b53d37f7b7d1dbd4d575e4d9b2;hb=d3606ff36cbf24f80152c5848fefee0c62686486;hpb=c17699d17f17f6ea105b7440ff95fa39eebb54a6 diff --git a/tests/lib b/tests/lib index 046d3628..0b883626 100644 --- a/tests/lib +++ b/tests/lib @@ -5,12 +5,16 @@ set -x set -o pipefail . tests/lib-core +. tests/lib-restricts t-set-intree -: ${DGIT_TEST_DEBUG:=-D} +: ${DGIT_TEST_DEBUG=-D} export DGIT_TEST_DEBUG +export GIT_COMMITTER_DATE='1440253867 +0100' +export GIT_AUTHOR_DATE='1440253867 +0100' + root=`pwd` troot=$root/tests testname="${DGIT_TEST_TESTNAME-${0##*/}}" @@ -44,9 +48,32 @@ incoming = $tmp/incoming run_dinstall = 0 END +t-git-next-date () { + GIT_COMMITTER_DATE="$(( ${GIT_COMMITTER_DATE%% *} + 1 )) ${GIT_COMMITTER_DATE#* }" + GIT_AUTHOR_DATE="$GIT_COMMITTER_DATE" +} + 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 +86,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 () { @@ -104,11 +120,12 @@ t-git-objects-not-present () { t-reporefs () { local whichoutput=$1; shift + local whichrepo=${1-$dgitrepo} local outputfile="$tmp/show-refs.$whichoutput" (set -e exec >"$outputfile" - if test -d $dgitrepo; then - cd $dgitrepo + if test -d $whichrepo; then + cd $whichrepo git show-ref |sort fi) } @@ -117,7 +134,7 @@ t-untar () { local tarfile=$1.tar local edittree=$1.edit if test -d "$edittree"; then - cp -al "$edittree"/* . + cp -a "$edittree"/* . else tar xf "$tarfile" fi @@ -293,6 +310,15 @@ t-diff-nogit () { diff --exclude=.git --exclude=.pc -ruN $* } +t-files-notexist () { + local f + for f in "$@"; do + if [ -e $f ]; then + fail "$f exists!" + fi + done +} + t-cloned-fetched-good () { t-diff-nogit ../extract/$p-${v%-*} . t-clean-on-branch dgit/sid @@ -419,6 +445,16 @@ t-pushed-good () { git verify-tag `t-v-tag` } +t-commit-build-push-expect-log () { + local msg=$1 + local mpat=$2 + t-commit "$msg" + t-dgit build + LC_MESSAGES=C \ + t-dgit push --new 2>&1 |tee $tmp/push.log + t-grep-mpat "$mpat" $tmp/push.log +} + t-822-field () { local file=$1 local field=$2 @@ -476,6 +512,28 @@ t-apply-diff () { | patch -p1 -u } +t-gbp-unapplied-pq2qc () { + # does `gbp pq export' (leaving us on BRANCH (eg "quilt-tip")) + # commits the resulting debian/patches on qc/BRANCH + # goes back to patch-queue/BRANCH + # qc/BRANCH is not fast-forwarding + + gbp pq export + + branch=`git symbolic-ref HEAD` + branch=${branch#refs/heads/} + + case "$branch" in + */*) fail "unexpected branch $branch" ;; + esac + + git branch -f qc/$branch + git checkout qc/$branch + git add debian/patches + git commit -m 'Commit patch queue' + git checkout patch-queue/$branch +} + t-commit () { local msg=$1 v=${2-1.$revision} @@ -540,14 +598,20 @@ t-policy-nonexist () { ln -sf no-such-file-or-directory $drs_dispatch/policy-hook } -t-policy () { - local policyhook=$1 - policyhook=${DGIT_INFRA_PFX}$policyhook - case $policyhook in +t-make-hook-link () { + local hook=$1 # in infra/ + local linkpath=$2 + hook=${DGIT_INFRA_PFX}$hook + case $hook in */*) ;; - *) policyhook=`type -P $policyhook` ;; + *) hook=`type -P $hook` ;; esac - ln -sf "$policyhook" $drs_dispatch/policy-hook + ln -sf "$hook" $linkpath +} + +t-policy () { + local policyhook=$1 + t-make-hook-link $policyhook $drs_dispatch/policy-hook } t-debpolicy () { @@ -563,6 +627,15 @@ t-policy-periodic () { test-dummy $drs_dispatch '' --cron } +t-restrict () { + local restriction=$1 + (cd $root; t-restriction-$restriction >&2) +} + +t-dependencies () { + : "Hopefully installed: $*" +} + t-chain-test () { local ct=$1 local d=${0%/*}