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