chiark / gitweb /
9d3e45a1c177700e7674156d7256d46e1cd45406
[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 echo foo >bar
27 git add bar
28 git commit -m"corrupt the upstream source to test upstream-nonidentical check"
29
30 t-tagupl-settings
31
32 tagname=test-dummy/$v
33
34 t-expect-fail "the upstream source in tag $upstreamtag is not identical to the upstream source in refs/heads/master" \
35 t-tagupl-test --quilt=gbp --upstream=$upstreamtag
36
37 git reset --hard HEAD~1
38
39 t-expect-fail "upstream tag $upstreamtag is not an ancestor of refs/heads/master" \
40 t-tagupl-test --quilt=gbp --upstream=$upstreamtag
41
42 t-expect-fail "upstream tag $upstreamtag is not an ancestor of refs/heads/master" \
43 t-tagupl-test --quilt=gbp --force=suite --force=no-such-force-option --upstream=$upstreamtag
44
45 t-tagupl-test --quilt=gbp --force=suite --force=no-such-force-option-1 \
46               --force=upstream-nonancestor,no-such-force-option-2 \
47               --upstream=$upstreamtag
48 t-pushed-good master
49
50 # todo: test each miss/rejection
51
52 ident=ok
53
54 git cat-file tag $tagname >../basetag
55 v=1.0-2
56 tagname=test-dummy/$v
57
58 perl -i -ne '
59         next if $.==1../^$/;
60         next if m/^----/..0;
61         s/\b1\.0-1\b/1.0-2/g;
62         print or die $!;
63 ' ../basetag
64
65 mv-ident () {
66         local f=$tmp/$1
67         if test -e $f; then
68                 mv $f $f--$ident
69         fi
70 }
71
72 next-mangle () {
73         mv-ident tagupl/overall.log
74         mv-ident sendmail.log
75         ident=$1
76 }
77
78 with-mangled () {
79         local perl=$1
80         perl <../basetag >../badtag-$ident -pe "$perl"
81         git tag -u Senatus -f -s -m "$(cat ../badtag-$ident)" "$tagname"
82
83         LC_MESSAGES=C \
84         t-tagupl-run-drs $tmp/$p
85 }
86
87 expect-quit () {
88         next-mangle "$1"
89         local perl=$2
90         local mregexp=$3
91         with-mangled "$perl"
92         egrep ": $mregexp" ../tagupl/overall.log
93 }
94
95 expect-email () {
96         next-mangle "$1"
97         local perl=$2
98         local mregexp=$3
99         with-mangled "$perl"
100         egrep 'Was not successful' ../sendmail.log
101         egrep "$mregexp" ../sendmail.log
102         egrep ": failed, emailed" ../tagupl/overall.log
103 }
104
105 raw-mangled () {
106         git update-ref refs/tags/$tagname \
107                 $(git hash-object -w -t tag ../tagobj-$ident)
108         t-tagupl-run-drs $tmp/$p
109 }
110
111 tagname=test-dummy/1.2
112 t-expect-fail E:'failed command: git fetch' \
113 t-tagupl-run-drs $tmp/$p
114
115 tagname=splorf/$v     ; expect-quit baddistro '' 'tag name not for us'
116 tagname=test-dummy/1,2; expect-quit badver    '' 'tag name not for us'
117 tagname=test-dummy/$v
118
119 expect-quit noplease s/please-upload/plunk/ 'tag missing please-upload'
120
121 expect-email vermatch 's/^example release /$&3/' 'reject: version mismatch'
122
123 expect-email unkinfo 's/^\[dgit please-upload/$& Rejectme/' \
124         'unknown dgit info in tag'
125
126 expect-quit unkdistro 's/test-dummy/ubuntu/ if m/^\[dgit/' \
127         'not for this distro'
128
129 expect-email notsplit 's/ split / no-split /' 'reject: missing "split"'
130
131 expect-email upsnot1 's/ upstream=/ uxstream=/' \
132         'reject: upstream tag and not commitish'
133
134 expect-email upsnot2 's/ upstream-tag=/ uxstream-tag=/' \
135         'reject: upstream tag and not commitish'
136
137 expect-email bupstag1 's/ upstream-tag=/$&:/' \
138         "failed command: git check-ref-format"
139
140 expect-email bupstag2 's/ upstream-tag=/$&x/' \
141         "[Cc]ouldn't find remote ref refs/tags/xUPSTREAM"
142
143 expect-email wrongver '' 'mismatch: changelog Version'
144
145 v=1.0-2
146
147 t-dch-commit -v $v -m bump
148
149 expect-email upsmism 's/ upstream=/$&3/' \
150         "but tag refers to"
151
152 expect-email wrongpkg 's/^example /explosive /' 'mismatch: changelog Source'
153
154 # we are going to trash $p because it will contain corrupted objects
155 # which makes our end-of-test fsck fail
156 cp -al ../$p ../$p.save
157 cd ../$p
158
159 git cat-file tag $tagname >../raw-base
160
161 next-mangle sigfail
162 perl -pe <../raw-base >../tagobj-$ident 's/ split / split ignoreme /'
163 raw-mangled
164 grep 'gpgv: BAD signature' ../sendmail.log
165
166 next-mangle nosig
167 perl -ne <../raw-base >../tagobj-$ident 'print unless m/^-----/..0'
168 raw-mangled
169 grep 'missing signature' ../sendmail.log
170
171 git cat-file tag test-dummy/1.0-1 >../raw-base
172
173 next-mangle badtagger
174 perl -pe <../raw-base '
175         s/\+\d+$/xyz/ if m/^tagger /;
176         exit 0 if m/^$/;
177 ' >../tagobj-$ident
178 echo >>../tagobj-$ident
179 cat ../basetag >>../tagobj-$ident
180 raw-mangled
181 grep 'failed to fish tagger out of tag' ../tagupl/overall.log
182
183 cd ..
184 rm -rf $p
185 mv $p.save $p
186
187 t-ok