chiark / gitweb /
test suite: gitattributes: test unsetup tree, too
[dgit.git] / tests / tests / gitattributes
1 #!/bin/bash
2 set -e
3 . tests/lib
4
5 t-dependencies bsdgames
6 t-tstunt-parsechangelog
7
8 t-archive-none example
9 bv=1.0
10 t-worktree $bv
11
12 : ----- prepare badnesses -----
13
14 mkdir af
15
16 badattr1 () {
17         local filename=$1
18         local attrspec=$2
19         echo >>af/$filename "Test file with $attrspec"
20         printf >>af/$filename 'crlf: \r\n'
21         echo >>af/$filename 'id $Id: $'
22         echo >>af/$filename 'id $Id: SPLARK $'
23         echo >>gitattrs "af/$filename" "$attrspec"
24 }
25
26 badattr () {
27         attrname=$1; shift
28         badattr1 $attrname-set $attrname
29         badattr1 $attrname-unset -$attrname
30         badattr1 $attrname-unspec \!$attrname
31         local val
32         for val in "$@"; do
33                 badattr1 $attrname=$val $attrname=$val
34         done
35 }
36
37 # xxx want to make each of these files into a quilt patch
38
39 t-git-config core.eol crlf
40
41 badattr text auto
42 badattr eol lf crlf
43 badattr ident
44
45 t-git-config filter.dgit-test-crazy-f.smudge '/usr/games/rot13 2'
46 t-git-config filter.dgit-test-crazy-f.clean  '/usr/games/rot13 24'
47 t-git-config filter.dgit-test-crazy-f.requrired true
48
49 badattr filter dgit-test-crazy-f
50
51 badattr diff
52 badattr merge text binary union
53 badattr whitespace
54 badattr export-ignore
55 badattr export-subst
56 badattr delta
57 badattr encoding no-such-encoding
58
59 sha256sum af/* >sums
60
61 # ----- common to source formats -----
62
63 sfmt_setup () {
64         v=$1
65         sfmt=$2
66
67         pdb=$p.$sfmt
68
69         local addpatch=${sfmt}_addpatch
70         local convert=${sfmt}_convert
71
72         cp -a $p $pdb-edit
73         cd $pdb-edit
74
75         $convert
76
77         dch -v $v -m convert
78
79         rm -rf .git
80
81         cp ../gitattrs .gitattributes
82         $addpatch gitattrs
83
84         cp -a ../af .
85         $addpatch files
86
87         cp ../sums .
88         $addpatch sums
89
90         dpkg-source -b .
91
92         cd ..
93 }
94
95 sfmt_import () {
96         inst=$1
97         dgitargs=$2
98         refname="import.$sfmt-$inst"
99
100         mkdir $pdb-import-$inst
101         cd $pdb-import-$inst
102         git init
103
104         t-dgit $dgitargs import-dsc ../${p}_${v}.dsc +$refname.broken
105         git checkout $refname.broken
106         sha256sum af/* >../$sums.broken
107
108         for s in ../sums ../$sums.broken; do
109                 sed 's/[0-9a-f]* //' $s >$s.nosums
110         done
111         diff -U0 ../sums.nosums ../$sums.broken.nosums
112         set +e
113         diff -U0 ../sums ../$sums.broken
114         rc=$?
115         set -e
116         test $rc = 1
117
118         t-dgit setup-new-tree
119
120         t-dgit $dgitargs import-dsc ../${p}_${v}.dsc +$refname
121         git checkout $refname
122
123         sums=sums.$sfmt-$inst
124
125         for f in af/*; do
126                 git cat-file blob "refs/heads/$refname:$f" \
127                         | sha256sum \
128                         | sed -e 's#-$#'$f'#' \
129                 >>../$sums
130         done
131
132         cd ..
133         diff -U0 sums $sums
134 }
135
136 : ----- generate the orig -----
137
138 tar --exclude=debian -zcf ${p}_${bv}.orig.tar.gz $p
139
140 : ----- test 1.0 native -----
141
142 native_addpatch () { :; }
143 native_convert () { :; }
144
145 sfmt_setup 1.1 native
146 sfmt_import norm
147
148 : ----- test 1.0 diff -----
149
150 diff_addpatch () { :; }
151 diff_convert () { :; }
152
153 sfmt_setup 1.1 diff
154 sfmt_import norm
155
156 : ----- test "3.0 (quilt)"
157
158 quilt_addpatch () {
159         pname=$1
160         cat >../editor.pl <<END
161                 next if m/^$/..0;
162                 s{^(description:).*}{\$1 dgit test patch $pname}i;
163                 \$_='' if m/^ /;
164 END
165         EDITOR="perl -pi $tmp/editor.pl" dpkg-source -iX --commit . $pname
166         test -f debian/patches/$pname
167 }
168
169 quilt_convert () {
170         mkdir -p debian/source
171         echo '3.0 (quilt)' >debian/source/format
172 }
173
174 sfmt_setup 1.0-1 quilt
175 sfmt_import norm
176 sfmt_import absurd --force-import-gitapply-absurd
177
178 #t-ok