Blame


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