summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/lib36
-rw-r--r--tests/lib-core2
-rw-r--r--tests/lib-orig-include-exclude62
-rwxr-xr-xtests/setup/examplegit2
-rwxr-xr-xtests/tests/gbp-orig75
-rwxr-xr-xtests/tests/import-dsc99
-rwxr-xr-xtests/tests/inarchivecopy34
-rwxr-xr-xtests/tests/orig-include-exclude25
-rwxr-xr-xtests/tests/orig-include-exclude-chkquery33
-rwxr-xr-xtests/tests/overwrite-splitbrains6
-rwxr-xr-xtests/tests/quilt-gbp9
-rwxr-xr-xtests/tests/quilt-splitbrains10
12 files changed, 369 insertions, 24 deletions
diff --git a/tests/lib b/tests/lib
index 5d8e742..23daeac 100644
--- a/tests/lib
+++ b/tests/lib
@@ -188,6 +188,8 @@ t-git-merge-base () {
}
t-has-ancestor () {
+ # t-has-ancestor ANCESTOR
+ # (CHILD is implicit, HEAD)
local now=`git rev-parse HEAD`
local ancestor=`git rev-parse $1^{}`
local mbase=`t-git-merge-base $ancestor $now`
@@ -196,6 +198,18 @@ t-has-ancestor () {
fi
}
+t-has-parent-or-is () {
+ # t-has-parent-or-is CHILD PARENT
+ local child=$1
+ local parent=$2
+ local parents=$(git show --pretty=format:' %P %H ' "$child")
+ parent=$(git rev-parse "$parent~0")
+ case "$parents" in
+ *" $parent "*) ;;
+ *) fail "child $child lacks parent $parent" ;;
+ esac
+}
+
t-prep-newpackage () {
t-select-package $1
v=$2
@@ -278,7 +292,7 @@ t-archive-updated () {
t-archive-process-incoming () {
local suite=$1
- mv $tmp/incoming/${p}_${v}[._]* $tmp/mirror/pool/main/
+ mv $tmp/incoming/${p}_* $tmp/mirror/pool/main/
t-archive-query "$suite"
}
@@ -475,17 +489,19 @@ t-ref-head () {
t-ref-same-val () {
local name="$1"
local val=$2
- case "$t_ref_val" in
- '') ;;
+ case "${t_ref_val-unset}" in
+ unset) ;;
"$val") ;;
- *) fail "ref varies: $name:\
- ${val:-nothing} != ${t_ref_val:-nothing}" ;;
+ *) fail "ref varies: ($name)\
+ ${val:-nothing} != ${t_ref_val:-nothing} (${t_ref_names[*]})" ;;
esac
t_ref_val="$val"
+ t_ref_names+=("$name")
}
t-refs-same-start () {
- t_ref_val=''
+ unset t_ref_val
+ t_ref_names=()
}
t-refs-same () {
@@ -573,6 +589,7 @@ t-splitbrain-pushed-good--unpack () {
mkdir t-unpack
cd t-unpack
ln -s $tmp/mirror/pool/main/*.orig*.tar* .
+ ln -s $tmp/incoming/*.orig*.tar* . ||:
ln -s $incoming_dsc .
ln -s ${incoming_dsc/.dsc/.debian.tar}* .
dpkg-source "$@" -x *.dsc
@@ -602,6 +619,13 @@ t-splitbrain-pushed-good-start () {
git merge-base --is-ancestor $dep14tag $dgittag
t-refs-same-start
+ t-ref-same refs/heads/split.p
+ case "$(t-git-get-ref refs/heads/split.b)" in
+ "$t_ref_val") ;;
+ "$(git rev-parse refs/heads/split.p^0)") ;;
+ "$(git rev-parse refs/heads/split.p^1)") ;;
+ *) fail 'bad b/p' ;;
+ esac
t-pushed-good-core
t-incoming-dsc
diff --git a/tests/lib-core b/tests/lib-core
index 056a1bc..7ed2761 100644
--- a/tests/lib-core
+++ b/tests/lib-core
@@ -20,6 +20,8 @@ t-set-using-tmp () {
export DGIT_TEST_DUMMY_DIR=$tmp
export DGIT_TEST_TMP=$tmp
export GNUPGHOME=$tmp/nonexistent
+ git config --global user.email 'dgit-test@debian.example.net'
+ git config --global user.name 'dgit test git user'
}
t-filter-out-git-hyphen-dir () {
diff --git a/tests/lib-orig-include-exclude b/tests/lib-orig-include-exclude
new file mode 100644
index 0000000..75a9656
--- /dev/null
+++ b/tests/lib-orig-include-exclude
@@ -0,0 +1,62 @@
+# designed to be .'d
+
+t-tstunt-parsechangelog
+
+t-archive example 1.0-1
+t-git-none
+
+t-dgit clone $p
+
+origs='orig orig-docs'
+usvsns='1.0 1.1'
+
+for o in $origs; do
+ cp ${p}_{1.0,1.1}.${o}.tar.gz
+done
+
+mkdir -p "$tmp/aq/file_in_archive/%"
+
+cd $p
+
+test-push-1 () {
+ v=$1
+ ch=$2
+ suite=$3
+
+ t-commit $v $v $suite
+ t-dgit $ch build
+}
+
+test-push-2 () {
+ $test_push_2_hook
+ t-dgit $ch "$@" push
+}
+
+test-push-1 1.0-2 --ch:-sa
+
+grep orig ../${p}_${v}_*.changes
+
+test-push-2
+
+# check that dgit stripped out the orig update
+find $tmp/mirror -name '*orig*' -ls >../before
+
+t-archive-process-incoming sid
+
+find $tmp/mirror -name '*orig*' -ls >../after
+diff -u ../before ../after
+
+test-push-1 1.1-1.2 --ch:-sd
+
+test-push-2
+
+t-archive-process-incoming sid
+
+cd ..
+mkdir get
+cd get
+
+t-dgit clone $p
+# ^ checks that all the origs are there, ie that dgit added the origs
+
+cd ..
diff --git a/tests/setup/examplegit b/tests/setup/examplegit
index 924113f..98900d0 100755
--- a/tests/setup/examplegit
+++ b/tests/setup/examplegit
@@ -2,7 +2,7 @@
set -e
. tests/lib
-suitespecs+=' stable'
+suitespecs+=' stable testing'
t-tstunt-parsechangelog
diff --git a/tests/tests/gbp-orig b/tests/tests/gbp-orig
new file mode 100755
index 0000000..ffc145f
--- /dev/null
+++ b/tests/tests/gbp-orig
@@ -0,0 +1,75 @@
+#!/bin/bash
+set -e
+. tests/lib
+
+t-tstunt-parsechangelog
+
+t-archive-none example
+t-git-none
+t-worktree 1.0
+
+cd $p
+
+: '----- construct an unpatched branch with patches -----'
+
+git checkout patch-queue/quilt-tip
+gbp pq export
+: 'now on quilt-tip'
+git add debian/patches
+git commit -m 'Commit patch queue'
+
+: '----- construct an upstream branch -----'
+
+git checkout --orphan upstream
+git reset --hard
+git clean -xdf
+
+tar --strip-components=1 -xf $troot/pkg-srcs/${p}_1.0.orig.tar.gz
+
+mkdir docs
+cd docs
+tar --strip-components=1 -xf $troot/pkg-srcs/${p}_1.0.orig-docs.tar.gz
+cd ..
+
+git add -Af .
+git commit -m 'Import 1.0'
+git tag upstream/1.0
+
+git checkout quilt-tip
+t-git-pseudo-merge upstream
+
+v=1.0-1
+
+: '----- let gbp build a .orig for comparison -----'
+
+gbp buildpackage --git-ignore-branch --git-no-sign-tags -us -uc
+
+mkdir ../gbp-output
+mv ../*1.0* ../gbp-output/.
+rm -f ../*.changes
+
+: '----- now do it ourselves -----'
+
+t-dgit -wgf --dgit-view-save=split.b gbp-build --git-ignore-branch
+
+t-dgit -wgf --quilt=gbp clean # gbp leaves dirty trees :-/
+
+t-dgit -wgf --dgit-view-save=split.p --quilt=gbp push --new
+
+t-gbp-pushed-good
+
+: '----- check .origs are the same -----'
+
+# if gbp weren't weird about .gitignore we could just debdiff the .dscs
+
+for d in . gbp-output; do
+ cd $tmp/$d
+ mkdir tar-x
+ cd tar-x
+ tar zxf ../${p}_${v%-*}.orig.tar.gz
+done
+
+cd $tmp
+diff -ruN gbp-output/tar-x tar-x
+
+echo done.
diff --git a/tests/tests/import-dsc b/tests/tests/import-dsc
new file mode 100755
index 0000000..9d3d9b7
--- /dev/null
+++ b/tests/tests/import-dsc
@@ -0,0 +1,99 @@
+#!/bin/bash
+set -e
+. tests/lib
+
+t-setup-import examplegit
+
+p=example
+
+check-import () {
+ path=$1
+ v=$2
+ opts=$3
+ branch=t.$v
+
+ dsc=${path}/${p}_${v}.dsc
+ t-dgit $opts import-dsc $dsc $branch
+
+ git checkout $branch
+
+ check-imported $dsc
+}
+
+check-imported () {
+ local dsc=$1
+ (
+ rm -rf ../t.unpack
+ mkdir ../t.unpack
+ cd ../t.unpack
+ dpkg-source -x $dsc
+ )
+
+ git checkout HEAD~0
+ git branch -D u.$v ||:
+ git checkout -b u.$v $branch
+ git rm -rf .
+ git clean -xdf
+ cp -al ../t.unpack/*/. .
+ git add -Af .
+
+ git diff --stat --exit-code
+}
+
+cd $p
+
+check-import ../mirror/pool/main 1.2
+
+dgit12=`git rev-parse HEAD`
+
+dsc2=../mirror/pool/main/${p}_2.0.dsc
+
+git checkout $branch
+t-expect-fail 'is checked out - will not update' \
+t-dgit import-dsc $dsc2 $branch
+
+git checkout HEAD~0
+
+t-expect-fail 'Not fast forward' \
+t-dgit import-dsc $dsc2 $branch
+
+t-expect-fail 'Not fast forward' \
+t-dgit import-dsc $dsc2 ..$branch
+
+t-dgit import-dsc $dsc2 +$branch
+check-imported $dsc2
+
+cd ..
+mkdir $p.2
+cd $p.2
+
+git init
+
+check-import ../../../pkg-srcs 1.0-1
+
+t-expect-fail "Your git tree does not have that object" \
+check-import ../mirror/pool/main 1.2
+
+check-import ../mirror/pool/main 1.2 --force-import-dsc-with-dgit-field
+
+v=1.0-1.100
+dsc2=../../../pkg-srcs/${p}_${v}.dsc
+
+t-expect-fail E:'Branch.*already exists' \
+t-dgit import-dsc $dsc2 $branch
+
+git branch merge-reset
+t-dgit import-dsc $dsc2 ..$branch
+t-has-ancestor merge-reset $branch
+
+git push . +merge-reset:$branch
+
+t-dgit import-dsc $dsc2 +$branch
+
+mb=$(t-git-merge-base merge-reset $branch)
+test "x$mb" = x
+
+t-expect-fail 'signature check failed' \
+t-dgit import-dsc --require-valid-signature $dsc2 +$branch
+
+echo ok.
diff --git a/tests/tests/inarchivecopy b/tests/tests/inarchivecopy
index e87baaf..632d420 100755
--- a/tests/tests/inarchivecopy
+++ b/tests/tests/inarchivecopy
@@ -14,34 +14,34 @@ t-inarchive-copy () {
local from=${2:-sid}
local to=${3:-stable}
egrep "^${vm//./\\.}" aq/package.$from.$p >>aq/package.$to.$p
- t-archive-updated stable $p
+ t-archive-updated $to $p
}
copy-check-good () {
git diff $vtag
- t-refs-same refs/remotes/dgit/dgit/stable
+ t-refs-same refs/remotes/dgit/dgit/$tosuite
t-ref-head
+ t-has-parent-or-is HEAD $vtag
}
copy-check () {
local vm=$1
- t-inarchive-copy $vm
+ local tosuite=${2:-stable}
+ t-inarchive-copy $vm '' $tosuite
vtag=$(v=$vm t-v-tag)
cd $p
t-refs-same-start
- t-ref-same $vtag^1
-
- t-dgit fetch stable
- git merge --ff-only dgit/dgit/stable
+ t-dgit fetch $tosuite
+ git merge --ff-only dgit/dgit/$tosuite
copy-check-good
local fetched=$(t-sametree-parent HEAD)
cd ..
rm -rf example.cloned
- t-dgit clone $p stable example.cloned
+ t-dgit clone $p $tosuite example.cloned
cd example.cloned
t-refs-same-start
@@ -49,13 +49,31 @@ copy-check () {
local cloned=$(t-sametree-parent HEAD)
cd ..
+ rm -rf example.initd
+ mkdir example.initd
+ cd example.initd
+ git init
+ t-refs-same-start
+ t-dgit -p $p fetch $tosuite
+ git reset --hard refs/remotes/dgit/dgit/$tosuite
+ copy-check-good
+ local initd=$(t-sametree-parent HEAD)
+ cd ..
+
t-refs-same-start
t-ref-same-val fetched $fetched
t-ref-same-val cloned $cloned
+ t-ref-same-val initd $initd
}
copy-check 2.0
copy-check 2.1
+cd $p
+git checkout -b dgit/testing $(v=1.1 t-v-tag)
+cd ..
+
+copy-check 2.1 testing
+
echo ok.
diff --git a/tests/tests/orig-include-exclude b/tests/tests/orig-include-exclude
new file mode 100755
index 0000000..96bf4f2
--- /dev/null
+++ b/tests/tests/orig-include-exclude
@@ -0,0 +1,25 @@
+#!/bin/bash
+set -e
+. tests/lib
+
+suitespecs+=' stable'
+
+. $troot/lib-orig-include-exclude
+
+ofb=example_1.1.orig.tar
+zcat $ofb.gz >$ofb.SPONG
+gzip -1Nv $ofb.SPONG
+mv $ofb.SPONG.gz $ofb.gz
+
+#suite=stable
+#t-archive-none $p
+#t-archive-updated stable $p
+
+cd $p
+
+test-push-1 1.1-1.3 '' stable
+
+t-expect-fail E:'archive contains .* with different checksum' \
+test-push-2 --new
+
+echo done.
diff --git a/tests/tests/orig-include-exclude-chkquery b/tests/tests/orig-include-exclude-chkquery
new file mode 100755
index 0000000..59fc80f
--- /dev/null
+++ b/tests/tests/orig-include-exclude-chkquery
@@ -0,0 +1,33 @@
+#!/bin/bash
+set -e
+. tests/lib
+
+t-git-config dgit-distro.test-dummy.archive-query ftpmasterapi:
+# ^ that will crash if it gets unexpected file_in_archive queries
+
+# orig-include-exclude will set origs and usvsns
+update-files_in_archive () {
+ for o in $origs; do for usvsn in $usvsns; do \
+ of=${p}_${v%-*}.${o}.tar.gz
+ pat="%/${of//_/\\_}"
+ # curl url-decodes these things so we have to have literals
+ find $tmp/mirror -name $of | \
+ xargs -r sha256sum | \
+ perl -pe '
+ BEGIN { print "["; }
+ chomp;
+ s/^/{"sha256sum":"/;
+ s/ /","filename":"/;
+ s/$/"}$delim/;
+ $delim=",";
+ END { print "]\n"; }
+ ' \
+ >$tmp/aq/"file_in_archive/$pat"
+ done; done
+}
+
+test_push_2_hook=update-files_in_archive
+
+. $troot/lib-orig-include-exclude
+
+echo done.
diff --git a/tests/tests/overwrite-splitbrains b/tests/tests/overwrite-splitbrains
index c0c7470..725357d 100755
--- a/tests/tests/overwrite-splitbrains
+++ b/tests/tests/overwrite-splitbrains
@@ -7,7 +7,7 @@ t-tstunt-parsechangelog
t-gbp-example-prep-no-ff
t-newtag
-t-dgit --quilt=gbp build-source
+t-dgit --quilt=gbp --dgit-view-save=split.b build-source
t-dgit fetch
@@ -15,12 +15,12 @@ t-refs-same-start
t-ref-head
t-expect-fail 'check failed (maybe --overwrite is needed' \
-t-dgit --quilt=gbp push
+t-dgit --quilt=gbp --dgit-view-save=split.p push
t-refs-same-start
t-ref-head
-t-dgit --quilt=gbp --overwrite push
+t-dgit --quilt=gbp --dgit-view-save=split.p --overwrite push
t-gbp-pushed-good
diff --git a/tests/tests/quilt-gbp b/tests/tests/quilt-gbp
index 21e396b..38d2489 100755
--- a/tests/tests/quilt-gbp
+++ b/tests/tests/quilt-gbp
@@ -14,7 +14,8 @@ t-expect-fail 'requires split view so server needs to support' \
t-dgit -wgf --quilt=gbp build-source
t-newtag
-t-dgit --quilt=gbp build-source
+t-dgit --quilt=gbp --dgit-view-save=split.b1 build-source
+git rev-parse split.b1
t-dgit --quilt=gbp --gbp-pq=no-such-command-gbp build-source
@@ -31,14 +32,14 @@ test-push-1 () {
}
test-push-2 () {
- t-dgit --quilt=gbp push
+ t-dgit --quilt=gbp --dgit-view-save=split.p push
t-gbp-pushed-good
}
test-push-1
-t-dgit --quilt=gbp --clean=git build-source
+t-dgit --quilt=gbp --clean=git --dgit-view-save=split.b build-source
t-expect-fail "HEAD specifies a different tree to $p" \
t-dgit push
@@ -53,7 +54,7 @@ t-commit 'Check pseudomerge' 1.0-3
test-push-1
-t-dgit --quilt=gbp --clean=git build-source
+t-dgit --quilt=gbp --clean=git --dgit-view-save=split.b build-source
test-push-2
diff --git a/tests/tests/quilt-splitbrains b/tests/tests/quilt-splitbrains
index 1e853f3..112bc39 100755
--- a/tests/tests/quilt-splitbrains
+++ b/tests/tests/quilt-splitbrains
@@ -2,6 +2,8 @@
set -e
. tests/lib
+suitespecs+=' stable'
+
# This test script tests each of the split brain quilt modes, and
# --quilt=linear, with a tree suitable for each of those, and pushes
# them in sequence. The idea is to check that each tree is rejected
@@ -24,9 +26,9 @@ want-success () {
t-refs-same-start
t-ref-head
- t-dgit "$@" --quilt=$qmode build-source
+ t-dgit "$@" --quilt=$qmode --dgit-view-save=split.b build-source
- t-dgit "$@" --quilt=$qmode push
+ t-dgit "$@" --quilt=$qmode --dgit-view-save=split.p push
t-$qmode-pushed-good
}
@@ -130,5 +132,9 @@ t-dgit -wgf build-source
want-success dpm
+suite=stable
+t-commit dpmish-stable 1.0-6 $suite
+
+want-success dpm --new
echo ok.