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