chiark / gitweb /
c8d1b0ae64fa353f46c9388527c6b51b456ccef5
[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         t-dgit setup-new-tree
104
105         t-dgit $dgitargs import-dsc ../${p}_${v}.dsc +$refname
106         git checkout $refname
107
108         sums=sums.$sfmt-$inst
109
110         for f in af/*; do
111                 git cat-file blob "refs/heads/$refname:$f" | sha256sum | \
112                         sed -e 's#-$#'$f'#' \
113                         >>../$sums
114         done
115
116         cd ..
117         diff -U0 sums $sums
118 }
119
120 : ----- generate the orig -----
121
122 tar --exclude=debian -zcf ${p}_${bv}.orig.tar.gz $p
123
124 : ----- test 1.0 native -----
125
126 native_addpatch () { :; }
127 native_convert () { :; }
128
129 sfmt_setup 1.1 native
130 sfmt_import norm
131
132 : ----- test 1.0 diff -----
133
134 diff_addpatch () { :; }
135 diff_convert () { :; }
136
137 sfmt_setup 1.1 diff
138 sfmt_import norm
139
140 : ----- test "3.0 (quilt)"
141
142 quilt_addpatch () {
143         pname=$1
144         cat >../editor.pl <<END
145                 next if m/^$/..0;
146                 s{^(description:).*}{\$1 dgit test patch $pname}i;
147                 \$_='' if m/^ /;
148 END
149         EDITOR="perl -pi $tmp/editor.pl" dpkg-source -iX --commit . $pname
150         test -f debian/patches/$pname
151 }
152
153 quilt_convert () {
154         mkdir -p debian/source
155         echo '3.0 (quilt)' >debian/source/format
156 }
157
158 sfmt_setup 1.0-1 quilt
159 sfmt_import norm
160 sfmt_import absurd --force-import-gitapply-absurd
161
162 #t-ok