chiark / gitweb /
test suite: tagupl: Use a different strategy to avoid fsck fail
[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 mv-ident () {
50         local f=$tmp/$1
51         if test -e $f; then
52                 mv $f $f--$ident
53         fi
54 }
55
56 next-mangle () {
57         mv-ident tagupl/overall.log
58         mv-ident sendmail.log
59         ident=$1
60 }
61
62 with-mangled () {
63         local perl=$1
64         perl <../basetag >../badtag-$ident -pe "$perl"
65         git tag -u Senatus -f -s -m "$(cat ../badtag-$ident)" "$tagname"
66
67         t-tagupl-run-drs
68 }
69
70 expect-quit () {
71         next-mangle "$1"
72         local perl=$2
73         local mstring=$3
74         with-mangled "$perl"
75         grep ": $mstring" ../tagupl/overall.log
76 }
77
78 tagname=test-dummy/1.2
79 t-expect-fail E:'failed command: git fetch' \
80 t-tagupl-run-drs
81
82 tagname=splorf/$v     ; expect-quit baddistro '' 'tag name not for us'
83 tagname=test-dummy/1,2; expect-quit badver    '' 'tag name not for us'
84 tagname=test-dummy/$v
85
86 expect-quit noplease s/please-upload/plunk/ 'tag missing please-upload'
87
88 # we are going to trash $p because it will contain corrupted objects
89 # which makes our end-of-test fsck fail
90 cp -al ../$p ../$p.save
91 cd ../$p
92
93 next-mangle badtagger
94 git cat-file tag test-dummy/1.0-1 | perl -pe '
95         s/\+\d+$/xyz/ if m/^tagger /;
96         exit 0 if m/^$/;
97 ' >../tagobj-$ident
98 echo >>../tagobj-$ident
99 cat ../basetag >>../tagobj-$ident
100 git update-ref $tagname $(git hash-object -w -t tag ../tagobj-$ident)
101
102 cd ..
103 rm -rf $p
104 mv $p.save $p
105
106 t-ok