chiark / gitweb /
test suite: tagupl-*: Move t-pushed-good out of t-tagupl-test
[dgit.git] / tests / tests / tagupl
1 #!/bin/bash
2 set -e
3 . tests/lib
4
5 t-dependencies DEBORIG git-debpush
6
7 t-debpolicy
8
9 t-archive-none example
10 t-git-none
11 t-worktree 1.0
12
13 v=1.0-1
14
15 cd $p
16 git checkout -b native 
17
18 git checkout --orphan upstream quilt-tip-2
19 git rm -rf debian
20 git commit -m 'pseudo-upstream'
21 upstreamtag=UPSTREAM/RELEASE/1.0
22 git tag $upstreamtag
23
24 git checkout -B master quilt-tip-2
25
26 t-tagupl-settings
27
28 tagname=test-dummy/$v
29
30 t-tagupl-test --quilt=gbp --upstream=$upstreamtag
31 t-pushed-good master
32
33 # todo: test each miss/rejection
34
35 ident=ok
36
37 git cat-file tag $tagname >../basetag
38 v=1.0-2
39 tagname=test-dummy/$v
40
41 perl -i -ne '
42         next if $.==1../^$/;
43         next if m/^----/..0;
44         s/\b1\.0-1\b/1.0-2/g;
45         print or die $!;
46 ' ../basetag
47
48 mv-ident () {
49         local f=$tmp/$1
50         if test -e $f; then
51                 mv $f $f--$ident
52         fi
53 }
54
55 next-mangle () {
56         mv-ident tagupl/overall.log
57         mv-ident sendmail.log
58         ident=$1
59 }
60
61 with-mangled () {
62         local perl=$1
63         perl <../basetag >../badtag-$ident -pe "$perl"
64         git tag -u Senatus -f -s -m "$(cat ../badtag-$ident)" "$tagname"
65
66         t-tagupl-run-drs $tmp/$p
67 }
68
69 expect-quit () {
70         next-mangle "$1"
71         local perl=$2
72         local mstring=$3
73         with-mangled "$perl"
74         grep ": $mstring" ../tagupl/overall.log
75 }
76
77 expect-email () {
78         next-mangle "$1"
79         local perl=$2
80         local mstring=$3
81         with-mangled "$perl"
82         grep 'Was not successful' ../sendmail.log
83         grep "$mstring" ../sendmail.log
84         grep ": failed, emailed" ../tagupl/overall.log
85 }
86
87 raw-mangled () {
88         git update-ref refs/tags/$tagname \
89                 $(git hash-object -w -t tag ../tagobj-$ident)
90         t-tagupl-run-drs $tmp/$p
91 }
92
93 tagname=test-dummy/1.2
94 t-expect-fail E:'failed command: git fetch' \
95 t-tagupl-run-drs $tmp/$p
96
97 tagname=splorf/$v     ; expect-quit baddistro '' 'tag name not for us'
98 tagname=test-dummy/1,2; expect-quit badver    '' 'tag name not for us'
99 tagname=test-dummy/$v
100
101 expect-quit noplease s/please-upload/plunk/ 'tag missing please-upload'
102
103 expect-email vermatch 's/^example release /$&3/' 'reject: version mismatch'
104
105 expect-email unkinfo 's/^\[dgit please-upload/$& Rejectme/' \
106         'unknown dgit info in tag'
107
108 expect-quit unkdistro 's/test-dummy/ubuntu/ if m/^\[dgit/' \
109         'not for this distro'
110
111 expect-email notsplit 's/ split / no-split /' 'reject: missing "split"'
112
113 expect-email upsnot1 's/ upstream=/ uxstream=/' \
114         'reject: upstream tag and not commitish'
115
116 expect-email upsnot2 's/ upstream-tag=/ uxstream-tag=/' \
117         'reject: upstream tag and not commitish'
118
119 expect-email bupstag1 's/ upstream-tag=/$&:/' \
120         "failed command: git check-ref-format"
121
122 expect-email bupstag2 's/ upstream-tag=/$&x/' \
123         "Couldn't find remote ref refs/tags/xUPSTREAM"
124
125 expect-email wrongver '' 'mismatch: changelog Version'
126
127 v=1.0-2
128
129 t-dch-commit -v $v -m bump
130
131 expect-email upsmism 's/ upstream=/$&3/' \
132         "but tag refers to"
133
134 expect-email wrongpkg 's/^example /explosive /' 'mismatch: changelog Source'
135
136 # we are going to trash $p because it will contain corrupted objects
137 # which makes our end-of-test fsck fail
138 cp -al ../$p ../$p.save
139 cd ../$p
140
141 git cat-file tag $tagname >../raw-base
142
143 next-mangle sigfail
144 perl -pe <../raw-base >../tagobj-$ident 's/ split / split ignoreme /'
145 raw-mangled
146 grep 'gpgv: BAD signature' ../sendmail.log
147
148 next-mangle nosig
149 perl -ne <../raw-base >../tagobj-$ident 'print unless m/^-----/..0'
150 raw-mangled
151 grep 'missing signature' ../sendmail.log
152
153 git cat-file tag test-dummy/1.0-1 >../raw-base
154
155 next-mangle badtagger
156 perl -pe <../raw-base '
157         s/\+\d+$/xyz/ if m/^tagger /;
158         exit 0 if m/^$/;
159 ' >../tagobj-$ident
160 echo >>../tagobj-$ident
161 cat ../basetag >>../tagobj-$ident
162 raw-mangled
163 grep 'failed to fish tagger out of tag' ../tagupl/overall.log
164
165 cd ..
166 rm -rf $p
167 mv $p.save $p
168
169 t-ok