Blame


1 e9ce266e 2022-03-07 op #!/bin/sh
2 e9ce266e 2022-03-07 op #
3 e9ce266e 2022-03-07 op # Copyright (c) 2022 Omar Polo <op@openbsd.org>
4 e9ce266e 2022-03-07 op #
5 e9ce266e 2022-03-07 op # Permission to use, copy, modify, and distribute this software for any
6 e9ce266e 2022-03-07 op # purpose with or without fee is hereby granted, provided that the above
7 e9ce266e 2022-03-07 op # copyright notice and this permission notice appear in all copies.
8 e9ce266e 2022-03-07 op #
9 e9ce266e 2022-03-07 op # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 e9ce266e 2022-03-07 op # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 e9ce266e 2022-03-07 op # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 e9ce266e 2022-03-07 op # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 e9ce266e 2022-03-07 op # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 e9ce266e 2022-03-07 op # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 e9ce266e 2022-03-07 op # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 e9ce266e 2022-03-07 op
17 e9ce266e 2022-03-07 op . ./common.sh
18 e9ce266e 2022-03-07 op
19 57b1c3f2 2022-08-01 op test_patch_basic() {
20 57b1c3f2 2022-08-01 op local testroot=`test_init patch_basic`
21 e9ce266e 2022-03-07 op
22 e9ce266e 2022-03-07 op got checkout $testroot/repo $testroot/wt > /dev/null
23 e9ce266e 2022-03-07 op ret=$?
24 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
25 e9ce266e 2022-03-07 op test_done $testroot $ret
26 e9ce266e 2022-03-07 op return 1
27 e9ce266e 2022-03-07 op fi
28 e9ce266e 2022-03-07 op
29 57b1c3f2 2022-08-01 op jot 100 > $testroot/wt/numbers
30 57b1c3f2 2022-08-01 op (cd $testroot/wt && got add numbers && got commit -m +numbers) \
31 57b1c3f2 2022-08-01 op >/dev/null
32 e9ce266e 2022-03-07 op ret=$?
33 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
34 57b1c3f2 2022-08-01 op test_done "$testroot" $ret
35 e9ce266e 2022-03-07 op return 1
36 e9ce266e 2022-03-07 op fi
37 e9ce266e 2022-03-07 op
38 e9ce266e 2022-03-07 op cat <<EOF > $testroot/wt/patch
39 e9ce266e 2022-03-07 op --- alpha
40 e9ce266e 2022-03-07 op +++ alpha
41 e9ce266e 2022-03-07 op @@ -1 +1 @@
42 e9ce266e 2022-03-07 op -alpha
43 e9ce266e 2022-03-07 op +alpha is my favourite character
44 57b1c3f2 2022-08-01 op --- beta
45 57b1c3f2 2022-08-01 op +++ /dev/null
46 57b1c3f2 2022-08-01 op @@ -1 +0,0 @@
47 57b1c3f2 2022-08-01 op -beta
48 57b1c3f2 2022-08-01 op --- gamma/delta
49 57b1c3f2 2022-08-01 op +++ gamma/delta
50 e9ce266e 2022-03-07 op @@ -1 +1,2 @@
51 57b1c3f2 2022-08-01 op +this is:
52 57b1c3f2 2022-08-01 op delta
53 57b1c3f2 2022-08-01 op --- /dev/null
54 57b1c3f2 2022-08-01 op +++ eta
55 57b1c3f2 2022-08-01 op @@ -0,0 +5,5 @@
56 57b1c3f2 2022-08-01 op +1
57 57b1c3f2 2022-08-01 op +2
58 57b1c3f2 2022-08-01 op +3
59 57b1c3f2 2022-08-01 op +4
60 57b1c3f2 2022-08-01 op +5
61 e9ce266e 2022-03-07 op --- numbers
62 e9ce266e 2022-03-07 op +++ numbers
63 e9ce266e 2022-03-07 op @@ -3,7 +3,7 @@
64 e9ce266e 2022-03-07 op 3
65 e9ce266e 2022-03-07 op 4
66 e9ce266e 2022-03-07 op 5
67 e9ce266e 2022-03-07 op -6
68 57b1c3f2 2022-08-01 op +six
69 e9ce266e 2022-03-07 op 7
70 e9ce266e 2022-03-07 op 8
71 e9ce266e 2022-03-07 op 9
72 e9ce266e 2022-03-07 op @@ -57,7 +57,7 @@
73 e9ce266e 2022-03-07 op 57
74 e9ce266e 2022-03-07 op 58
75 e9ce266e 2022-03-07 op 59
76 e9ce266e 2022-03-07 op -60
77 57b1c3f2 2022-08-01 op +sixty
78 e9ce266e 2022-03-07 op 61
79 e9ce266e 2022-03-07 op 62
80 e9ce266e 2022-03-07 op 63
81 e9ce266e 2022-03-07 op @@ -98,3 +98,6 @@
82 e9ce266e 2022-03-07 op 98
83 e9ce266e 2022-03-07 op 99
84 e9ce266e 2022-03-07 op 100
85 e9ce266e 2022-03-07 op +101
86 e9ce266e 2022-03-07 op +102
87 57b1c3f2 2022-08-01 op +103
88 e9ce266e 2022-03-07 op EOF
89 e9ce266e 2022-03-07 op
90 9cda65e5 2022-10-15 stsp (cd $testroot/wt && got patch < patch) > $testroot/stdout
91 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
92 57b1c3f2 2022-08-01 op test_done "$testroot" $ret
93 e9ce266e 2022-03-07 op return 1
94 e9ce266e 2022-03-07 op fi
95 e9ce266e 2022-03-07 op
96 57b1c3f2 2022-08-01 op echo 'M alpha' > $testroot/stdout.expected
97 57b1c3f2 2022-08-01 op echo 'D beta' >> $testroot/stdout.expected
98 57b1c3f2 2022-08-01 op echo 'M gamma/delta' >> $testroot/stdout.expected
99 57b1c3f2 2022-08-01 op echo 'A eta' >> $testroot/stdout.expected
100 57b1c3f2 2022-08-01 op echo 'M numbers' >> $testroot/stdout.expected
101 57b1c3f2 2022-08-01 op
102 e9ce266e 2022-03-07 op cmp -s $testroot/stdout.expected $testroot/stdout
103 e9ce266e 2022-03-07 op ret=$?
104 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
105 e9ce266e 2022-03-07 op diff -u $testroot/stdout.expected $testroot/stdout
106 e9ce266e 2022-03-07 op test_done $testroot $ret
107 e9ce266e 2022-03-07 op return 1
108 e9ce266e 2022-03-07 op fi
109 e9ce266e 2022-03-07 op
110 57b1c3f2 2022-08-01 op echo 'alpha is my favourite character' > $testroot/wt/alpha.expected
111 57b1c3f2 2022-08-01 op cmp -s $testroot/wt/alpha.expected $testroot/wt/alpha
112 e9ce266e 2022-03-07 op ret=$?
113 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
114 57b1c3f2 2022-08-01 op diff -u $testroot/wt/alpha.expected $testroot/wt/alpha
115 57b1c3f2 2022-08-01 op test_done "$testroot" $ret
116 57b1c3f2 2022-08-01 op return 1
117 e9ce266e 2022-03-07 op fi
118 e9ce266e 2022-03-07 op
119 57b1c3f2 2022-08-01 op if [ -f "$testroot/wt/beta" ]; then
120 57b1c3f2 2022-08-01 op echo "beta was not deleted!" >&2
121 57b1c3f2 2022-08-01 op test_done "$testroot" 1
122 e9ce266e 2022-03-07 op return 1
123 e9ce266e 2022-03-07 op fi
124 e9ce266e 2022-03-07 op
125 57b1c3f2 2022-08-01 op echo 'this is:' > $testroot/wt/gamma/delta.expected
126 57b1c3f2 2022-08-01 op echo 'delta' >> $testroot/wt/gamma/delta.expected
127 57b1c3f2 2022-08-01 op cmp -s $testroot/wt/gamma/delta.expected $testroot/wt/gamma/delta
128 e9ce266e 2022-03-07 op ret=$?
129 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
130 57b1c3f2 2022-08-01 op diff -u $testroot/wt/gamma/delta.expected $testroot/wt/gamma/delta
131 57b1c3f2 2022-08-01 op test_done "$testroot" $ret
132 e9ce266e 2022-03-07 op return 1
133 e9ce266e 2022-03-07 op fi
134 e9ce266e 2022-03-07 op
135 57b1c3f2 2022-08-01 op jot 5 > $testroot/wt/eta.expected
136 57b1c3f2 2022-08-01 op cmp -s $testroot/wt/eta.expected $testroot/wt/eta
137 e9ce266e 2022-03-07 op ret=$?
138 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
139 57b1c3f2 2022-08-01 op diff -u $testroot/wt/eta.expected $testroot/wt/eta
140 57b1c3f2 2022-08-01 op test_done "$testroot" $ret
141 e9ce266e 2022-03-07 op return 1
142 e9ce266e 2022-03-07 op fi
143 e9ce266e 2022-03-07 op
144 57b1c3f2 2022-08-01 op jot 103 | sed -e 's/^6$/six/' -e 's/60/sixty/' \
145 57b1c3f2 2022-08-01 op > $testroot/wt/numbers.expected
146 57b1c3f2 2022-08-01 op cmp -s $testroot/wt/numbers.expected $testroot/wt/numbers
147 57b1c3f2 2022-08-01 op ret=$?
148 57b1c3f2 2022-08-01 op if [ $ret -ne 0 ]; then
149 57b1c3f2 2022-08-01 op diff -u $testroot/wt/numbers.expected $testroot/wt/numbers
150 57b1c3f2 2022-08-01 op fi
151 57b1c3f2 2022-08-01 op test_done $testroot $ret
152 e9ce266e 2022-03-07 op }
153 e9ce266e 2022-03-07 op
154 e9ce266e 2022-03-07 op test_patch_dont_apply() {
155 e9ce266e 2022-03-07 op local testroot=`test_init patch_dont_apply`
156 e9ce266e 2022-03-07 op
157 e9ce266e 2022-03-07 op got checkout $testroot/repo $testroot/wt > /dev/null
158 e9ce266e 2022-03-07 op ret=$?
159 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
160 e9ce266e 2022-03-07 op test_done $testroot $ret
161 e9ce266e 2022-03-07 op return 1
162 e9ce266e 2022-03-07 op fi
163 e9ce266e 2022-03-07 op
164 5b67f96e 2022-03-13 op jot 100 > $testroot/wt/numbers
165 5b67f96e 2022-03-13 op (cd $testroot/wt && got add numbers && got commit -m 'add numbers') \
166 5b67f96e 2022-03-13 op >/dev/null
167 5b67f96e 2022-03-13 op ret=$?
168 5b67f96e 2022-03-13 op if [ $ret -ne 0 ]; then
169 5b67f96e 2022-03-13 op test_done $testroot $ret
170 5b67f96e 2022-03-13 op return 1
171 5b67f96e 2022-03-13 op fi
172 5b67f96e 2022-03-13 op
173 5b67f96e 2022-03-13 op cat <<EOF > $testroot/wt/patch
174 60aa1fa0 2022-03-17 op --- alpha
175 60aa1fa0 2022-03-17 op +++ alpha
176 60aa1fa0 2022-03-17 op @@ -1 +1,2 @@
177 60aa1fa0 2022-03-17 op +hatsuseno
178 60aa1fa0 2022-03-17 op alpha something
179 5b67f96e 2022-03-13 op --- numbers
180 5b67f96e 2022-03-13 op +++ /dev/null
181 5b67f96e 2022-03-13 op @@ -1,9 +0,0 @@
182 5b67f96e 2022-03-13 op -1
183 5b67f96e 2022-03-13 op -2
184 5b67f96e 2022-03-13 op -3
185 5b67f96e 2022-03-13 op -4
186 5b67f96e 2022-03-13 op -5
187 5b67f96e 2022-03-13 op -6
188 5b67f96e 2022-03-13 op -7
189 5b67f96e 2022-03-13 op -8
190 5b67f96e 2022-03-13 op -9
191 5b67f96e 2022-03-13 op EOF
192 5b67f96e 2022-03-13 op
193 60aa1fa0 2022-03-17 op (cd $testroot/wt && got patch patch) > $testroot/stdout 2> /dev/null
194 5b67f96e 2022-03-13 op ret=$?
195 5b67f96e 2022-03-13 op if [ $ret -eq 0 ]; then # should fail
196 5b67f96e 2022-03-13 op test_done $testroot 1
197 e9ce266e 2022-03-07 op return 1
198 e9ce266e 2022-03-07 op fi
199 e9ce266e 2022-03-07 op
200 60aa1fa0 2022-03-17 op cat <<EOF > $testroot/stdout.expected
201 60aa1fa0 2022-03-17 op # alpha
202 60aa1fa0 2022-03-17 op @@ -1,1 +1,2 @@ hunk failed to apply
203 60aa1fa0 2022-03-17 op # numbers
204 60aa1fa0 2022-03-17 op @@ -1,9 +0,0 @@ hunk failed to apply
205 bfcdc9e9 2023-05-11 stsp Files where patch failed to apply: 2
206 60aa1fa0 2022-03-17 op EOF
207 60aa1fa0 2022-03-17 op
208 60aa1fa0 2022-03-17 op cmp -s $testroot/stdout.expected $testroot/stdout
209 5b67f96e 2022-03-13 op ret=$?
210 5b67f96e 2022-03-13 op if [ $ret -ne 0 ]; then
211 60aa1fa0 2022-03-17 op diff -u $testroot/stdout.expected $testroot/stdout
212 5b67f96e 2022-03-13 op fi
213 e9ce266e 2022-03-07 op test_done $testroot $ret
214 e9ce266e 2022-03-07 op }
215 e9ce266e 2022-03-07 op
216 e9ce266e 2022-03-07 op test_patch_malformed() {
217 e9ce266e 2022-03-07 op local testroot=`test_init patch_malformed`
218 e9ce266e 2022-03-07 op
219 e9ce266e 2022-03-07 op got checkout $testroot/repo $testroot/wt > /dev/null
220 e9ce266e 2022-03-07 op ret=$?
221 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
222 e9ce266e 2022-03-07 op test_done $testroot $ret
223 e9ce266e 2022-03-07 op return 1
224 e9ce266e 2022-03-07 op fi
225 e9ce266e 2022-03-07 op
226 e9ce266e 2022-03-07 op # missing "@@"
227 e9ce266e 2022-03-07 op cat <<EOF > $testroot/wt/patch
228 e9ce266e 2022-03-07 op --- alpha
229 e9ce266e 2022-03-07 op +++ alpha
230 e9ce266e 2022-03-07 op @@ -1 +1,2
231 e9ce266e 2022-03-07 op +hatsuseno
232 e9ce266e 2022-03-07 op alpha
233 e9ce266e 2022-03-07 op EOF
234 e9ce266e 2022-03-07 op
235 e9ce266e 2022-03-07 op echo -n > $testroot/stdout.expected
236 e9ce266e 2022-03-07 op echo "got: malformed patch" > $testroot/stderr.expected
237 e9ce266e 2022-03-07 op
238 e9ce266e 2022-03-07 op (cd $testroot/wt && got patch patch) \
239 e9ce266e 2022-03-07 op > $testroot/stdout \
240 e9ce266e 2022-03-07 op 2> $testroot/stderr
241 e9ce266e 2022-03-07 op ret=$?
242 bfbccd0a 2022-03-08 op if [ $ret -eq 0 ]; then
243 e9ce266e 2022-03-07 op echo "got managed to apply an invalid patch"
244 e9ce266e 2022-03-07 op test_done $testroot 1
245 e9ce266e 2022-03-07 op return 1
246 e9ce266e 2022-03-07 op fi
247 e9ce266e 2022-03-07 op
248 e9ce266e 2022-03-07 op cmp -s $testroot/stdout.expected $testroot/stdout
249 e9ce266e 2022-03-07 op ret=$?
250 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
251 e9ce266e 2022-03-07 op diff -u $testroot/stdout.expected $testroot/stdout
252 e9ce266e 2022-03-07 op test_done $testroot $ret
253 e9ce266e 2022-03-07 op return 1
254 e9ce266e 2022-03-07 op fi
255 e9ce266e 2022-03-07 op
256 e9ce266e 2022-03-07 op cmp -s $testroot/stderr.expected $testroot/stderr
257 e9ce266e 2022-03-07 op ret=$?
258 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
259 e9ce266e 2022-03-07 op diff -u $testroot/stderr.expected $testroot/stderr
260 e9ce266e 2022-03-07 op test_done $testroot $ret
261 e9ce266e 2022-03-07 op return 1
262 e9ce266e 2022-03-07 op fi
263 e9ce266e 2022-03-07 op
264 e9ce266e 2022-03-07 op # wrong first character
265 e9ce266e 2022-03-07 op cat <<EOF > $testroot/wt/patch
266 e9ce266e 2022-03-07 op --- alpha
267 e9ce266e 2022-03-07 op +++ alpha
268 e9ce266e 2022-03-07 op @@ -1 +1,2 @@
269 e9ce266e 2022-03-07 op +hatsuseno
270 e9ce266e 2022-03-07 op alpha
271 be33dff7 2022-05-13 op EOF
272 be33dff7 2022-05-13 op
273 be33dff7 2022-05-13 op (cd $testroot/wt && got patch patch) \
274 be33dff7 2022-05-13 op > $testroot/stdout \
275 be33dff7 2022-05-13 op 2> $testroot/stderr
276 be33dff7 2022-05-13 op ret=$?
277 be33dff7 2022-05-13 op if [ $ret -eq 0 ]; then
278 be33dff7 2022-05-13 op echo "got managed to apply an invalid patch"
279 be33dff7 2022-05-13 op test_done $testroot 1
280 be33dff7 2022-05-13 op return 1
281 be33dff7 2022-05-13 op fi
282 be33dff7 2022-05-13 op
283 be33dff7 2022-05-13 op cmp -s $testroot/stdout.expected $testroot/stdout
284 be33dff7 2022-05-13 op ret=$?
285 be33dff7 2022-05-13 op if [ $ret -ne 0 ]; then
286 be33dff7 2022-05-13 op diff -u $testroot/stdout.expected $testroot/stdout
287 be33dff7 2022-05-13 op test_done $testroot $ret
288 be33dff7 2022-05-13 op return 1
289 be33dff7 2022-05-13 op fi
290 be33dff7 2022-05-13 op
291 be33dff7 2022-05-13 op cmp -s $testroot/stderr.expected $testroot/stderr
292 be33dff7 2022-05-13 op ret=$?
293 be33dff7 2022-05-13 op if [ $ret -ne 0 ]; then
294 be33dff7 2022-05-13 op diff -u $testroot/stderr.expected $testroot/stderr
295 be33dff7 2022-05-13 op test_done $testroot $ret
296 be33dff7 2022-05-13 op return 1
297 be33dff7 2022-05-13 op fi
298 be33dff7 2022-05-13 op
299 be33dff7 2022-05-13 op # empty hunk
300 be33dff7 2022-05-13 op cat <<EOF > $testroot/wt/patch
301 be33dff7 2022-05-13 op diff --git a/alpha b/iota
302 be33dff7 2022-05-13 op --- a/alpha
303 be33dff7 2022-05-13 op +++ b/iota
304 be33dff7 2022-05-13 op @@ -0,0 +0,0 @@
305 e9ce266e 2022-03-07 op EOF
306 e9ce266e 2022-03-07 op
307 e9ce266e 2022-03-07 op (cd $testroot/wt && got patch patch) \
308 e9ce266e 2022-03-07 op > $testroot/stdout \
309 e9ce266e 2022-03-07 op 2> $testroot/stderr
310 e9ce266e 2022-03-07 op ret=$?
311 bfbccd0a 2022-03-08 op if [ $ret -eq 0 ]; then
312 e9ce266e 2022-03-07 op echo "got managed to apply an invalid patch"
313 e9ce266e 2022-03-07 op test_done $testroot 1
314 e9ce266e 2022-03-07 op return 1
315 e9ce266e 2022-03-07 op fi
316 e9ce266e 2022-03-07 op
317 e9ce266e 2022-03-07 op cmp -s $testroot/stdout.expected $testroot/stdout
318 e9ce266e 2022-03-07 op ret=$?
319 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
320 e9ce266e 2022-03-07 op diff -u $testroot/stdout.expected $testroot/stdout
321 e9ce266e 2022-03-07 op test_done $testroot $ret
322 e9ce266e 2022-03-07 op return 1
323 e9ce266e 2022-03-07 op fi
324 e9ce266e 2022-03-07 op
325 e9ce266e 2022-03-07 op cmp -s $testroot/stderr.expected $testroot/stderr
326 e9ce266e 2022-03-07 op ret=$?
327 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
328 e9ce266e 2022-03-07 op diff -u $testroot/stderr.expected $testroot/stderr
329 e9ce266e 2022-03-07 op test_done $testroot $ret
330 e9ce266e 2022-03-07 op return 1
331 e9ce266e 2022-03-07 op fi
332 e9ce266e 2022-03-07 op
333 e9ce266e 2022-03-07 op test_done $testroot $ret
334 e9ce266e 2022-03-07 op }
335 e9ce266e 2022-03-07 op
336 e9ce266e 2022-03-07 op test_patch_no_patch() {
337 e9ce266e 2022-03-07 op local testroot=`test_init patch_no_patch`
338 e9ce266e 2022-03-07 op
339 e9ce266e 2022-03-07 op got checkout $testroot/repo $testroot/wt > /dev/null
340 e9ce266e 2022-03-07 op ret=$?
341 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
342 e9ce266e 2022-03-07 op test_done $testroot $ret
343 e9ce266e 2022-03-07 op return 1
344 e9ce266e 2022-03-07 op fi
345 e9ce266e 2022-03-07 op
346 e9ce266e 2022-03-07 op cat <<EOF > $testroot/wt/patch
347 e9ce266e 2022-03-07 op hello world!
348 e9ce266e 2022-03-07 op ...
349 e9ce266e 2022-03-07 op
350 e9ce266e 2022-03-07 op some other nonsense
351 e9ce266e 2022-03-07 op ...
352 e9ce266e 2022-03-07 op
353 e9ce266e 2022-03-07 op there's no patch in here!
354 e9ce266e 2022-03-07 op EOF
355 e9ce266e 2022-03-07 op
356 e9ce266e 2022-03-07 op echo -n > $testroot/stdout.expected
357 e9ce266e 2022-03-07 op echo "got: no patch found" > $testroot/stderr.expected
358 e9ce266e 2022-03-07 op
359 e9ce266e 2022-03-07 op (cd $testroot/wt && got patch patch) \
360 e9ce266e 2022-03-07 op > $testroot/stdout \
361 e9ce266e 2022-03-07 op 2> $testroot/stderr
362 e9ce266e 2022-03-07 op ret=$?
363 bfbccd0a 2022-03-08 op if [ $ret -eq 0 ]; then # should fail
364 e9ce266e 2022-03-07 op test_done $testroot 1
365 e9ce266e 2022-03-07 op return 1
366 e9ce266e 2022-03-07 op fi
367 3313bcd8 2022-04-19 op
368 e9ce266e 2022-03-07 op cmp -s $testroot/stdout.expected $testroot/stdout
369 e9ce266e 2022-03-07 op ret=$?
370 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
371 e9ce266e 2022-03-07 op diff -u $testroot/stdout.expected $testroot/stdout
372 e9ce266e 2022-03-07 op test_done $testroot $ret
373 e9ce266e 2022-03-07 op return 1
374 e9ce266e 2022-03-07 op fi
375 e9ce266e 2022-03-07 op
376 e9ce266e 2022-03-07 op cmp -s $testroot/stderr.expected $testroot/stderr
377 e9ce266e 2022-03-07 op ret=$?
378 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
379 e9ce266e 2022-03-07 op diff -u $testroot/stderr.expected $testroot/stderr
380 e9ce266e 2022-03-07 op test_done $testroot $ret
381 e9ce266e 2022-03-07 op return 1
382 e9ce266e 2022-03-07 op fi
383 e9ce266e 2022-03-07 op
384 e9ce266e 2022-03-07 op test_done $testroot $ret
385 e9ce266e 2022-03-07 op }
386 e9ce266e 2022-03-07 op
387 e9ce266e 2022-03-07 op test_patch_equals_for_context() {
388 f1d6cebb 2022-04-23 op local testroot=`test_init patch_equals_for_context`
389 e9ce266e 2022-03-07 op
390 e9ce266e 2022-03-07 op got checkout $testroot/repo $testroot/wt > /dev/null
391 e9ce266e 2022-03-07 op ret=$?
392 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
393 e9ce266e 2022-03-07 op test_done $testroot $ret
394 e9ce266e 2022-03-07 op return 1
395 e9ce266e 2022-03-07 op fi
396 e9ce266e 2022-03-07 op
397 e9ce266e 2022-03-07 op cat <<EOF > $testroot/wt/patch
398 e9ce266e 2022-03-07 op --- alpha
399 e9ce266e 2022-03-07 op +++ alpha
400 e9ce266e 2022-03-07 op @@ -1 +1,2 @@
401 e9ce266e 2022-03-07 op +hatsuseno
402 e9ce266e 2022-03-07 op =alpha
403 e9ce266e 2022-03-07 op EOF
404 e9ce266e 2022-03-07 op
405 e9ce266e 2022-03-07 op echo "M alpha" > $testroot/stdout.expected
406 e9ce266e 2022-03-07 op
407 e9ce266e 2022-03-07 op (cd $testroot/wt && got patch patch) > $testroot/stdout
408 e9ce266e 2022-03-07 op ret=$?
409 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
410 e9ce266e 2022-03-07 op test_done $testroot $ret
411 e9ce266e 2022-03-07 op return 1
412 e9ce266e 2022-03-07 op fi
413 e9ce266e 2022-03-07 op
414 e9ce266e 2022-03-07 op cmp -s $testroot/stdout.expected $testroot/stdout
415 e9ce266e 2022-03-07 op ret=$?
416 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
417 e9ce266e 2022-03-07 op diff -u $testroot/stdout.expected $testroot/stdout
418 e9ce266e 2022-03-07 op test_done $testroot $ret
419 e9ce266e 2022-03-07 op return 1
420 e9ce266e 2022-03-07 op fi
421 e9ce266e 2022-03-07 op
422 e9ce266e 2022-03-07 op echo hatsuseno > $testroot/wt/alpha.expected
423 e9ce266e 2022-03-07 op echo alpha >> $testroot/wt/alpha.expected
424 e9ce266e 2022-03-07 op cmp -s $testroot/wt/alpha.expected $testroot/wt/alpha
425 e9ce266e 2022-03-07 op ret=$?
426 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
427 e9ce266e 2022-03-07 op diff -u $testroot/wt/alpha.expected $testroot/wt/alpha
428 e9ce266e 2022-03-07 op fi
429 e9ce266e 2022-03-07 op test_done $testroot $ret
430 e9ce266e 2022-03-07 op }
431 6e96b326 2022-03-12 op
432 6e96b326 2022-03-12 op test_patch_rename() {
433 6e96b326 2022-03-12 op local testroot=`test_init patch_rename`
434 6e96b326 2022-03-12 op
435 6e96b326 2022-03-12 op got checkout $testroot/repo $testroot/wt > /dev/null
436 6e96b326 2022-03-12 op ret=$?
437 6e96b326 2022-03-12 op if [ $ret -ne 0 ]; then
438 6e96b326 2022-03-12 op test_done $testroot $ret
439 6e96b326 2022-03-12 op return 1
440 6e96b326 2022-03-12 op fi
441 6e96b326 2022-03-12 op
442 6e96b326 2022-03-12 op cat <<EOF > $testroot/wt/patch
443 4379a9aa 2022-05-02 op diff --git a/beta b/iota
444 4379a9aa 2022-05-02 op similarity index 100%
445 4379a9aa 2022-05-02 op rename from beta
446 4379a9aa 2022-05-02 op rename to iota
447 7a30b5cb 2022-03-20 op diff --git a/alpha b/eta
448 7a30b5cb 2022-03-20 op --- a/alpha
449 7a30b5cb 2022-03-20 op +++ b/eta
450 4379a9aa 2022-05-02 op @@ -1 +1 @@
451 4379a9aa 2022-05-02 op -alpha
452 4379a9aa 2022-05-02 op +eta
453 6e96b326 2022-03-12 op EOF
454 e9ce266e 2022-03-07 op
455 4379a9aa 2022-05-02 op echo 'D beta' > $testroot/stdout.expected
456 4379a9aa 2022-05-02 op echo 'A iota' >> $testroot/stdout.expected
457 4379a9aa 2022-05-02 op echo 'D alpha' >> $testroot/stdout.expected
458 4379a9aa 2022-05-02 op echo 'A eta' >> $testroot/stdout.expected
459 6e96b326 2022-03-12 op
460 6e96b326 2022-03-12 op (cd $testroot/wt && got patch patch) > $testroot/stdout
461 6e96b326 2022-03-12 op ret=$?
462 6e96b326 2022-03-12 op if [ $ret -ne 0 ]; then
463 6e96b326 2022-03-12 op test_done $testroot $ret
464 6e96b326 2022-03-12 op return 1
465 6e96b326 2022-03-12 op fi
466 6e96b326 2022-03-12 op
467 6e96b326 2022-03-12 op cmp -s $testroot/stdout.expected $testroot/stdout
468 6e96b326 2022-03-12 op ret=$?
469 6e96b326 2022-03-12 op if [ $ret -ne 0 ]; then
470 6e96b326 2022-03-12 op diff -u $testroot/stdout.expected $testroot/stdout
471 6e96b326 2022-03-12 op test_done $testroot $ret
472 6e96b326 2022-03-12 op return 1
473 6e96b326 2022-03-12 op fi
474 6e96b326 2022-03-12 op
475 4379a9aa 2022-05-02 op if [ -f $testroot/wt/alpha -o -f $testroot/wt/beta ]; then
476 4379a9aa 2022-05-02 op echo "alpha or beta were not removed" >&2
477 6e96b326 2022-03-12 op test_done $testroot 1
478 6e96b326 2022-03-12 op return 1
479 6e96b326 2022-03-12 op fi
480 4379a9aa 2022-05-02 op if [ ! -f $testroot/wt/iota -o ! -f $testroot/wt/eta ]; then
481 4379a9aa 2022-05-02 op echo "iota or eta were not created" >&2
482 6e96b326 2022-03-12 op test_done $testroot 1
483 6e96b326 2022-03-12 op return 1
484 6e96b326 2022-03-12 op fi
485 6e96b326 2022-03-12 op
486 4379a9aa 2022-05-02 op echo beta > $testroot/wt/iota.expected
487 4379a9aa 2022-05-02 op cmp -s $testroot/wt/iota.expected $testroot/wt/iota
488 6e96b326 2022-03-12 op ret=$?
489 6e96b326 2022-03-12 op if [ $ret -ne 0 ]; then
490 4379a9aa 2022-05-02 op diff -u $testroot/wt/iota.expected $testroot/wt/iota
491 6e96b326 2022-03-12 op test_done $testroot $ret
492 6e96b326 2022-03-12 op return 1
493 6e96b326 2022-03-12 op fi
494 6e96b326 2022-03-12 op
495 4379a9aa 2022-05-02 op echo eta > $testroot/wt/eta.expected
496 4379a9aa 2022-05-02 op cmp -s $testroot/wt/eta.expected $testroot/wt/eta
497 6e96b326 2022-03-12 op ret=$?
498 6e96b326 2022-03-12 op if [ $ret -ne 0 ]; then
499 4379a9aa 2022-05-02 op diff -u $testroot/wt/eta.expected $testroot/wt/eta
500 6e96b326 2022-03-12 op test_done $testroot $ret
501 6e96b326 2022-03-12 op return 1
502 6e96b326 2022-03-12 op fi
503 6e96b326 2022-03-12 op
504 6e96b326 2022-03-12 op test_done $testroot $ret
505 6e96b326 2022-03-12 op }
506 dbda770b 2022-03-13 op
507 dbda770b 2022-03-13 op test_patch_illegal_status() {
508 dbda770b 2022-03-13 op local testroot=`test_init patch_illegal_status`
509 dbda770b 2022-03-13 op
510 dbda770b 2022-03-13 op got checkout $testroot/repo $testroot/wt > /dev/null
511 dbda770b 2022-03-13 op ret=$?
512 dbda770b 2022-03-13 op if [ $ret -ne 0 ]; then
513 dbda770b 2022-03-13 op test_done $testroot $ret
514 dbda770b 2022-03-13 op return 1
515 dbda770b 2022-03-13 op fi
516 dbda770b 2022-03-13 op
517 60aa1fa0 2022-03-17 op # try to patch an obstructed file, add a versioned one, edit a
518 60aa1fa0 2022-03-17 op # non existent file and an unversioned one, and remove a
519 60aa1fa0 2022-03-17 op # non existent file.
520 dbda770b 2022-03-13 op cat <<EOF > $testroot/wt/patch
521 60aa1fa0 2022-03-17 op --- alpha
522 60aa1fa0 2022-03-17 op +++ alpha
523 60aa1fa0 2022-03-17 op @@ -1 +1,2 @@
524 60aa1fa0 2022-03-17 op alpha
525 60aa1fa0 2022-03-17 op +was edited
526 60aa1fa0 2022-03-17 op --- /dev/null
527 60aa1fa0 2022-03-17 op +++ beta
528 60aa1fa0 2022-03-17 op @@ -0,0 +1 @@
529 60aa1fa0 2022-03-17 op +beta
530 dbda770b 2022-03-13 op --- iota
531 dbda770b 2022-03-13 op +++ iota
532 dbda770b 2022-03-13 op @@ -1 +1 @@
533 60aa1fa0 2022-03-17 op -iota
534 60aa1fa0 2022-03-17 op +IOTA
535 60aa1fa0 2022-03-17 op --- kappa
536 60aa1fa0 2022-03-17 op +++ kappa
537 60aa1fa0 2022-03-17 op @@ -1 +1 @@
538 60aa1fa0 2022-03-17 op -kappa
539 60aa1fa0 2022-03-17 op +KAPPA
540 60aa1fa0 2022-03-17 op --- lambda
541 60aa1fa0 2022-03-17 op +++ /dev/null
542 60aa1fa0 2022-03-17 op @@ -1 +0,0 @@
543 60aa1fa0 2022-03-17 op -lambda
544 dbda770b 2022-03-13 op EOF
545 6e96b326 2022-03-12 op
546 60aa1fa0 2022-03-17 op echo kappa > $testroot/wt/kappa
547 dbda770b 2022-03-13 op rm $testroot/wt/alpha
548 dbda770b 2022-03-13 op mkdir $testroot/wt/alpha
549 dbda770b 2022-03-13 op
550 60aa1fa0 2022-03-17 op (cd $testroot/wt && got patch patch) > $testroot/stdout \
551 dbda770b 2022-03-13 op 2> $testroot/stderr
552 dbda770b 2022-03-13 op ret=$?
553 dbda770b 2022-03-13 op if [ $ret -eq 0 ]; then
554 dbda770b 2022-03-13 op echo "edited a missing file" >&2
555 a19f439c 2022-06-03 op test_done $testroot 1
556 dbda770b 2022-03-13 op return 1
557 dbda770b 2022-03-13 op fi
558 dbda770b 2022-03-13 op
559 60aa1fa0 2022-03-17 op cat <<EOF > $testroot/stdout.expected
560 60aa1fa0 2022-03-17 op # alpha
561 60aa1fa0 2022-03-17 op # beta
562 60aa1fa0 2022-03-17 op # iota
563 60aa1fa0 2022-03-17 op # kappa
564 60aa1fa0 2022-03-17 op # lambda
565 bfcdc9e9 2023-05-11 stsp Files where patch failed to apply: 5
566 60aa1fa0 2022-03-17 op EOF
567 dbda770b 2022-03-13 op
568 60aa1fa0 2022-03-17 op cat <<EOF > $testroot/stderr.expected
569 60aa1fa0 2022-03-17 op got: alpha: file has unexpected status
570 60aa1fa0 2022-03-17 op got: beta: file has unexpected status
571 60aa1fa0 2022-03-17 op got: iota: No such file or directory
572 60aa1fa0 2022-03-17 op got: kappa: file has unexpected status
573 60aa1fa0 2022-03-17 op got: lambda: No such file or directory
574 60aa1fa0 2022-03-17 op got: patch failed to apply
575 dbda770b 2022-03-13 op EOF
576 dbda770b 2022-03-13 op
577 60aa1fa0 2022-03-17 op cmp -s $testroot/stdout.expected $testroot/stdout
578 dbda770b 2022-03-13 op ret=$?
579 60aa1fa0 2022-03-17 op if [ $ret -ne 0 ]; then
580 60aa1fa0 2022-03-17 op diff -u $testroot/stdout.expected $testroot/stdout
581 dbda770b 2022-03-13 op test_done $testroot $ret
582 dbda770b 2022-03-13 op return 1
583 dbda770b 2022-03-13 op fi
584 dbda770b 2022-03-13 op
585 dbda770b 2022-03-13 op cmp -s $testroot/stderr.expected $testroot/stderr
586 dbda770b 2022-03-13 op ret=$?
587 60aa1fa0 2022-03-17 op if [ $ret -ne 0 ]; then
588 dbda770b 2022-03-13 op diff -u $testroot/stderr.expected $testroot/stderr
589 78f5ac24 2022-03-19 op test_done $testroot $ret
590 78f5ac24 2022-03-19 op return 1
591 dbda770b 2022-03-13 op fi
592 78f5ac24 2022-03-19 op
593 78f5ac24 2022-03-19 op (cd $testroot/wt && got status) > $testroot/stdout
594 78f5ac24 2022-03-19 op cat <<EOF > $testroot/stdout.expected
595 78f5ac24 2022-03-19 op ~ alpha
596 78f5ac24 2022-03-19 op ? kappa
597 78f5ac24 2022-03-19 op ? patch
598 78f5ac24 2022-03-19 op EOF
599 78f5ac24 2022-03-19 op
600 78f5ac24 2022-03-19 op cmp -s $testroot/stdout.expected $testroot/stdout
601 78f5ac24 2022-03-19 op ret=$?
602 78f5ac24 2022-03-19 op if [ $ret -ne 0 ]; then
603 78f5ac24 2022-03-19 op diff -u $testroot/stdout.expected $testroot/stdout
604 78f5ac24 2022-03-19 op fi
605 899fcfdf 2022-03-13 op test_done $testroot $ret
606 899fcfdf 2022-03-13 op }
607 899fcfdf 2022-03-13 op
608 899fcfdf 2022-03-13 op test_patch_nop() {
609 899fcfdf 2022-03-13 op local testroot=`test_init patch_nop`
610 899fcfdf 2022-03-13 op
611 899fcfdf 2022-03-13 op got checkout $testroot/repo $testroot/wt > /dev/null
612 899fcfdf 2022-03-13 op ret=$?
613 899fcfdf 2022-03-13 op if [ $ret -ne 0 ]; then
614 899fcfdf 2022-03-13 op test_done $testroot $ret
615 899fcfdf 2022-03-13 op return 1
616 899fcfdf 2022-03-13 op fi
617 899fcfdf 2022-03-13 op
618 899fcfdf 2022-03-13 op cat <<EOF > $testroot/wt/patch
619 899fcfdf 2022-03-13 op --- alpha
620 899fcfdf 2022-03-13 op +++ alpha
621 899fcfdf 2022-03-13 op @@ -1 +1 @@
622 899fcfdf 2022-03-13 op -alpha
623 899fcfdf 2022-03-13 op +cafe alpha
624 899fcfdf 2022-03-13 op --- beta
625 899fcfdf 2022-03-13 op +++ /dev/null
626 899fcfdf 2022-03-13 op @@ -1 +0,0 @@
627 899fcfdf 2022-03-13 op -beta
628 7a30b5cb 2022-03-20 op diff --git a/gamma/delta b/gamma/delta.new
629 899fcfdf 2022-03-13 op --- gamma/delta
630 899fcfdf 2022-03-13 op +++ gamma/delta.new
631 899fcfdf 2022-03-13 op @@ -1 +1 @@
632 899fcfdf 2022-03-13 op -delta
633 899fcfdf 2022-03-13 op +delta updated and renamed!
634 899fcfdf 2022-03-13 op EOF
635 899fcfdf 2022-03-13 op
636 899fcfdf 2022-03-13 op (cd $testroot/wt && got patch -n patch)
637 899fcfdf 2022-03-13 op ret=$?
638 899fcfdf 2022-03-13 op if [ $ret -ne 0 ]; then
639 899fcfdf 2022-03-13 op test_done $testroot $ret
640 899fcfdf 2022-03-13 op return 1
641 dbda770b 2022-03-13 op fi
642 899fcfdf 2022-03-13 op
643 899fcfdf 2022-03-13 op # remove the patch to avoid the ? entry
644 899fcfdf 2022-03-13 op rm $testroot/wt/patch
645 899fcfdf 2022-03-13 op
646 899fcfdf 2022-03-13 op (cd $testroot/wt && got status) > $testroot/stdout
647 899fcfdf 2022-03-13 op ret=$?
648 899fcfdf 2022-03-13 op if [ $ret -ne 0 ]; then
649 899fcfdf 2022-03-13 op test_done $testroot $ret
650 899fcfdf 2022-03-13 op return 1
651 899fcfdf 2022-03-13 op fi
652 899fcfdf 2022-03-13 op
653 899fcfdf 2022-03-13 op echo -n > $testroot/stdout.expected
654 899fcfdf 2022-03-13 op cmp -s $testroot/stdout.expected $testroot/stdout
655 899fcfdf 2022-03-13 op ret=$?
656 899fcfdf 2022-03-13 op if [ $ret -ne 0 ]; then
657 899fcfdf 2022-03-13 op diff -u $testroot/stdout.expected $testroot/stdout
658 899fcfdf 2022-03-13 op fi
659 dbda770b 2022-03-13 op test_done $testroot $ret
660 2be5e1a2 2022-03-16 op }
661 2be5e1a2 2022-03-16 op
662 2be5e1a2 2022-03-16 op test_patch_preserve_perm() {
663 2be5e1a2 2022-03-16 op local testroot=`test_init patch_preserve_perm`
664 2be5e1a2 2022-03-16 op
665 2be5e1a2 2022-03-16 op got checkout $testroot/repo $testroot/wt > /dev/null
666 2be5e1a2 2022-03-16 op ret=$?
667 2be5e1a2 2022-03-16 op if [ $ret -ne 0 ]; then
668 2be5e1a2 2022-03-16 op test_done $testroot $ret
669 2be5e1a2 2022-03-16 op return 1
670 2be5e1a2 2022-03-16 op fi
671 2be5e1a2 2022-03-16 op
672 2be5e1a2 2022-03-16 op chmod +x $testroot/wt/alpha
673 2be5e1a2 2022-03-16 op (cd $testroot/wt && got commit -m 'alpha executable') > /dev/null
674 2be5e1a2 2022-03-16 op ret=$?
675 2be5e1a2 2022-03-16 op if [ $ret -ne 0 ]; then
676 2be5e1a2 2022-03-16 op test_done $testroot $ret
677 2be5e1a2 2022-03-16 op return 1
678 2be5e1a2 2022-03-16 op fi
679 2be5e1a2 2022-03-16 op
680 2be5e1a2 2022-03-16 op cat <<EOF > $testroot/wt/patch
681 2be5e1a2 2022-03-16 op --- alpha
682 2be5e1a2 2022-03-16 op +++ alpha
683 2be5e1a2 2022-03-16 op @@ -1 +1,2 @@
684 2be5e1a2 2022-03-16 op alpha
685 2be5e1a2 2022-03-16 op +was edited
686 2be5e1a2 2022-03-16 op EOF
687 2be5e1a2 2022-03-16 op
688 2be5e1a2 2022-03-16 op (cd $testroot/wt && got patch patch) > /dev/null
689 2be5e1a2 2022-03-16 op ret=$?
690 2be5e1a2 2022-03-16 op if [ $ret -ne 0 ]; then
691 2be5e1a2 2022-03-16 op test_done $testroot $ret
692 2be5e1a2 2022-03-16 op return 1
693 2be5e1a2 2022-03-16 op fi
694 2be5e1a2 2022-03-16 op
695 2be5e1a2 2022-03-16 op if [ ! -x $testroot/wt/alpha ]; then
696 2be5e1a2 2022-03-16 op echo "alpha is no more executable!" >&2
697 2be5e1a2 2022-03-16 op test_done $testroot 1
698 95d68340 2022-03-16 op return 1
699 95d68340 2022-03-16 op fi
700 95d68340 2022-03-16 op test_done $testroot 0
701 95d68340 2022-03-16 op }
702 95d68340 2022-03-16 op
703 95d68340 2022-03-16 op test_patch_create_dirs() {
704 95d68340 2022-03-16 op local testroot=`test_init patch_create_dirs`
705 95d68340 2022-03-16 op
706 95d68340 2022-03-16 op got checkout $testroot/repo $testroot/wt > /dev/null
707 95d68340 2022-03-16 op ret=$?
708 95d68340 2022-03-16 op if [ $ret -ne 0 ]; then
709 95d68340 2022-03-16 op test_done $testroot $ret
710 95d68340 2022-03-16 op return 1
711 95d68340 2022-03-16 op fi
712 95d68340 2022-03-16 op
713 95d68340 2022-03-16 op cat <<EOF > $testroot/wt/patch
714 95d68340 2022-03-16 op --- /dev/null
715 95d68340 2022-03-16 op +++ iota/kappa/lambda
716 95d68340 2022-03-16 op @@ -0,0 +1 @@
717 95d68340 2022-03-16 op +lambda
718 95d68340 2022-03-16 op EOF
719 95d68340 2022-03-16 op
720 95d68340 2022-03-16 op (cd $testroot/wt && got patch patch) > $testroot/stdout
721 95d68340 2022-03-16 op ret=$?
722 95d68340 2022-03-16 op if [ $ret -ne 0 ]; then
723 95d68340 2022-03-16 op test_done $testroot $ret
724 2be5e1a2 2022-03-16 op return 1
725 2be5e1a2 2022-03-16 op fi
726 95d68340 2022-03-16 op
727 95d68340 2022-03-16 op echo 'A iota/kappa/lambda' >> $testroot/stdout.expected
728 95d68340 2022-03-16 op cmp -s $testroot/stdout.expected $testroot/stdout
729 95d68340 2022-03-16 op ret=$?
730 95d68340 2022-03-16 op if [ $ret -ne 0 ]; then
731 95d68340 2022-03-16 op diff -u $testroot/stdout.expected $testroot/stdout
732 95d68340 2022-03-16 op test_done $testroot $ret
733 95d68340 2022-03-16 op return 1
734 95d68340 2022-03-16 op fi
735 95d68340 2022-03-16 op
736 95d68340 2022-03-16 op if [ ! -f $testroot/wt/iota/kappa/lambda ]; then
737 95d68340 2022-03-16 op echo "file not created!" >&2
738 95d68340 2022-03-16 op test_done $testroot $ret
739 95d68340 2022-03-16 op return 1
740 95d68340 2022-03-16 op fi
741 2be5e1a2 2022-03-16 op test_done $testroot 0
742 dbda770b 2022-03-13 op }
743 dbda770b 2022-03-13 op
744 60aa1fa0 2022-03-17 op test_patch_with_offset() {
745 60aa1fa0 2022-03-17 op local testroot=`test_init patch_with_offset`
746 60aa1fa0 2022-03-17 op
747 60aa1fa0 2022-03-17 op got checkout $testroot/repo $testroot/wt > /dev/null
748 60aa1fa0 2022-03-17 op ret=$?
749 60aa1fa0 2022-03-17 op if [ $ret -ne 0 ]; then
750 60aa1fa0 2022-03-17 op test_done $testroot $ret
751 60aa1fa0 2022-03-17 op return 1
752 60aa1fa0 2022-03-17 op fi
753 60aa1fa0 2022-03-17 op
754 60aa1fa0 2022-03-17 op cat <<EOF > $testroot/wt/patch
755 60aa1fa0 2022-03-17 op --- numbers
756 60aa1fa0 2022-03-17 op +++ numbers
757 60aa1fa0 2022-03-17 op @@ -47,7 +47,7 @@
758 60aa1fa0 2022-03-17 op 47
759 60aa1fa0 2022-03-17 op 48
760 60aa1fa0 2022-03-17 op 49
761 60aa1fa0 2022-03-17 op -50
762 60aa1fa0 2022-03-17 op +midway tru it!
763 60aa1fa0 2022-03-17 op 51
764 60aa1fa0 2022-03-17 op 52
765 60aa1fa0 2022-03-17 op 53
766 60aa1fa0 2022-03-17 op @@ -87,7 +87,7 @@
767 60aa1fa0 2022-03-17 op 87
768 60aa1fa0 2022-03-17 op 88
769 60aa1fa0 2022-03-17 op 89
770 60aa1fa0 2022-03-17 op -90
771 60aa1fa0 2022-03-17 op +almost there!
772 60aa1fa0 2022-03-17 op 91
773 60aa1fa0 2022-03-17 op 92
774 60aa1fa0 2022-03-17 op 93
775 60aa1fa0 2022-03-17 op EOF
776 60aa1fa0 2022-03-17 op
777 60aa1fa0 2022-03-17 op jot 100 > $testroot/wt/numbers
778 5f94a4e0 2022-11-18 op ed -s "$testroot/wt/numbers" <<EOF
779 60aa1fa0 2022-03-17 op 1,10d
780 60aa1fa0 2022-03-17 op 50r !jot 20
781 60aa1fa0 2022-03-17 op w
782 60aa1fa0 2022-03-17 op q
783 60aa1fa0 2022-03-17 op EOF
784 60aa1fa0 2022-03-17 op
785 60aa1fa0 2022-03-17 op (cd $testroot/wt && got add numbers && got commit -m '+numbers') \
786 60aa1fa0 2022-03-17 op > /dev/null
787 60aa1fa0 2022-03-17 op ret=$?
788 60aa1fa0 2022-03-17 op if [ $ret -ne 0 ]; then
789 60aa1fa0 2022-03-17 op test_done $testroot $ret
790 60aa1fa0 2022-03-17 op return 1
791 60aa1fa0 2022-03-17 op fi
792 60aa1fa0 2022-03-17 op
793 60aa1fa0 2022-03-17 op (cd $testroot/wt && got patch patch) > $testroot/stdout
794 60aa1fa0 2022-03-17 op ret=$?
795 60aa1fa0 2022-03-17 op if [ $ret -ne 0 ]; then
796 60aa1fa0 2022-03-17 op test_done $testroot/wt $ret
797 60aa1fa0 2022-03-17 op return 1
798 60aa1fa0 2022-03-17 op fi
799 60aa1fa0 2022-03-17 op
800 60aa1fa0 2022-03-17 op cat <<EOF > $testroot/stdout.expected
801 60aa1fa0 2022-03-17 op M numbers
802 60aa1fa0 2022-03-17 op @@ -47,7 +47,7 @@ applied with offset -10
803 60aa1fa0 2022-03-17 op @@ -87,7 +87,7 @@ applied with offset 10
804 7a30b5cb 2022-03-20 op EOF
805 7a30b5cb 2022-03-20 op
806 7a30b5cb 2022-03-20 op cmp -s $testroot/stdout.expected $testroot/stdout
807 7a30b5cb 2022-03-20 op ret=$?
808 7a30b5cb 2022-03-20 op if [ $ret -ne 0 ]; then
809 7a30b5cb 2022-03-20 op diff -u $testroot/stdout.expected $testroot/stdout
810 7a30b5cb 2022-03-20 op fi
811 7a30b5cb 2022-03-20 op test_done $testroot $ret
812 7a30b5cb 2022-03-20 op }
813 7a30b5cb 2022-03-20 op
814 7a30b5cb 2022-03-20 op test_patch_prefer_new_path() {
815 7a30b5cb 2022-03-20 op local testroot=`test_init patch_orig`
816 7a30b5cb 2022-03-20 op
817 7a30b5cb 2022-03-20 op got checkout $testroot/repo $testroot/wt > /dev/null
818 7a30b5cb 2022-03-20 op ret=$?
819 7a30b5cb 2022-03-20 op if [ $ret -ne 0 ]; then
820 7a30b5cb 2022-03-20 op test_done $testroot $ret
821 7a30b5cb 2022-03-20 op return 1
822 7a30b5cb 2022-03-20 op fi
823 7a30b5cb 2022-03-20 op
824 7a30b5cb 2022-03-20 op cat <<EOF > $testroot/wt/patch
825 7a30b5cb 2022-03-20 op --- alpha.orig
826 7a30b5cb 2022-03-20 op +++ alpha
827 7a30b5cb 2022-03-20 op @@ -1 +1,2 @@
828 7a30b5cb 2022-03-20 op alpha
829 7a30b5cb 2022-03-20 op +was edited
830 60aa1fa0 2022-03-17 op EOF
831 60aa1fa0 2022-03-17 op
832 7a30b5cb 2022-03-20 op (cd $testroot/wt && got patch patch) > $testroot/stdout
833 7a30b5cb 2022-03-20 op ret=$?
834 7a30b5cb 2022-03-20 op if [ $ret -ne 0 ]; then
835 7a30b5cb 2022-03-20 op test_done $testroot $ret
836 7a30b5cb 2022-03-20 op return 1
837 7a30b5cb 2022-03-20 op fi
838 7a30b5cb 2022-03-20 op
839 3313bcd8 2022-04-19 op echo 'M alpha' > $testroot/stdout.expected
840 60aa1fa0 2022-03-17 op cmp -s $testroot/stdout.expected $testroot/stdout
841 60aa1fa0 2022-03-17 op ret=$?
842 60aa1fa0 2022-03-17 op if [ $ret -ne 0 ]; then
843 60aa1fa0 2022-03-17 op diff -u $testroot/stdout.expected $testroot/stdout
844 60aa1fa0 2022-03-17 op fi
845 60aa1fa0 2022-03-17 op test_done $testroot $ret
846 60aa1fa0 2022-03-17 op }
847 60aa1fa0 2022-03-17 op
848 b3c57ab2 2022-03-22 op test_patch_no_newline() {
849 b3c57ab2 2022-03-22 op local testroot=`test_init patch_no_newline`
850 b3c57ab2 2022-03-22 op
851 b3c57ab2 2022-03-22 op got checkout $testroot/repo $testroot/wt > /dev/null
852 b3c57ab2 2022-03-22 op ret=$?
853 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
854 b3c57ab2 2022-03-22 op test_done $testroot $ret
855 b3c57ab2 2022-03-22 op return 1
856 b3c57ab2 2022-03-22 op fi
857 b3c57ab2 2022-03-22 op
858 b3c57ab2 2022-03-22 op cat <<EOF > $testroot/wt/patch
859 b3c57ab2 2022-03-22 op --- /dev/null
860 b3c57ab2 2022-03-22 op +++ eta
861 b3c57ab2 2022-03-22 op @@ -0,0 +1 @@
862 b3c57ab2 2022-03-22 op +eta
863 b3c57ab2 2022-03-22 op \ No newline at end of file
864 b3c57ab2 2022-03-22 op EOF
865 b3c57ab2 2022-03-22 op
866 b3c57ab2 2022-03-22 op (cd $testroot/wt && got patch patch) > $testroot/stdout
867 b3c57ab2 2022-03-22 op ret=$?
868 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
869 b3c57ab2 2022-03-22 op test_done $testroot $ret
870 b3c57ab2 2022-03-22 op return 1
871 b3c57ab2 2022-03-22 op fi
872 b3c57ab2 2022-03-22 op
873 b3c57ab2 2022-03-22 op echo "A eta" > $testroot/stdout.expected
874 b3c57ab2 2022-03-22 op cmp -s $testroot/stdout.expected $testroot/stdout
875 b3c57ab2 2022-03-22 op ret=$?
876 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
877 b3c57ab2 2022-03-22 op diff -u $testroot/stdout.expected $testroot/stdout
878 b3c57ab2 2022-03-22 op test_done $testroot $ret
879 b3c57ab2 2022-03-22 op return 1
880 b3c57ab2 2022-03-22 op fi
881 b3c57ab2 2022-03-22 op
882 b3c57ab2 2022-03-22 op echo -n eta > $testroot/wt/eta.expected
883 b3c57ab2 2022-03-22 op cmp -s $testroot/wt/eta.expected $testroot/wt/eta
884 b3c57ab2 2022-03-22 op ret=$?
885 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
886 b3c57ab2 2022-03-22 op diff -u $testroot/wt/eta.expected $testroot/wt/eta
887 b3c57ab2 2022-03-22 op test_done $testroot $ret
888 b3c57ab2 2022-03-22 op return 1
889 b3c57ab2 2022-03-22 op fi
890 b3c57ab2 2022-03-22 op
891 b3c57ab2 2022-03-22 op (cd $testroot/wt && got commit -m 'add eta') > /dev/null
892 b3c57ab2 2022-03-22 op ret=$?
893 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
894 b3c57ab2 2022-03-22 op test_done $testroot $ret
895 b3c57ab2 2022-03-22 op return 1
896 b3c57ab2 2022-03-22 op fi
897 b3c57ab2 2022-03-22 op
898 b3c57ab2 2022-03-22 op cat <<EOF > $testroot/wt/patch
899 b3c57ab2 2022-03-22 op --- eta
900 b3c57ab2 2022-03-22 op +++ eta
901 b3c57ab2 2022-03-22 op @@ -1 +1 @@
902 b3c57ab2 2022-03-22 op -eta
903 b3c57ab2 2022-03-22 op \ No newline at end of file
904 b3c57ab2 2022-03-22 op +ETA
905 b3c57ab2 2022-03-22 op \ No newline at end of file
906 b3c57ab2 2022-03-22 op EOF
907 b3c57ab2 2022-03-22 op
908 b3c57ab2 2022-03-22 op (cd $testroot/wt && got patch patch) > $testroot/stdout
909 b3c57ab2 2022-03-22 op ret=$?
910 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
911 b3c57ab2 2022-03-22 op test_done $testroot $ret
912 b3c57ab2 2022-03-22 op return 1
913 b3c57ab2 2022-03-22 op fi
914 b3c57ab2 2022-03-22 op
915 b3c57ab2 2022-03-22 op echo "M eta" > $testroot/stdout.expected
916 b3c57ab2 2022-03-22 op cmp -s $testroot/stdout.expected $testroot/stdout
917 b3c57ab2 2022-03-22 op ret=$?
918 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
919 b3c57ab2 2022-03-22 op diff -u $testroot/stdout.expected $testroot/stdout
920 b3c57ab2 2022-03-22 op test_done $testroot $ret
921 b3c57ab2 2022-03-22 op return 1
922 b3c57ab2 2022-03-22 op fi
923 b3c57ab2 2022-03-22 op
924 b3c57ab2 2022-03-22 op echo -n ETA > $testroot/wt/eta.expected
925 b3c57ab2 2022-03-22 op cmp -s $testroot/wt/eta.expected $testroot/wt/eta
926 b3c57ab2 2022-03-22 op ret=$?
927 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
928 b3c57ab2 2022-03-22 op diff -u $testroot/wt/eta.expected $testroot/wt/eta
929 b3c57ab2 2022-03-22 op test_done $testroot $ret
930 b3c57ab2 2022-03-22 op return 1
931 b3c57ab2 2022-03-22 op fi
932 b3c57ab2 2022-03-22 op
933 b3c57ab2 2022-03-22 op (cd $testroot/wt && got commit -m 'edit eta') > /dev/null
934 b3c57ab2 2022-03-22 op ret=$?
935 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
936 b3c57ab2 2022-03-22 op test_done $testroot $ret
937 b3c57ab2 2022-03-22 op return 1
938 b3c57ab2 2022-03-22 op fi
939 b3c57ab2 2022-03-22 op
940 b3c57ab2 2022-03-22 op cat <<EOF > $testroot/wt/patch
941 b3c57ab2 2022-03-22 op --- eta
942 b3c57ab2 2022-03-22 op +++ eta
943 b3c57ab2 2022-03-22 op @@ -1 +1 @@
944 b3c57ab2 2022-03-22 op -ETA
945 b3c57ab2 2022-03-22 op \ No newline at end of file
946 b3c57ab2 2022-03-22 op +eta
947 b3c57ab2 2022-03-22 op EOF
948 b3c57ab2 2022-03-22 op
949 b3c57ab2 2022-03-22 op (cd $testroot/wt && got patch patch) > $testroot/stdout
950 b3c57ab2 2022-03-22 op ret=$?
951 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
952 b3c57ab2 2022-03-22 op test_done $testroot $ret
953 b3c57ab2 2022-03-22 op return 1
954 b3c57ab2 2022-03-22 op fi
955 b3c57ab2 2022-03-22 op
956 b3c57ab2 2022-03-22 op echo "M eta" > $testroot/stdout.expected
957 b3c57ab2 2022-03-22 op cmp -s $testroot/stdout.expected $testroot/stdout
958 b3c57ab2 2022-03-22 op ret=$?
959 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
960 b3c57ab2 2022-03-22 op diff -u $testroot/stdout.expected $testroot/stdout
961 b3c57ab2 2022-03-22 op test_done $testroot $ret
962 b3c57ab2 2022-03-22 op return 1
963 b3c57ab2 2022-03-22 op fi
964 b3c57ab2 2022-03-22 op
965 b3c57ab2 2022-03-22 op echo eta > $testroot/wt/eta.expected
966 b3c57ab2 2022-03-22 op cmp -s $testroot/wt/eta.expected $testroot/wt/eta
967 b3c57ab2 2022-03-22 op ret=$?
968 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
969 b3c57ab2 2022-03-22 op diff -u $testroot/wt/eta.expected $testroot/wt/eta
970 b3c57ab2 2022-03-22 op fi
971 b3c57ab2 2022-03-22 op test_done $testroot $ret
972 b3c57ab2 2022-03-22 op }
973 b3c57ab2 2022-03-22 op
974 9d6cabd5 2022-04-07 op test_patch_strip() {
975 9d6cabd5 2022-04-07 op local testroot=`test_init patch_strip`
976 9d6cabd5 2022-04-07 op
977 9d6cabd5 2022-04-07 op got checkout $testroot/repo $testroot/wt > /dev/null
978 9d6cabd5 2022-04-07 op ret=$?
979 9d6cabd5 2022-04-07 op if [ $ret -ne 0 ]; then
980 9d6cabd5 2022-04-07 op test_done $testroot $ret
981 9d6cabd5 2022-04-07 op return 1
982 9d6cabd5 2022-04-07 op fi
983 9d6cabd5 2022-04-07 op
984 9d6cabd5 2022-04-07 op cat <<EOF > $testroot/wt/patch
985 9d6cabd5 2022-04-07 op --- foo/bar/alpha.orig
986 9d6cabd5 2022-04-07 op +++ foo/bar/alpha
987 9d6cabd5 2022-04-07 op @@ -1 +1 @@
988 9d6cabd5 2022-04-07 op -alpha
989 9d6cabd5 2022-04-07 op +ALPHA
990 9d6cabd5 2022-04-07 op EOF
991 9d6cabd5 2022-04-07 op
992 9d6cabd5 2022-04-07 op (cd $testroot/wt && got patch -p2 patch) > $testroot/stdout
993 9d6cabd5 2022-04-07 op ret=$?
994 9d6cabd5 2022-04-07 op if [ $ret -ne 0 ]; then
995 9d6cabd5 2022-04-07 op test_done $testroot $ret
996 9d6cabd5 2022-04-07 op return 1
997 9d6cabd5 2022-04-07 op fi
998 9d6cabd5 2022-04-07 op
999 9d6cabd5 2022-04-07 op echo "M alpha" >> $testroot/stdout.expected
1000 9d6cabd5 2022-04-07 op cmp -s $testroot/stdout.expected $testroot/stdout
1001 9d6cabd5 2022-04-07 op ret=$?
1002 9d6cabd5 2022-04-07 op if [ $ret -ne 0 ]; then
1003 9d6cabd5 2022-04-07 op diff -u $testroot/stdout.expected $testroot/stdout
1004 9d6cabd5 2022-04-07 op test_done $testroot $ret
1005 9d6cabd5 2022-04-07 op return 1
1006 9d6cabd5 2022-04-07 op fi
1007 9d6cabd5 2022-04-07 op
1008 9d6cabd5 2022-04-07 op (cd $testroot/wt && got revert alpha) > /dev/null 2>&1
1009 9d6cabd5 2022-04-07 op ret=$?
1010 9d6cabd5 2022-04-07 op if [ $ret -ne 0 ]; then
1011 9d6cabd5 2022-04-07 op test_done $testroot $ret
1012 9d6cabd5 2022-04-07 op return 1
1013 9d6cabd5 2022-04-07 op fi
1014 9d6cabd5 2022-04-07 op
1015 9d6cabd5 2022-04-07 op (cd $testroot/wt && got patch -p3 patch) \
1016 9d6cabd5 2022-04-07 op 2> $testroot/stderr
1017 9d6cabd5 2022-04-07 op ret=$?
1018 9d6cabd5 2022-04-07 op if [ $ret -eq 0 ]; then
1019 9d6cabd5 2022-04-07 op echo "stripped more components than available!"
1020 9d6cabd5 2022-04-07 op test_done $testroot 1
1021 9d6cabd5 2022-04-07 op return 1
1022 9d6cabd5 2022-04-07 op fi
1023 9d6cabd5 2022-04-07 op
1024 9d6cabd5 2022-04-07 op cat <<EOF > $testroot/stderr.expected
1025 9d6cabd5 2022-04-07 op got: can't strip 1 path-components from foo/bar/alpha: bad path
1026 9d6cabd5 2022-04-07 op EOF
1027 9d6cabd5 2022-04-07 op
1028 9d6cabd5 2022-04-07 op cmp -s $testroot/stderr.expected $testroot/stderr
1029 9d6cabd5 2022-04-07 op ret=$?
1030 9d6cabd5 2022-04-07 op if [ $ret -ne 0 ]; then
1031 9d6cabd5 2022-04-07 op diff -u $testroot/stderr.expected $testroot/stderr
1032 9d6cabd5 2022-04-07 op fi
1033 9d6cabd5 2022-04-07 op test_done $testroot 0
1034 a92a2042 2022-07-02 op }
1035 a92a2042 2022-07-02 op
1036 a92a2042 2022-07-02 op test_patch_whitespace() {
1037 a92a2042 2022-07-02 op local testroot=`test_init patch_whitespace`
1038 a92a2042 2022-07-02 op
1039 a92a2042 2022-07-02 op got checkout $testroot/repo $testroot/wt > /dev/null
1040 a92a2042 2022-07-02 op ret=$?
1041 a92a2042 2022-07-02 op if [ $ret -ne 0 ]; then
1042 a92a2042 2022-07-02 op test_done $testroot $ret
1043 a92a2042 2022-07-02 op return 1
1044 a92a2042 2022-07-02 op fi
1045 a92a2042 2022-07-02 op
1046 a92a2042 2022-07-02 op trailing=" "
1047 a92a2042 2022-07-02 op
1048 a92a2042 2022-07-02 op cat <<EOF > $testroot/wt/hello.c
1049 a92a2042 2022-07-02 op #include <stdio.h>
1050 a92a2042 2022-07-02 op
1051 a92a2042 2022-07-02 op int
1052 a92a2042 2022-07-02 op main(void)
1053 a92a2042 2022-07-02 op {
1054 a92a2042 2022-07-02 op /* the trailing whitespace is on purpose */
1055 a92a2042 2022-07-02 op printf("hello, world\n");$trailing
1056 a92a2042 2022-07-02 op return 0;
1057 a92a2042 2022-07-02 op }
1058 a92a2042 2022-07-02 op EOF
1059 a92a2042 2022-07-02 op
1060 a92a2042 2022-07-02 op (cd $testroot/wt && got add hello.c && got ci -m '+hello.c') \
1061 a92a2042 2022-07-02 op > /dev/null
1062 a92a2042 2022-07-02 op ret=$?
1063 a92a2042 2022-07-02 op if [ $ret -ne 0 ]; then
1064 a92a2042 2022-07-02 op test_done $testroot $ret
1065 a92a2042 2022-07-02 op return 1
1066 a92a2042 2022-07-02 op fi
1067 a92a2042 2022-07-02 op
1068 a92a2042 2022-07-02 op # test with a diff with various whitespace corruptions
1069 a92a2042 2022-07-02 op cat <<EOF > $testroot/wt/patch
1070 a92a2042 2022-07-02 op --- hello.c
1071 a92a2042 2022-07-02 op +++ hello.c
1072 a92a2042 2022-07-02 op @@ -5,5 +5,5 @@
1073 a92a2042 2022-07-02 op {
1074 a92a2042 2022-07-02 op /* the trailing whitespace is on purpose */
1075 a92a2042 2022-07-02 op printf("hello, world\n");
1076 a92a2042 2022-07-02 op - return 0;
1077 a92a2042 2022-07-02 op + return 5; /* always fails */
1078 a92a2042 2022-07-02 op }
1079 a92a2042 2022-07-02 op EOF
1080 a92a2042 2022-07-02 op
1081 a92a2042 2022-07-02 op (cd $testroot/wt && got patch patch) \
1082 a92a2042 2022-07-02 op 2>$testroot/stderr >$testroot/stdout
1083 a92a2042 2022-07-02 op ret=$?
1084 a92a2042 2022-07-02 op if [ $ret -ne 0 ]; then
1085 a92a2042 2022-07-02 op echo "failed to apply diff" >&2
1086 a92a2042 2022-07-02 op test_done $testroot $ret
1087 a92a2042 2022-07-02 op return 1
1088 a92a2042 2022-07-02 op fi
1089 a92a2042 2022-07-02 op
1090 a92a2042 2022-07-02 op echo 'M hello.c' > $testroot/stdout.expected
1091 a92a2042 2022-07-02 op echo '@@ -5,5 +5,5 @@ hunk contains mangled whitespace' \
1092 a92a2042 2022-07-02 op >> $testroot/stdout.expected
1093 a92a2042 2022-07-02 op cmp -s $testroot/stdout.expected $testroot/stdout
1094 a92a2042 2022-07-02 op ret=$?
1095 a92a2042 2022-07-02 op if [ $ret -ne 0 ]; then
1096 a92a2042 2022-07-02 op diff -u $testroot/stdout.expected $testroot/stdout
1097 a92a2042 2022-07-02 op test_done $testroot $ret
1098 a92a2042 2022-07-02 op return 1
1099 a92a2042 2022-07-02 op fi
1100 a92a2042 2022-07-02 op
1101 a92a2042 2022-07-02 op cat <<EOF > $testroot/wt/hello.c.expected
1102 a92a2042 2022-07-02 op #include <stdio.h>
1103 a92a2042 2022-07-02 op
1104 a92a2042 2022-07-02 op int
1105 a92a2042 2022-07-02 op main(void)
1106 a92a2042 2022-07-02 op {
1107 a92a2042 2022-07-02 op /* the trailing whitespace is on purpose */
1108 a92a2042 2022-07-02 op printf("hello, world\n");$trailing
1109 a92a2042 2022-07-02 op return 5; /* always fails */
1110 a92a2042 2022-07-02 op }
1111 a92a2042 2022-07-02 op EOF
1112 a92a2042 2022-07-02 op
1113 a92a2042 2022-07-02 op cmp -s $testroot/wt/hello.c.expected $testroot/wt/hello.c
1114 a92a2042 2022-07-02 op ret=$?
1115 a92a2042 2022-07-02 op if [ $ret -ne 0 ]; then
1116 a92a2042 2022-07-02 op diff -u $testroot/wt/hello.c.expected $testroot/wt/hello.c
1117 a92a2042 2022-07-02 op fi
1118 a92a2042 2022-07-02 op test_done $testroot $ret
1119 9d6cabd5 2022-04-07 op }
1120 ed3bff83 2022-04-23 op
1121 ed3bff83 2022-04-23 op test_patch_relative_paths() {
1122 f1d6cebb 2022-04-23 op local testroot=`test_init patch_relative_paths`
1123 ed3bff83 2022-04-23 op
1124 ed3bff83 2022-04-23 op got checkout $testroot/repo $testroot/wt > /dev/null
1125 ed3bff83 2022-04-23 op ret=$?
1126 ed3bff83 2022-04-23 op if [ $ret -ne 0 ]; then
1127 ed3bff83 2022-04-23 op test_done $testroot $ret
1128 ed3bff83 2022-04-23 op return 1
1129 ed3bff83 2022-04-23 op fi
1130 9d6cabd5 2022-04-07 op
1131 ed3bff83 2022-04-23 op cat <<EOF > $testroot/wt/gamma/patch
1132 ed3bff83 2022-04-23 op --- delta
1133 ed3bff83 2022-04-23 op +++ delta
1134 ed3bff83 2022-04-23 op @@ -1 +1 @@
1135 ed3bff83 2022-04-23 op -delta
1136 ed3bff83 2022-04-23 op +DELTA
1137 ed3bff83 2022-04-23 op --- /dev/null
1138 ed3bff83 2022-04-23 op +++ eta
1139 ed3bff83 2022-04-23 op @@ -0,0 +1 @@
1140 ed3bff83 2022-04-23 op +eta
1141 ed3bff83 2022-04-23 op EOF
1142 ed3bff83 2022-04-23 op
1143 ed3bff83 2022-04-23 op (cd $testroot/wt/gamma && got patch patch) > $testroot/stdout
1144 ed3bff83 2022-04-23 op ret=$?
1145 ed3bff83 2022-04-23 op if [ $ret -ne 0 ]; then
1146 ed3bff83 2022-04-23 op test_done $testroot $ret
1147 ed3bff83 2022-04-23 op return 1
1148 ed3bff83 2022-04-23 op fi
1149 ed3bff83 2022-04-23 op
1150 ed3bff83 2022-04-23 op echo 'M gamma/delta' > $testroot/stdout.expected
1151 ed3bff83 2022-04-23 op echo 'A gamma/eta' >> $testroot/stdout.expected
1152 15e1bda6 2022-04-23 op
1153 15e1bda6 2022-04-23 op cmp -s $testroot/stdout.expected $testroot/stdout
1154 15e1bda6 2022-04-23 op ret=$?
1155 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1156 15e1bda6 2022-04-23 op diff -u $testroot/stdout.expected $testroot/stdout
1157 15e1bda6 2022-04-23 op fi
1158 15e1bda6 2022-04-23 op test_done $testroot $ret
1159 15e1bda6 2022-04-23 op }
1160 15e1bda6 2022-04-23 op
1161 15e1bda6 2022-04-23 op test_patch_with_path_prefix() {
1162 15e1bda6 2022-04-23 op local testroot=`test_init patch_with_path_prefix`
1163 15e1bda6 2022-04-23 op
1164 15e1bda6 2022-04-23 op got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
1165 15e1bda6 2022-04-23 op ret=$?
1166 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1167 15e1bda6 2022-04-23 op test_done $testroot $ret
1168 15e1bda6 2022-04-23 op return 1
1169 15e1bda6 2022-04-23 op fi
1170 15e1bda6 2022-04-23 op
1171 15e1bda6 2022-04-23 op cat <<EOF > $testroot/wt/patch
1172 15e1bda6 2022-04-23 op --- delta
1173 15e1bda6 2022-04-23 op +++ delta
1174 15e1bda6 2022-04-23 op @@ -1 +1 @@
1175 15e1bda6 2022-04-23 op -delta
1176 15e1bda6 2022-04-23 op +DELTA
1177 15e1bda6 2022-04-23 op --- /dev/null
1178 15e1bda6 2022-04-23 op +++ eta
1179 15e1bda6 2022-04-23 op @@ -0,0 +1 @@
1180 15e1bda6 2022-04-23 op +eta
1181 15e1bda6 2022-04-23 op EOF
1182 15e1bda6 2022-04-23 op
1183 15e1bda6 2022-04-23 op (cd $testroot/wt && got patch patch) > $testroot/stdout
1184 15e1bda6 2022-04-23 op ret=$?
1185 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1186 15e1bda6 2022-04-23 op test_done $testroot $ret
1187 15e1bda6 2022-04-23 op return 1
1188 15e1bda6 2022-04-23 op fi
1189 15e1bda6 2022-04-23 op
1190 15e1bda6 2022-04-23 op echo 'M delta' > $testroot/stdout.expected
1191 15e1bda6 2022-04-23 op echo 'A eta' >> $testroot/stdout.expected
1192 15e1bda6 2022-04-23 op
1193 15e1bda6 2022-04-23 op cmp -s $testroot/stdout.expected $testroot/stdout
1194 15e1bda6 2022-04-23 op ret=$?
1195 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1196 15e1bda6 2022-04-23 op diff -u $testroot/stdout.expected $testroot/stdout
1197 15e1bda6 2022-04-23 op fi
1198 15e1bda6 2022-04-23 op test_done $testroot $ret
1199 15e1bda6 2022-04-23 op }
1200 ed3bff83 2022-04-23 op
1201 15e1bda6 2022-04-23 op test_patch_relpath_with_path_prefix() {
1202 15e1bda6 2022-04-23 op local testroot=`test_init patch_relpaths_with_path_prefix`
1203 15e1bda6 2022-04-23 op
1204 15e1bda6 2022-04-23 op got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
1205 15e1bda6 2022-04-23 op ret=$?
1206 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1207 15e1bda6 2022-04-23 op test_done $testroot $ret
1208 15e1bda6 2022-04-23 op return 1
1209 15e1bda6 2022-04-23 op fi
1210 15e1bda6 2022-04-23 op
1211 15e1bda6 2022-04-23 op mkdir -p $testroot/wt/epsilon/zeta/
1212 15e1bda6 2022-04-23 op
1213 15e1bda6 2022-04-23 op cat <<EOF > $testroot/wt/patch
1214 15e1bda6 2022-04-23 op --- /dev/null
1215 15e1bda6 2022-04-23 op +++ zeta/theta
1216 15e1bda6 2022-04-23 op @@ -0,0 +1 @@
1217 15e1bda6 2022-04-23 op +theta
1218 15e1bda6 2022-04-23 op EOF
1219 15e1bda6 2022-04-23 op
1220 15e1bda6 2022-04-23 op (cd $testroot/wt/epsilon/zeta && got patch -p1 $testroot/wt/patch) \
1221 15e1bda6 2022-04-23 op > $testroot/stdout
1222 15e1bda6 2022-04-23 op ret=$?
1223 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1224 15e1bda6 2022-04-23 op test_done $testroot $ret
1225 15e1bda6 2022-04-23 op return 1
1226 15e1bda6 2022-04-23 op fi
1227 15e1bda6 2022-04-23 op
1228 15e1bda6 2022-04-23 op echo 'A epsilon/zeta/theta' >> $testroot/stdout.expected
1229 15e1bda6 2022-04-23 op
1230 ed3bff83 2022-04-23 op cmp -s $testroot/stdout.expected $testroot/stdout
1231 ed3bff83 2022-04-23 op ret=$?
1232 ed3bff83 2022-04-23 op if [ $ret -ne 0 ]; then
1233 ed3bff83 2022-04-23 op diff -u $testroot/stdout.expected $testroot/stdout
1234 15e1bda6 2022-04-23 op test_done $testroot $ret
1235 15e1bda6 2022-04-23 op return 1
1236 ed3bff83 2022-04-23 op fi
1237 15e1bda6 2022-04-23 op
1238 15e1bda6 2022-04-23 op echo 'theta' > $testroot/theta.expected
1239 15e1bda6 2022-04-23 op cmp -s $testroot/wt/epsilon/zeta/theta $testroot/theta.expected
1240 15e1bda6 2022-04-23 op ret=$?
1241 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1242 15e1bda6 2022-04-23 op diff -u $testroot/wt/epsilon/zeta/theta $testroot/theta.expected
1243 15e1bda6 2022-04-23 op fi
1244 ed3bff83 2022-04-23 op test_done $testroot $ret
1245 ed3bff83 2022-04-23 op }
1246 bad961bf 2022-04-23 op
1247 bad961bf 2022-04-23 op test_patch_reverse() {
1248 bad961bf 2022-04-23 op local testroot=`test_init patch_reverse`
1249 bad961bf 2022-04-23 op
1250 bad961bf 2022-04-23 op got checkout $testroot/repo $testroot/wt > /dev/null
1251 bad961bf 2022-04-23 op ret=$?
1252 bad961bf 2022-04-23 op if [ $ret -ne 0 ]; then
1253 bad961bf 2022-04-23 op test_done $testroot $ret
1254 bad961bf 2022-04-23 op return 1
1255 bad961bf 2022-04-23 op fi
1256 bad961bf 2022-04-23 op
1257 bad961bf 2022-04-23 op cat <<EOF > $testroot/wt/patch
1258 bad961bf 2022-04-23 op --- alpha
1259 bad961bf 2022-04-23 op +++ alpha
1260 bad961bf 2022-04-23 op @@ -1 +1 @@
1261 bad961bf 2022-04-23 op -ALPHA
1262 bad961bf 2022-04-23 op \ No newline at end of file
1263 bad961bf 2022-04-23 op +alpha
1264 bad961bf 2022-04-23 op EOF
1265 ed3bff83 2022-04-23 op
1266 bad961bf 2022-04-23 op (cd $testroot/wt && got patch -R patch) > $testroot/stdout
1267 bad961bf 2022-04-23 op ret=$?
1268 bad961bf 2022-04-23 op if [ $ret -ne 0 ]; then
1269 bad961bf 2022-04-23 op test_done $testroot $ret
1270 bad961bf 2022-04-23 op return 1
1271 bad961bf 2022-04-23 op fi
1272 bad961bf 2022-04-23 op
1273 bad961bf 2022-04-23 op echo "M alpha" > $testroot/stdout.expected
1274 bad961bf 2022-04-23 op cmp -s $testroot/stdout.expected $testroot/stdout
1275 bad961bf 2022-04-23 op ret=$?
1276 bad961bf 2022-04-23 op if [ $ret -ne 0 ]; then
1277 bad961bf 2022-04-23 op diff -u $testroot/stdout.expected $testroot/stdout
1278 bad961bf 2022-04-23 op test_done $testroot $ret
1279 bad961bf 2022-04-23 op return 1
1280 bad961bf 2022-04-23 op fi
1281 bad961bf 2022-04-23 op
1282 bad961bf 2022-04-23 op echo -n ALPHA > $testroot/wt/alpha.expected
1283 bad961bf 2022-04-23 op cmp -s $testroot/wt/alpha.expected $testroot/wt/alpha
1284 bad961bf 2022-04-23 op ret=$?
1285 bad961bf 2022-04-23 op if [ $ret -ne 0 ]; then
1286 bad961bf 2022-04-23 op diff -u $testroot/wt/alpha.expected $testroot/wt/alpha
1287 55e9459f 2022-06-19 op fi
1288 55e9459f 2022-06-19 op test_done $testroot $ret
1289 55e9459f 2022-06-19 op }
1290 55e9459f 2022-06-19 op
1291 55e9459f 2022-06-19 op test_patch_merge_simple() {
1292 55e9459f 2022-06-19 op local testroot=`test_init patch_merge_simple`
1293 55e9459f 2022-06-19 op
1294 55e9459f 2022-06-19 op got checkout $testroot/repo $testroot/wt > /dev/null
1295 55e9459f 2022-06-19 op ret=$?
1296 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1297 55e9459f 2022-06-19 op test_done $testroot $ret
1298 55e9459f 2022-06-19 op return 1
1299 55e9459f 2022-06-19 op fi
1300 55e9459f 2022-06-19 op
1301 55e9459f 2022-06-19 op jot 10 > $testroot/wt/numbers
1302 5dffb1a1 2022-07-02 op chmod +x $testroot/wt/numbers
1303 55e9459f 2022-06-19 op (cd $testroot/wt && got add numbers && got commit -m +numbers) \
1304 55e9459f 2022-06-19 op > /dev/null
1305 55e9459f 2022-06-19 op ret=$?
1306 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1307 55e9459f 2022-06-19 op test_done $testroot $ret
1308 55e9459f 2022-06-19 op return 1
1309 55e9459f 2022-06-19 op fi
1310 55e9459f 2022-06-19 op
1311 55e9459f 2022-06-19 op jot 10 | sed 's/4/four/g' > $testroot/wt/numbers
1312 55e9459f 2022-06-19 op
1313 55e9459f 2022-06-19 op (cd $testroot/wt && got diff > $testroot/old.diff \
1314 55e9459f 2022-06-19 op && got revert numbers) >/dev/null
1315 55e9459f 2022-06-19 op ret=$?
1316 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1317 55e9459f 2022-06-19 op test_done $testroot $ret
1318 55e9459f 2022-06-19 op return 1
1319 55e9459f 2022-06-19 op fi
1320 55e9459f 2022-06-19 op
1321 55e9459f 2022-06-19 op jot 10 | sed 's/6/six/g' > $testroot/wt/numbers
1322 55e9459f 2022-06-19 op (cd $testroot/wt && got commit -m 'edit numbers') \
1323 55e9459f 2022-06-19 op > /dev/null
1324 55e9459f 2022-06-19 op ret=$?
1325 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1326 55e9459f 2022-06-19 op test_done $testroot $ret
1327 55e9459f 2022-06-19 op return 1
1328 55e9459f 2022-06-19 op fi
1329 55e9459f 2022-06-19 op
1330 55e9459f 2022-06-19 op (cd $testroot/wt && got patch $testroot/old.diff) \
1331 9802c41c 2022-06-21 op > $testroot/stdout
1332 55e9459f 2022-06-19 op ret=$?
1333 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1334 9802c41c 2022-06-21 op test_done $testroot $ret
1335 9802c41c 2022-06-21 op return 1
1336 9802c41c 2022-06-21 op fi
1337 9802c41c 2022-06-21 op
1338 9802c41c 2022-06-21 op echo 'G numbers' > $testroot/stdout.expected
1339 9802c41c 2022-06-21 op cmp -s $testroot/stdout $testroot/stdout.expected
1340 9802c41c 2022-06-21 op ret=$?
1341 9802c41c 2022-06-21 op if [ $ret -ne 0 ]; then
1342 9802c41c 2022-06-21 op diff -u $testroot/stdout $testroot/stdout.expected
1343 55e9459f 2022-06-19 op test_done $testroot $ret
1344 55e9459f 2022-06-19 op return 1
1345 55e9459f 2022-06-19 op fi
1346 55e9459f 2022-06-19 op
1347 55e9459f 2022-06-19 op jot 10 | sed -e s/4/four/ -e s/6/six/ > $testroot/wt/numbers.expected
1348 55e9459f 2022-06-19 op cmp -s $testroot/wt/numbers $testroot/wt/numbers.expected
1349 55e9459f 2022-06-19 op ret=$?
1350 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1351 55e9459f 2022-06-19 op diff -u $testroot/wt/numbers $testroot/wt/numbers.expected
1352 5dffb1a1 2022-07-02 op test_done $testroot $ret
1353 5dffb1a1 2022-07-02 op return 1
1354 db0dfdd7 2022-06-27 op fi
1355 5dffb1a1 2022-07-02 op
1356 5dffb1a1 2022-07-02 op test -x $testroot/wt/numbers
1357 5dffb1a1 2022-07-02 op ret=$?
1358 5dffb1a1 2022-07-02 op if [ $ret -ne 0 ]; then
1359 5dffb1a1 2022-07-02 op echo "numbers lost the executable bit" >&2
1360 5dffb1a1 2022-07-02 op fi
1361 db0dfdd7 2022-06-27 op test_done $testroot $ret
1362 db0dfdd7 2022-06-27 op }
1363 db0dfdd7 2022-06-27 op
1364 db0dfdd7 2022-06-27 op test_patch_merge_gitdiff() {
1365 db0dfdd7 2022-06-27 op local testroot=`test_init patch_merge_gitdiff`
1366 db0dfdd7 2022-06-27 op
1367 db0dfdd7 2022-06-27 op jot 10 > $testroot/repo/numbers
1368 db0dfdd7 2022-06-27 op (cd $testroot/repo && git add numbers && \
1369 db0dfdd7 2022-06-27 op git_commit $testroot/repo -m "nums")
1370 db0dfdd7 2022-06-27 op ret=$?
1371 db0dfdd7 2022-06-27 op if [ $ret -ne 0 ]; then
1372 db0dfdd7 2022-06-27 op test_done $testroot $ret
1373 db0dfdd7 2022-06-27 op return 1
1374 db0dfdd7 2022-06-27 op fi
1375 db0dfdd7 2022-06-27 op
1376 db0dfdd7 2022-06-27 op jot 10 | sed 's/4/four/g' > $testroot/repo/numbers
1377 db0dfdd7 2022-06-27 op (cd $testroot/repo && git diff > $testroot/old.diff)
1378 db0dfdd7 2022-06-27 op ret=$?
1379 db0dfdd7 2022-06-27 op if [ $ret -ne 0 ]; then
1380 db0dfdd7 2022-06-27 op test_done $testroot $ret
1381 db0dfdd7 2022-06-27 op return 1
1382 db0dfdd7 2022-06-27 op fi
1383 db0dfdd7 2022-06-27 op
1384 db0dfdd7 2022-06-27 op # restore numbers
1385 db0dfdd7 2022-06-27 op jot 10 > $testroot/repo/numbers
1386 db0dfdd7 2022-06-27 op
1387 db0dfdd7 2022-06-27 op jot 10 | sed 's/6/six/g' > $testroot/repo/numbers
1388 db0dfdd7 2022-06-27 op (cd $testroot/repo && git add numbers && \
1389 db0dfdd7 2022-06-27 op git_commit $testroot/repo -m "edit")
1390 db0dfdd7 2022-06-27 op ret=$?
1391 db0dfdd7 2022-06-27 op if [ $ret -ne 0 ]; then
1392 db0dfdd7 2022-06-27 op test_done $testroot $ret
1393 db0dfdd7 2022-06-27 op return 1
1394 db0dfdd7 2022-06-27 op fi
1395 db0dfdd7 2022-06-27 op
1396 db0dfdd7 2022-06-27 op # now work with got:
1397 db0dfdd7 2022-06-27 op got checkout $testroot/repo $testroot/wt > /dev/null
1398 db0dfdd7 2022-06-27 op ret=$?
1399 db0dfdd7 2022-06-27 op if [ $ret -ne 0 ]; then
1400 db0dfdd7 2022-06-27 op test_done $testroot $ret
1401 db0dfdd7 2022-06-27 op return 1
1402 db0dfdd7 2022-06-27 op fi
1403 db0dfdd7 2022-06-27 op
1404 db0dfdd7 2022-06-27 op (cd $testroot/wt && got patch $testroot/old.diff) > $testroot/stdout
1405 db0dfdd7 2022-06-27 op ret=$?
1406 db0dfdd7 2022-06-27 op if [ $ret -ne 0 ]; then
1407 db0dfdd7 2022-06-27 op test_done $testroot $ret
1408 db0dfdd7 2022-06-27 op return 1
1409 55e9459f 2022-06-19 op fi
1410 db0dfdd7 2022-06-27 op
1411 db0dfdd7 2022-06-27 op echo 'G numbers' > $testroot/stdout.expected
1412 db0dfdd7 2022-06-27 op cmp -s $testroot/stdout $testroot/stdout.expected
1413 db0dfdd7 2022-06-27 op ret=$?
1414 db0dfdd7 2022-06-27 op if [ $ret -ne 0 ]; then
1415 db0dfdd7 2022-06-27 op diff -u $testroot/stdout $testroot/stdout.expected
1416 db0dfdd7 2022-06-27 op fi
1417 55e9459f 2022-06-19 op test_done $testroot $ret
1418 55e9459f 2022-06-19 op }
1419 5f56d41e 2022-07-28 op
1420 5f56d41e 2022-07-28 op test_patch_merge_base_provided() {
1421 5f56d41e 2022-07-28 op local testroot=`test_init patch_merge_base_provided`
1422 5f56d41e 2022-07-28 op
1423 5f56d41e 2022-07-28 op got checkout $testroot/repo $testroot/wt >/dev/null
1424 5f56d41e 2022-07-28 op ret=$?
1425 5f56d41e 2022-07-28 op if [ $ret -ne 0 ]; then
1426 5f56d41e 2022-07-28 op test_done $testroot $ret
1427 5f56d41e 2022-07-28 op return 1
1428 5f56d41e 2022-07-28 op fi
1429 5f56d41e 2022-07-28 op
1430 5f56d41e 2022-07-28 op jot 10 > $testroot/wt/numbers
1431 5f56d41e 2022-07-28 op (cd $testroot/wt && got add numbers && got commit -m +numbers) \
1432 5f56d41e 2022-07-28 op >/dev/null
1433 5f56d41e 2022-07-28 op ret=$?
1434 5f56d41e 2022-07-28 op if [ $ret -ne 0 ]; then
1435 5f56d41e 2022-07-28 op test_done $testroot $ret
1436 5f56d41e 2022-07-28 op return 1
1437 5f56d41e 2022-07-28 op fi
1438 55e9459f 2022-06-19 op
1439 5f56d41e 2022-07-28 op local commit_id=`git_show_head $testroot/repo`
1440 5f56d41e 2022-07-28 op
1441 5f56d41e 2022-07-28 op jot 10 | sed s/4/four/ > $testroot/wt/numbers
1442 5f56d41e 2022-07-28 op
1443 5f56d41e 2022-07-28 op # get rid of the metadata
1444 5f56d41e 2022-07-28 op (cd $testroot/wt && got diff | sed -n '/^---/,$p' > patch) \
1445 5f56d41e 2022-07-28 op >/dev/null
1446 5f56d41e 2022-07-28 op
1447 5f56d41e 2022-07-28 op jot 10 | sed s/6/six/ > $testroot/wt/numbers
1448 5f56d41e 2022-07-28 op (cd $testroot/wt && got commit -m 'edit numbers') >/dev/null
1449 5f56d41e 2022-07-28 op ret=$?
1450 5f56d41e 2022-07-28 op if [ $ret -ne 0 ]; then
1451 5f56d41e 2022-07-28 op test_done $testroot $ret
1452 5f56d41e 2022-07-28 op return 1
1453 5f56d41e 2022-07-28 op fi
1454 5f56d41e 2022-07-28 op
1455 5f56d41e 2022-07-28 op (cd $testroot/wt && got patch -c $commit_id patch) >$testroot/stdout
1456 5f56d41e 2022-07-28 op ret=$?
1457 5f56d41e 2022-07-28 op if [ $ret -ne 0 ]; then
1458 5f56d41e 2022-07-28 op test_done $testroot $ret
1459 5f56d41e 2022-07-28 op return 1
1460 5f56d41e 2022-07-28 op fi
1461 5f56d41e 2022-07-28 op
1462 5f56d41e 2022-07-28 op echo 'G numbers' > $testroot/stdout.expected
1463 5f56d41e 2022-07-28 op cmp -s $testroot/stdout $testroot/stdout.expected
1464 5f56d41e 2022-07-28 op ret=$?
1465 5f56d41e 2022-07-28 op if [ $ret -ne 0 ]; then
1466 5f56d41e 2022-07-28 op diff -u $testroot/stdout $testroot/stdout.expected
1467 5f56d41e 2022-07-28 op test_done $testroot $ret
1468 5f56d41e 2022-07-28 op return 1
1469 5f56d41e 2022-07-28 op fi
1470 5f56d41e 2022-07-28 op
1471 5f56d41e 2022-07-28 op jot 10 | sed -e s/4/four/ -e s/6/six/ > $testroot/wt/numbers.expected
1472 5f56d41e 2022-07-28 op cmp -s $testroot/wt/numbers $testroot/wt/numbers.expected
1473 5f56d41e 2022-07-28 op ret=$?
1474 5f56d41e 2022-07-28 op if [ $ret -ne 0 ]; then
1475 5f56d41e 2022-07-28 op diff -u $testroot/wt/numbers $testroot/wt/numbers.expected
1476 5f56d41e 2022-07-28 op fi
1477 5f56d41e 2022-07-28 op test_done $testroot $ret
1478 5f56d41e 2022-07-28 op }
1479 5f56d41e 2022-07-28 op
1480 55e9459f 2022-06-19 op test_patch_merge_conflict() {
1481 55e9459f 2022-06-19 op local testroot=`test_init patch_merge_conflict`
1482 55e9459f 2022-06-19 op
1483 55e9459f 2022-06-19 op got checkout $testroot/repo $testroot/wt > /dev/null
1484 55e9459f 2022-06-19 op ret=$?
1485 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1486 55e9459f 2022-06-19 op test_done $testroot $ret
1487 55e9459f 2022-06-19 op return 1
1488 55e9459f 2022-06-19 op fi
1489 55e9459f 2022-06-19 op
1490 55e9459f 2022-06-19 op jot 10 > $testroot/wt/numbers
1491 55e9459f 2022-06-19 op (cd $testroot/wt && got add numbers && got commit -m +numbers) \
1492 55e9459f 2022-06-19 op > /dev/null
1493 55e9459f 2022-06-19 op ret=$?
1494 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1495 55e9459f 2022-06-19 op test_done $testroot $ret
1496 55e9459f 2022-06-19 op return 1
1497 55e9459f 2022-06-19 op fi
1498 d8b5af43 2022-06-19 op
1499 d8b5af43 2022-06-19 op local commit_id=`git_show_head $testroot/repo`
1500 55e9459f 2022-06-19 op
1501 55e9459f 2022-06-19 op jot 10 | sed 's/6/six/g' > $testroot/wt/numbers
1502 acf749fc 2022-07-02 op echo ALPHA > $testroot/wt/alpha
1503 55e9459f 2022-06-19 op
1504 55e9459f 2022-06-19 op (cd $testroot/wt && got diff > $testroot/old.diff \
1505 acf749fc 2022-07-02 op && got revert alpha numbers) >/dev/null
1506 55e9459f 2022-06-19 op ret=$?
1507 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1508 55e9459f 2022-06-19 op test_done $testroot $ret
1509 55e9459f 2022-06-19 op return 1
1510 55e9459f 2022-06-19 op fi
1511 55e9459f 2022-06-19 op
1512 55e9459f 2022-06-19 op jot 10 | sed 's/6/3+3/g' > $testroot/wt/numbers
1513 acf749fc 2022-07-02 op jot -c 3 a > $testroot/wt/alpha
1514 acf749fc 2022-07-02 op (cd $testroot/wt && got commit -m 'edit alpha and numbers') \
1515 55e9459f 2022-06-19 op > /dev/null
1516 55e9459f 2022-06-19 op ret=$?
1517 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1518 55e9459f 2022-06-19 op test_done $testroot $ret
1519 55e9459f 2022-06-19 op return 1
1520 bad961bf 2022-04-23 op fi
1521 55e9459f 2022-06-19 op
1522 55e9459f 2022-06-19 op (cd $testroot/wt && got patch $testroot/old.diff) \
1523 9802c41c 2022-06-21 op > $testroot/stdout 2>/dev/null
1524 55e9459f 2022-06-19 op ret=$?
1525 55e9459f 2022-06-19 op if [ $ret -eq 0 ]; then
1526 55e9459f 2022-06-19 op echo "got patch merged a diff that should conflict" >&2
1527 e423877d 2023-05-11 stsp test_done $testroot 1
1528 55e9459f 2022-06-19 op return 1
1529 55e9459f 2022-06-19 op fi
1530 55e9459f 2022-06-19 op
1531 acf749fc 2022-07-02 op echo 'C alpha' > $testroot/stdout.expected
1532 acf749fc 2022-07-02 op echo 'C numbers' >> $testroot/stdout.expected
1533 bfcdc9e9 2023-05-11 stsp echo 'Files with merge conflicts: 2' >> $testroot/stdout.expected
1534 9802c41c 2022-06-21 op cmp -s $testroot/stdout $testroot/stdout.expected
1535 9802c41c 2022-06-21 op ret=$?
1536 9802c41c 2022-06-21 op if [ $ret -ne 0 ]; then
1537 9802c41c 2022-06-21 op diff -u $testroot/stdout $testroot/stdout.expected
1538 9802c41c 2022-06-21 op test_done $testroot $ret
1539 9802c41c 2022-06-21 op return 1
1540 9802c41c 2022-06-21 op fi
1541 9802c41c 2022-06-21 op
1542 55e9459f 2022-06-19 op # XXX: prefixing every line with a tab otherwise got thinks
1543 55e9459f 2022-06-19 op # the file has conflicts in it.
1544 acf749fc 2022-07-02 op cat <<-EOF > $testroot/wt/alpha.expected
1545 acf749fc 2022-07-02 op <<<<<<< --- alpha
1546 acf749fc 2022-07-02 op ALPHA
1547 acf749fc 2022-07-02 op ||||||| commit $commit_id
1548 acf749fc 2022-07-02 op alpha
1549 acf749fc 2022-07-02 op =======
1550 acf749fc 2022-07-02 op a
1551 acf749fc 2022-07-02 op b
1552 acf749fc 2022-07-02 op c
1553 acf749fc 2022-07-02 op >>>>>>> +++ alpha
1554 acf749fc 2022-07-02 op EOF
1555 acf749fc 2022-07-02 op
1556 55e9459f 2022-06-19 op cat <<-EOF > $testroot/wt/numbers.expected
1557 55e9459f 2022-06-19 op 1
1558 55e9459f 2022-06-19 op 2
1559 55e9459f 2022-06-19 op 3
1560 55e9459f 2022-06-19 op 4
1561 55e9459f 2022-06-19 op 5
1562 55e9459f 2022-06-19 op <<<<<<< --- numbers
1563 55e9459f 2022-06-19 op six
1564 d8b5af43 2022-06-19 op ||||||| commit $commit_id
1565 55e9459f 2022-06-19 op 6
1566 55e9459f 2022-06-19 op =======
1567 55e9459f 2022-06-19 op 3+3
1568 55e9459f 2022-06-19 op >>>>>>> +++ numbers
1569 55e9459f 2022-06-19 op 7
1570 55e9459f 2022-06-19 op 8
1571 55e9459f 2022-06-19 op 9
1572 55e9459f 2022-06-19 op 10
1573 55e9459f 2022-06-19 op EOF
1574 55e9459f 2022-06-19 op
1575 acf749fc 2022-07-02 op cmp -s $testroot/wt/alpha $testroot/wt/alpha.expected
1576 acf749fc 2022-07-02 op ret=$?
1577 acf749fc 2022-07-02 op if [ $ret -ne 0 ]; then
1578 acf749fc 2022-07-02 op diff -u $testroot/wt/alpha $testroot/wt/alpha.expected
1579 acf749fc 2022-07-02 op test_done $testroot $ret
1580 acf749fc 2022-07-02 op return 1
1581 acf749fc 2022-07-02 op fi
1582 acf749fc 2022-07-02 op
1583 55e9459f 2022-06-19 op cmp -s $testroot/wt/numbers $testroot/wt/numbers.expected
1584 55e9459f 2022-06-19 op ret=$?
1585 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1586 55e9459f 2022-06-19 op diff -u $testroot/wt/numbers $testroot/wt/numbers.expected
1587 55e9459f 2022-06-19 op fi
1588 bad961bf 2022-04-23 op test_done $testroot $ret
1589 bad961bf 2022-04-23 op }
1590 bad961bf 2022-04-23 op
1591 55e9459f 2022-06-19 op test_patch_merge_unknown_blob() {
1592 55e9459f 2022-06-19 op local testroot=`test_init patch_merge_unknown_blob`
1593 55e9459f 2022-06-19 op
1594 55e9459f 2022-06-19 op got checkout $testroot/repo $testroot/wt > /dev/null
1595 55e9459f 2022-06-19 op ret=$?
1596 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1597 55e9459f 2022-06-19 op test_done $testroot $ret
1598 55e9459f 2022-06-19 op return 1
1599 55e9459f 2022-06-19 op fi
1600 55e9459f 2022-06-19 op
1601 55e9459f 2022-06-19 op cat <<EOF > $testroot/wt/patch
1602 55e9459f 2022-06-19 op I've got a
1603 dbc68eed 2022-06-21 op diff aaaabbbbccccddddeeeeffff0000111122223333 foo/bar
1604 dbc68eed 2022-06-21 op with a
1605 55e9459f 2022-06-19 op blob - aaaabbbbccccddddeeeeffff0000111122223333
1606 55e9459f 2022-06-19 op and also a
1607 dbc68eed 2022-06-21 op blob + 0000111122223333444455556666777788889999
1608 55e9459f 2022-06-19 op for this dummy diff
1609 55e9459f 2022-06-19 op --- alpha
1610 55e9459f 2022-06-19 op +++ alpha
1611 55e9459f 2022-06-19 op @@ -1 +1 @@
1612 55e9459f 2022-06-19 op -alpha
1613 55e9459f 2022-06-19 op +ALPHA
1614 55e9459f 2022-06-19 op will it work?
1615 55e9459f 2022-06-19 op EOF
1616 55e9459f 2022-06-19 op
1617 55e9459f 2022-06-19 op (cd $testroot/wt/ && got patch patch) > $testroot/stdout
1618 55e9459f 2022-06-19 op ret=$?
1619 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1620 55e9459f 2022-06-19 op test_done $testroot $ret
1621 55e9459f 2022-06-19 op return 1
1622 55e9459f 2022-06-19 op fi
1623 55e9459f 2022-06-19 op
1624 55e9459f 2022-06-19 op echo 'M alpha' > $testroot/stdout.expected
1625 55e9459f 2022-06-19 op cmp -s $testroot/stdout.expected $testroot/stdout
1626 55e9459f 2022-06-19 op ret=$?
1627 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1628 55e9459f 2022-06-19 op diff -u $testroot/stdout.expected $testroot/stdout
1629 dbc68eed 2022-06-21 op test_done $testroot $ret
1630 dbc68eed 2022-06-21 op return 1
1631 55e9459f 2022-06-19 op fi
1632 dbc68eed 2022-06-21 op
1633 dbc68eed 2022-06-21 op # try again without a `diff' header
1634 dbc68eed 2022-06-21 op
1635 dbc68eed 2022-06-21 op cat <<EOF > $testroot/wt/patch
1636 dbc68eed 2022-06-21 op I've got a
1637 dbc68eed 2022-06-21 op blob - aaaabbbbccccddddeeeeffff0000111122223333
1638 dbc68eed 2022-06-21 op and also a
1639 dbc68eed 2022-06-21 op blob + 0000111122223333444455556666777788889999
1640 dbc68eed 2022-06-21 op for this dummy diff
1641 dbc68eed 2022-06-21 op --- alpha
1642 dbc68eed 2022-06-21 op +++ alpha
1643 dbc68eed 2022-06-21 op @@ -1 +1 @@
1644 dbc68eed 2022-06-21 op -alpha
1645 dbc68eed 2022-06-21 op +ALPHA
1646 dbc68eed 2022-06-21 op will it work?
1647 dbc68eed 2022-06-21 op EOF
1648 dbc68eed 2022-06-21 op
1649 dbc68eed 2022-06-21 op (cd $testroot/wt && got revert alpha > /dev/null && got patch patch) \
1650 dbc68eed 2022-06-21 op > $testroot/stdout
1651 dbc68eed 2022-06-21 op ret=$?
1652 dbc68eed 2022-06-21 op if [ $ret -ne 0 ]; then
1653 dbc68eed 2022-06-21 op test_done $testroot $ret
1654 dbc68eed 2022-06-21 op return 1
1655 dbc68eed 2022-06-21 op fi
1656 dbc68eed 2022-06-21 op
1657 dbc68eed 2022-06-21 op echo 'M alpha' > $testroot/stdout.expected
1658 dbc68eed 2022-06-21 op cmp -s $testroot/stdout.expected $testroot/stdout
1659 dbc68eed 2022-06-21 op ret=$?
1660 dbc68eed 2022-06-21 op if [ $ret -ne 0 ]; then
1661 dbc68eed 2022-06-21 op diff -u $testroot/stdout.expected $testroot/stdout
1662 db0dfdd7 2022-06-27 op test_done $testroot $ret
1663 db0dfdd7 2022-06-27 op return 1
1664 dbc68eed 2022-06-21 op fi
1665 db0dfdd7 2022-06-27 op
1666 db0dfdd7 2022-06-27 op # try again with a git-style diff
1667 db0dfdd7 2022-06-27 op
1668 db0dfdd7 2022-06-27 op cat <<EOF > $testroot/wt/patch
1669 db0dfdd7 2022-06-27 op diff --git a/alpha b/alpha
1670 db0dfdd7 2022-06-27 op index 0123456789ab..abcdef012345 100644
1671 db0dfdd7 2022-06-27 op --- a/alpha
1672 db0dfdd7 2022-06-27 op +++ b/alpha
1673 db0dfdd7 2022-06-27 op @@ -1 +1 @@
1674 db0dfdd7 2022-06-27 op -alpha
1675 db0dfdd7 2022-06-27 op +ALPHA
1676 db0dfdd7 2022-06-27 op EOF
1677 db0dfdd7 2022-06-27 op
1678 db0dfdd7 2022-06-27 op (cd $testroot/wt && got revert alpha > /dev/null && got patch patch) \
1679 db0dfdd7 2022-06-27 op > $testroot/stdout
1680 db0dfdd7 2022-06-27 op ret=$?
1681 db0dfdd7 2022-06-27 op if [ $ret -ne 0 ]; then
1682 db0dfdd7 2022-06-27 op test_done $testroot $ret
1683 db0dfdd7 2022-06-27 op return 1
1684 db0dfdd7 2022-06-27 op fi
1685 db0dfdd7 2022-06-27 op
1686 db0dfdd7 2022-06-27 op echo 'M alpha' > $testroot/stdout.expected
1687 db0dfdd7 2022-06-27 op cmp -s $testroot/stdout.expected $testroot/stdout
1688 db0dfdd7 2022-06-27 op ret=$?
1689 db0dfdd7 2022-06-27 op if [ $ret -ne 0 ]; then
1690 db0dfdd7 2022-06-27 op diff -u $testroot/stdout.expected $testroot/stdout
1691 db0dfdd7 2022-06-27 op fi
1692 55e9459f 2022-06-19 op test_done $testroot $ret
1693 55e9459f 2022-06-19 op }
1694 38d61ead 2022-07-23 op
1695 38d61ead 2022-07-23 op test_patch_merge_reverse() {
1696 38d61ead 2022-07-23 op local testroot=`test_init patch_merge_simple`
1697 38d61ead 2022-07-23 op
1698 38d61ead 2022-07-23 op got checkout $testroot/repo $testroot/wt > /dev/null
1699 38d61ead 2022-07-23 op ret=$?
1700 38d61ead 2022-07-23 op if [ $ret -ne 0 ]; then
1701 38d61ead 2022-07-23 op test_done $testroot $ret
1702 38d61ead 2022-07-23 op return 1
1703 38d61ead 2022-07-23 op fi
1704 55e9459f 2022-06-19 op
1705 38d61ead 2022-07-23 op jot 10 > $testroot/wt/numbers
1706 38d61ead 2022-07-23 op (cd $testroot/wt && got add numbers && got commit -m +numbers) \
1707 38d61ead 2022-07-23 op > /dev/null
1708 38d61ead 2022-07-23 op ret=$?
1709 38d61ead 2022-07-23 op if [ $ret -ne 0 ]; then
1710 38d61ead 2022-07-23 op test_done $testroot $ret
1711 38d61ead 2022-07-23 op return 1
1712 38d61ead 2022-07-23 op fi
1713 38d61ead 2022-07-23 op
1714 38d61ead 2022-07-23 op local commit_id=`git_show_head $testroot/repo`
1715 38d61ead 2022-07-23 op
1716 38d61ead 2022-07-23 op jot 10 | sed s/5/five/g > $testroot/wt/numbers
1717 38d61ead 2022-07-23 op (cd $testroot/wt && got diff > $testroot/wt/patch \
1718 38d61ead 2022-07-23 op && got commit -m 'edit numbers') > /dev/null
1719 38d61ead 2022-07-23 op ret=$?
1720 38d61ead 2022-07-23 op if [ $ret -ne 0 ]; then
1721 38d61ead 2022-07-23 op test_done $testroot $ret
1722 38d61ead 2022-07-23 op return 1
1723 38d61ead 2022-07-23 op fi
1724 38d61ead 2022-07-23 op
1725 38d61ead 2022-07-23 op jot 10 | sed -e s/5/five/g -e s/6/six/g > $testroot/wt/numbers
1726 38d61ead 2022-07-23 op (cd $testroot/wt && got commit -m 'edit numbers again') >/dev/null
1727 38d61ead 2022-07-23 op ret=$?
1728 38d61ead 2022-07-23 op if [ $ret -ne 0 ]; then
1729 38d61ead 2022-07-23 op test_done $testroot $ret
1730 38d61ead 2022-07-23 op return 1
1731 38d61ead 2022-07-23 op fi
1732 38d61ead 2022-07-23 op
1733 38d61ead 2022-07-23 op (cd $testroot/wt && got patch -R patch) >/dev/null 2>&1
1734 38d61ead 2022-07-23 op ret=$?
1735 38d61ead 2022-07-23 op if [ $ret -eq 0 ]; then
1736 38d61ead 2022-07-23 op echo "unexpectedly reverted the patch" >&2
1737 38d61ead 2022-07-23 op test_done $testroot 1
1738 38d61ead 2022-07-23 op return 1
1739 38d61ead 2022-07-23 op fi
1740 38d61ead 2022-07-23 op
1741 38d61ead 2022-07-23 op cat <<-EOF > $testroot/wt/numbers.expected
1742 38d61ead 2022-07-23 op 1
1743 38d61ead 2022-07-23 op 2
1744 38d61ead 2022-07-23 op 3
1745 38d61ead 2022-07-23 op 4
1746 38d61ead 2022-07-23 op <<<<<<< --- numbers
1747 38d61ead 2022-07-23 op 5
1748 38d61ead 2022-07-23 op 6
1749 38d61ead 2022-07-23 op ||||||| +++ numbers
1750 38d61ead 2022-07-23 op five
1751 38d61ead 2022-07-23 op =======
1752 38d61ead 2022-07-23 op five
1753 38d61ead 2022-07-23 op six
1754 38d61ead 2022-07-23 op >>>>>>> commit $commit_id
1755 38d61ead 2022-07-23 op 7
1756 38d61ead 2022-07-23 op 8
1757 38d61ead 2022-07-23 op 9
1758 38d61ead 2022-07-23 op 10
1759 38d61ead 2022-07-23 op EOF
1760 38d61ead 2022-07-23 op
1761 38d61ead 2022-07-23 op cmp -s $testroot/wt/numbers $testroot/wt/numbers.expected
1762 38d61ead 2022-07-23 op ret=$?
1763 38d61ead 2022-07-23 op if [ $ret -ne 0 ]; then
1764 38d61ead 2022-07-23 op diff -u $testroot/wt/numbers $testroot/wt/numbers.expected
1765 611e5fc2 2022-09-21 mark fi
1766 611e5fc2 2022-09-21 mark test_done $testroot $ret
1767 611e5fc2 2022-09-21 mark }
1768 611e5fc2 2022-09-21 mark
1769 611e5fc2 2022-09-21 mark test_patch_newfile_xbit_got_diff() {
1770 611e5fc2 2022-09-21 mark local testroot=`test_init patch_newfile_xbit`
1771 611e5fc2 2022-09-21 mark
1772 611e5fc2 2022-09-21 mark got checkout $testroot/repo $testroot/wt > /dev/null
1773 611e5fc2 2022-09-21 mark ret=$?
1774 611e5fc2 2022-09-21 mark if [ $ret -ne 0 ]; then
1775 611e5fc2 2022-09-21 mark test_done $testroot $ret
1776 611e5fc2 2022-09-21 mark return 1
1777 611e5fc2 2022-09-21 mark fi
1778 611e5fc2 2022-09-21 mark
1779 611e5fc2 2022-09-21 mark cat <<EOF > $testroot/wt/patch
1780 611e5fc2 2022-09-21 mark blob - /dev/null
1781 611e5fc2 2022-09-21 mark blob + abcdef0123456789abcdef012345678901234567 (mode 755)
1782 611e5fc2 2022-09-21 mark --- /dev/null
1783 611e5fc2 2022-09-21 mark +++ xfile
1784 611e5fc2 2022-09-21 mark @@ -0,0 +1,1 @@
1785 611e5fc2 2022-09-21 mark +xfile
1786 611e5fc2 2022-09-21 mark EOF
1787 611e5fc2 2022-09-21 mark
1788 611e5fc2 2022-09-21 mark (cd $testroot/wt && got patch patch) > /dev/null
1789 611e5fc2 2022-09-21 mark ret=$?
1790 611e5fc2 2022-09-21 mark if [ $ret -ne 0 ]; then
1791 611e5fc2 2022-09-21 mark test_done $testroot $ret
1792 611e5fc2 2022-09-21 mark return 1
1793 38d61ead 2022-07-23 op fi
1794 611e5fc2 2022-09-21 mark
1795 611e5fc2 2022-09-21 mark if [ ! -x $testroot/wt/xfile ]; then
1796 611e5fc2 2022-09-21 mark echo "failed to set xbit on newfile" >&2
1797 611e5fc2 2022-09-21 mark test_done $testroot 1
1798 611e5fc2 2022-09-21 mark return 1
1799 611e5fc2 2022-09-21 mark fi
1800 611e5fc2 2022-09-21 mark
1801 611e5fc2 2022-09-21 mark echo xfile > $testroot/wt/xfile.expected
1802 611e5fc2 2022-09-21 mark cmp -s $testroot/wt/xfile $testroot/wt/xfile.expected
1803 611e5fc2 2022-09-21 mark ret=$?
1804 611e5fc2 2022-09-21 mark if [ $ret -ne 0 ]; then
1805 611e5fc2 2022-09-21 mark echo "fail"
1806 611e5fc2 2022-09-21 mark diff -u $testroot/wt/xfile $testroot/wt/xfile.expected
1807 611e5fc2 2022-09-21 mark fi
1808 611e5fc2 2022-09-21 mark
1809 38d61ead 2022-07-23 op test_done $testroot $ret
1810 38d61ead 2022-07-23 op }
1811 38d61ead 2022-07-23 op
1812 611e5fc2 2022-09-21 mark test_patch_newfile_xbit_git_diff() {
1813 611e5fc2 2022-09-21 mark local testroot=`test_init patch_newfile_xbit`
1814 611e5fc2 2022-09-21 mark
1815 611e5fc2 2022-09-21 mark got checkout $testroot/repo $testroot/wt > /dev/null
1816 611e5fc2 2022-09-21 mark ret=$?
1817 611e5fc2 2022-09-21 mark if [ $ret -ne 0 ]; then
1818 611e5fc2 2022-09-21 mark test_done $testroot $ret
1819 611e5fc2 2022-09-21 mark return 1
1820 611e5fc2 2022-09-21 mark fi
1821 611e5fc2 2022-09-21 mark
1822 611e5fc2 2022-09-21 mark cat <<EOF > $testroot/wt/patch
1823 611e5fc2 2022-09-21 mark diff --git a/xfile b/xfile
1824 611e5fc2 2022-09-21 mark new file mode 100755
1825 611e5fc2 2022-09-21 mark index 00000000..abcdef01
1826 611e5fc2 2022-09-21 mark --- /dev/null
1827 611e5fc2 2022-09-21 mark +++ b/xfile
1828 611e5fc2 2022-09-21 mark @@ -0,0 +1,1 @@
1829 611e5fc2 2022-09-21 mark +xfile
1830 611e5fc2 2022-09-21 mark EOF
1831 611e5fc2 2022-09-21 mark
1832 611e5fc2 2022-09-21 mark (cd $testroot/wt && got patch patch) > /dev/null
1833 611e5fc2 2022-09-21 mark ret=$?
1834 611e5fc2 2022-09-21 mark if [ $ret -ne 0 ]; then
1835 611e5fc2 2022-09-21 mark test_done $testroot $ret
1836 611e5fc2 2022-09-21 mark return 1
1837 611e5fc2 2022-09-21 mark fi
1838 611e5fc2 2022-09-21 mark
1839 611e5fc2 2022-09-21 mark if [ ! -x $testroot/wt/xfile ]; then
1840 611e5fc2 2022-09-21 mark echo "failed to set xbit on newfile" >&2
1841 611e5fc2 2022-09-21 mark test_done $testroot 1
1842 611e5fc2 2022-09-21 mark return 1
1843 611e5fc2 2022-09-21 mark fi
1844 611e5fc2 2022-09-21 mark
1845 611e5fc2 2022-09-21 mark echo xfile > $testroot/wt/xfile.expected
1846 611e5fc2 2022-09-21 mark cmp -s $testroot/wt/xfile $testroot/wt/xfile.expected
1847 611e5fc2 2022-09-21 mark ret=$?
1848 611e5fc2 2022-09-21 mark if [ $ret -ne 0 ]; then
1849 611e5fc2 2022-09-21 mark echo "fail"
1850 611e5fc2 2022-09-21 mark diff -u $testroot/wt/xfile $testroot/wt/xfile.expected
1851 611e5fc2 2022-09-21 mark fi
1852 611e5fc2 2022-09-21 mark
1853 611e5fc2 2022-09-21 mark test_done $testroot $ret
1854 b2b3fce1 2022-10-29 op }
1855 b2b3fce1 2022-10-29 op
1856 b2b3fce1 2022-10-29 op test_patch_umask() {
1857 b2b3fce1 2022-10-29 op local testroot=`test_init patch_umask`
1858 b2b3fce1 2022-10-29 op
1859 b2b3fce1 2022-10-29 op got checkout "$testroot/repo" "$testroot/wt" >/dev/null
1860 b2b3fce1 2022-10-29 op
1861 b2b3fce1 2022-10-29 op cat <<EOF >$testroot/wt/patch
1862 b2b3fce1 2022-10-29 op --- alpha
1863 b2b3fce1 2022-10-29 op +++ alpha
1864 b2b3fce1 2022-10-29 op @@ -1 +1 @@
1865 b2b3fce1 2022-10-29 op -alpha
1866 b2b3fce1 2022-10-29 op +modified alpha
1867 b2b3fce1 2022-10-29 op EOF
1868 b2b3fce1 2022-10-29 op
1869 b2b3fce1 2022-10-29 op # using a subshell to avoid clobbering global umask
1870 b2b3fce1 2022-10-29 op (umask 077 && cd "$testroot/wt" && got patch <patch) >/dev/null
1871 b2b3fce1 2022-10-29 op ret=$?
1872 b2b3fce1 2022-10-29 op if [ $ret -ne 0 ]; then
1873 b2b3fce1 2022-10-29 op test_done "$testroot" $ret
1874 b2b3fce1 2022-10-29 op return 1
1875 b2b3fce1 2022-10-29 op fi
1876 b2b3fce1 2022-10-29 op
1877 b2b3fce1 2022-10-29 op if ! ls -l "$testroot/wt/alpha" | grep -q ^-rw-------; then
1878 b2b3fce1 2022-10-29 op echo "alpha is not 0600 after patch" >&2
1879 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/alpha" >&2
1880 b2b3fce1 2022-10-29 op test_done "$testroot" 1
1881 b2b3fce1 2022-10-29 op return 1
1882 b2b3fce1 2022-10-29 op fi
1883 b2b3fce1 2022-10-29 op
1884 b2b3fce1 2022-10-29 op test_done "$testroot" 0
1885 611e5fc2 2022-09-21 mark }
1886 684a9a6c 2022-12-31 op
1887 684a9a6c 2022-12-31 op test_patch_remove_binary_file() {
1888 684a9a6c 2022-12-31 op local testroot=`test_init patch_remove_binary_file`
1889 684a9a6c 2022-12-31 op
1890 684a9a6c 2022-12-31 op if ! got checkout $testroot/repo $testroot/wt >/dev/null; then
1891 684a9a6c 2022-12-31 op test_done $testroot $ret
1892 684a9a6c 2022-12-31 op return 1
1893 684a9a6c 2022-12-31 op fi
1894 684a9a6c 2022-12-31 op
1895 684a9a6c 2022-12-31 op dd if=/dev/zero of=$testroot/wt/x bs=1 count=16 2>/dev/null >&2
1896 684a9a6c 2022-12-31 op (cd $testroot/wt && got add x && got commit -m +x) >/dev/null
1897 684a9a6c 2022-12-31 op
1898 684a9a6c 2022-12-31 op (cd $testroot/wt && \
1899 684a9a6c 2022-12-31 op got branch demo && \
1900 684a9a6c 2022-12-31 op got rm x && \
1901 684a9a6c 2022-12-31 op got ci -m -x &&
1902 684a9a6c 2022-12-31 op got up -b master) >/dev/null
1903 684a9a6c 2022-12-31 op
1904 684a9a6c 2022-12-31 op echo 'D x' > $testroot/stdout.expected
1905 611e5fc2 2022-09-21 mark
1906 684a9a6c 2022-12-31 op (cd $testroot/wt && got log -c demo -l 1 -p >patch)
1907 684a9a6c 2022-12-31 op
1908 684a9a6c 2022-12-31 op (cd $testroot/wt && got patch <patch) > $testroot/stdout
1909 684a9a6c 2022-12-31 op if [ $? -ne 0 ]; then
1910 684a9a6c 2022-12-31 op echo 'patch failed' >&2
1911 684a9a6c 2022-12-31 op test_done $testroot 1
1912 684a9a6c 2022-12-31 op return 1
1913 684a9a6c 2022-12-31 op fi
1914 684a9a6c 2022-12-31 op
1915 684a9a6c 2022-12-31 op if ! cmp -s $testroot/stdout.expected $testroot/stdout; then
1916 684a9a6c 2022-12-31 op diff -u $testroot/stdout.expected $testroot/stdout
1917 684a9a6c 2022-12-31 op test_done $testroot 1
1918 684a9a6c 2022-12-31 op return 1
1919 684a9a6c 2022-12-31 op fi
1920 684a9a6c 2022-12-31 op
1921 684a9a6c 2022-12-31 op # try again using a git produced diff
1922 684a9a6c 2022-12-31 op (cd $testroot/wt && got revert x) >/dev/null
1923 684a9a6c 2022-12-31 op
1924 684a9a6c 2022-12-31 op (cd $testroot/repo && git show demo) >$testroot/wt/patch
1925 684a9a6c 2022-12-31 op
1926 684a9a6c 2022-12-31 op (cd $testroot/wt && got patch <patch) > $testroot/stdout
1927 684a9a6c 2022-12-31 op if [ $? -ne 0 ]; then
1928 684a9a6c 2022-12-31 op echo 'patch failed' >&2
1929 684a9a6c 2022-12-31 op test_done $testroot 1
1930 684a9a6c 2022-12-31 op return 1
1931 684a9a6c 2022-12-31 op fi
1932 684a9a6c 2022-12-31 op
1933 684a9a6c 2022-12-31 op if ! cmp -s $testroot/stdout.expected $testroot/stdout; then
1934 684a9a6c 2022-12-31 op diff -u $testroot/stdout.expected $testroot/stdout
1935 684a9a6c 2022-12-31 op test_done $testroot 1
1936 684a9a6c 2022-12-31 op return 1
1937 684a9a6c 2022-12-31 op fi
1938 684a9a6c 2022-12-31 op
1939 684a9a6c 2022-12-31 op # try again using a diff(1) style patch
1940 684a9a6c 2022-12-31 op (cd $testroot/wt && got revert x) >/dev/null
1941 684a9a6c 2022-12-31 op
1942 684a9a6c 2022-12-31 op echo "Binary files x and /dev/null differ" >$testroot/wt/patch
1943 684a9a6c 2022-12-31 op (cd $testroot/wt && got patch <patch) >$testroot/stdout
1944 684a9a6c 2022-12-31 op if [ $? -ne 0 ]; then
1945 684a9a6c 2022-12-31 op echo 'patch failed' >&2
1946 684a9a6c 2022-12-31 op test_done $testroot 1
1947 684a9a6c 2022-12-31 op return 1
1948 684a9a6c 2022-12-31 op fi
1949 684a9a6c 2022-12-31 op
1950 684a9a6c 2022-12-31 op if ! cmp -s $testroot/stdout.expected $testroot/stdout; then
1951 684a9a6c 2022-12-31 op diff -u $testroot/stdout.expected $testroot/stdout
1952 684a9a6c 2022-12-31 op test_done $testroot 1
1953 684a9a6c 2022-12-31 op return 1
1954 684a9a6c 2022-12-31 op fi
1955 684a9a6c 2022-12-31 op
1956 684a9a6c 2022-12-31 op test_done $testroot 0
1957 684a9a6c 2022-12-31 op }
1958 684a9a6c 2022-12-31 op
1959 e9ce266e 2022-03-07 op test_parseargs "$@"
1960 57b1c3f2 2022-08-01 op run_test test_patch_basic
1961 e9ce266e 2022-03-07 op run_test test_patch_dont_apply
1962 e9ce266e 2022-03-07 op run_test test_patch_malformed
1963 e9ce266e 2022-03-07 op run_test test_patch_no_patch
1964 e9ce266e 2022-03-07 op run_test test_patch_equals_for_context
1965 6e96b326 2022-03-12 op run_test test_patch_rename
1966 dbda770b 2022-03-13 op run_test test_patch_illegal_status
1967 899fcfdf 2022-03-13 op run_test test_patch_nop
1968 2be5e1a2 2022-03-16 op run_test test_patch_preserve_perm
1969 95d68340 2022-03-16 op run_test test_patch_create_dirs
1970 60aa1fa0 2022-03-17 op run_test test_patch_with_offset
1971 7a30b5cb 2022-03-20 op run_test test_patch_prefer_new_path
1972 b3c57ab2 2022-03-22 op run_test test_patch_no_newline
1973 9d6cabd5 2022-04-07 op run_test test_patch_strip
1974 a92a2042 2022-07-02 op run_test test_patch_whitespace
1975 ed3bff83 2022-04-23 op run_test test_patch_relative_paths
1976 15e1bda6 2022-04-23 op run_test test_patch_with_path_prefix
1977 15e1bda6 2022-04-23 op run_test test_patch_relpath_with_path_prefix
1978 bad961bf 2022-04-23 op run_test test_patch_reverse
1979 55e9459f 2022-06-19 op run_test test_patch_merge_simple
1980 db0dfdd7 2022-06-27 op run_test test_patch_merge_gitdiff
1981 5f56d41e 2022-07-28 op run_test test_patch_merge_base_provided
1982 55e9459f 2022-06-19 op run_test test_patch_merge_conflict
1983 55e9459f 2022-06-19 op run_test test_patch_merge_unknown_blob
1984 38d61ead 2022-07-23 op run_test test_patch_merge_reverse
1985 611e5fc2 2022-09-21 mark run_test test_patch_newfile_xbit_got_diff
1986 611e5fc2 2022-09-21 mark run_test test_patch_newfile_xbit_git_diff
1987 b2b3fce1 2022-10-29 op run_test test_patch_umask
1988 684a9a6c 2022-12-31 op run_test test_patch_remove_binary_file