chiark / gitweb /
tests: import-dsc: Test corrupted ENV (#950446)
[dgit.git] / tests / tests / import-dsc
1 #!/bin/bash
2 set -e
3 . tests/lib
4 t-tstunt-parsechangelog
5
6 t-setup-import examplegit
7
8 p=example
9
10 check-import () {
11         path=$1
12         v=$2
13         opts=$3
14         branch=t.$v
15
16         dsc=${path}/${p}_${v}.dsc
17         t-dgit $opts import-dsc $dsc $branch
18
19         git checkout $branch
20
21         check-imported $dsc
22 }
23
24 check-imported () {
25         local dsc=$1
26         (
27         rm -rf ../t.unpack
28         mkdir ../t.unpack
29         cd ../t.unpack
30         dpkg-source -x $dsc
31         )
32
33         git checkout HEAD~0
34         git branch -D u.$v ||:
35         git checkout -b u.$v $branch
36         git rm -rf .
37         git clean -xdf
38         cp -al ../t.unpack/*/. .
39         git add -Af .
40
41         git diff --stat --exit-code
42 }
43
44 cd $p
45
46 check-import ../mirror/pool/main 1.2
47
48 dgit12=`git rev-parse HEAD`
49
50 dsc2=../mirror/pool/main/${p}_2.0.dsc
51
52 git checkout $branch
53 t-expect-fail 'is checked out - will not update' \
54 t-dgit import-dsc $dsc2 $branch
55
56 git checkout HEAD~0
57
58 t-expect-fail 'Not fast forward' \
59 t-dgit import-dsc $dsc2 $branch
60
61 t-expect-fail 'Not fast forward' \
62 t-dgit import-dsc $dsc2 ..$branch
63
64 t-dgit import-dsc $dsc2 +$branch
65 check-imported $dsc2
66
67 dsc3=$troot/pkg-srcs/example_1.0-1+brokenmeta.dsc
68 t-dgit import-dsc $dsc3 +$branch
69 check-imported $dsc3
70
71 cd ..
72 mkdir $p.2
73 cd $p.2
74
75 git init
76
77 check-import $troot/pkg-srcs 1.0-1
78
79 cd ..
80 v=1.0-1+absurd
81 rm -f ${p}_*
82 dsc=$troot/pkg-srcs/${p}_${v}.dsc
83 cd $p.2
84
85 cp $dsc ..
86 t-expect-fail 'No such file or directory' \
87 check-import .. $v
88
89 mkdir ../enoents
90 cp $dsc ../enoents
91 t-expect-fail 'No such file or directory' \
92 check-import ../enoents $v
93
94 cd ..
95 rm -f ${p}_${v}.dsc
96 dget -du file://$dsc
97 cd $p.2
98
99 check-import .. $v
100
101 t-expect-fail "Your git tree does not have that object" \
102 check-import ../mirror/pool/main 1.2 --no-chase-dsc-distro
103
104 check-import ../mirror/pool/main 1.2 --force-import-dsc-with-dgit-field
105
106 v=1.0-1.100
107 dsc2=$troot/pkg-srcs/${p}_${v}.dsc
108
109 t-expect-fail E:'Branch.*already exists' \
110 t-dgit import-dsc $dsc2 $branch
111
112 git branch merge-reset
113 t-dgit import-dsc $dsc2 ..$branch
114 t-has-ancestor merge-reset $branch
115
116 git push . +merge-reset:$branch
117
118 t-dgit import-dsc $dsc2 +$branch
119
120 mb=$(t-git-merge-base merge-reset $branch)
121 test "x$mb" = x
122
123 t-expect-fail 'signature check failed' \
124 t-dgit import-dsc --require-valid-signature $dsc2 +$branch
125
126 t-ok