3 069bbb86 2022-03-07 thomas # Copyright (c) 2022 Omar Polo <op@openbsd.org>
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.
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.
17 069bbb86 2022-03-07 thomas . ./common.sh
19 8d8dc2a3 2022-07-03 thomas test_patch_add_file() {
20 8d8dc2a3 2022-07-03 thomas local testroot=`test_init patch_add_file`
22 069bbb86 2022-03-07 thomas got checkout $testroot/repo $testroot/wt > /dev/null
24 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
25 069bbb86 2022-03-07 thomas test_done $testroot $ret
29 069bbb86 2022-03-07 thomas cat <<EOF > $testroot/wt/patch
30 069bbb86 2022-03-07 thomas --- /dev/null
32 8d8dc2a3 2022-07-03 thomas @@ -0,0 +5,5 @@
40 069bbb86 2022-03-07 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
42 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
43 069bbb86 2022-03-07 thomas test_done $testroot $ret
47 069bbb86 2022-03-07 thomas echo "A eta" > $testroot/stdout.expected
48 069bbb86 2022-03-07 thomas cmp -s $testroot/stdout.expected $testroot/stdout
50 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
51 069bbb86 2022-03-07 thomas diff -u $testroot/stdout.expected $testroot/stdout
52 069bbb86 2022-03-07 thomas test_done $testroot $ret
56 8d8dc2a3 2022-07-03 thomas jot 5 > $testroot/wt/eta.expected
57 069bbb86 2022-03-07 thomas cmp -s $testroot/wt/eta.expected $testroot/wt/eta
59 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
60 069bbb86 2022-03-07 thomas diff -u $testroot/wt/eta.expected $testroot/wt/eta
62 069bbb86 2022-03-07 thomas test_done $testroot $ret
65 762e07b8 2022-07-03 thomas test_patch_rm_file() {
66 762e07b8 2022-07-03 thomas local testroot=`test_init patch_rm_file`
68 069bbb86 2022-03-07 thomas got checkout $testroot/repo $testroot/wt > /dev/null
70 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
71 069bbb86 2022-03-07 thomas test_done $testroot $ret
75 069bbb86 2022-03-07 thomas cat <<EOF > $testroot/wt/patch
77 069bbb86 2022-03-07 thomas +++ /dev/null
78 069bbb86 2022-03-07 thomas @@ -1 +0,0 @@
82 069bbb86 2022-03-07 thomas echo "D alpha" > $testroot/stdout.expected
84 069bbb86 2022-03-07 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
86 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
87 069bbb86 2022-03-07 thomas test_done $testroot $ret
91 069bbb86 2022-03-07 thomas cmp -s $testroot/stdout.expected $testroot/stdout
93 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
94 069bbb86 2022-03-07 thomas diff -u $testroot/stdout.expected $testroot/stdout
95 069bbb86 2022-03-07 thomas test_done $testroot $ret
99 069bbb86 2022-03-07 thomas if [ -f $testroot/wt/alpha ]; then
101 069bbb86 2022-03-07 thomas echo "alpha still exists!"
103 069bbb86 2022-03-07 thomas test_done $testroot $ret
106 069bbb86 2022-03-07 thomas test_patch_simple_edit_file() {
107 069bbb86 2022-03-07 thomas local testroot=`test_init patch_simple_edit_file`
109 069bbb86 2022-03-07 thomas got checkout $testroot/repo $testroot/wt > /dev/null
111 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
112 069bbb86 2022-03-07 thomas test_done $testroot $ret
116 069bbb86 2022-03-07 thomas cat <<EOF > $testroot/wt/patch
117 069bbb86 2022-03-07 thomas --- alpha
118 069bbb86 2022-03-07 thomas +++ alpha
119 069bbb86 2022-03-07 thomas @@ -1 +1 @@
121 069bbb86 2022-03-07 thomas +alpha is my favourite character
124 069bbb86 2022-03-07 thomas echo "M alpha" > $testroot/stdout.expected
126 069bbb86 2022-03-07 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
128 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
129 069bbb86 2022-03-07 thomas test_done $testroot $ret
133 069bbb86 2022-03-07 thomas cmp -s $testroot/stdout.expected $testroot/stdout
135 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
136 069bbb86 2022-03-07 thomas diff -u $testroot/stdout.expected $testroot/stdout
137 069bbb86 2022-03-07 thomas test_done $testroot $ret
141 069bbb86 2022-03-07 thomas echo 'alpha is my favourite character' > $testroot/wt/alpha.expected
142 069bbb86 2022-03-07 thomas cmp -s $testroot/wt/alpha.expected $testroot/wt/alpha
144 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
145 069bbb86 2022-03-07 thomas diff -u $testroot/wt/alpha.expected $testroot/wt/alpha
147 069bbb86 2022-03-07 thomas test_done $testroot $ret
150 069bbb86 2022-03-07 thomas test_patch_prepend_line() {
151 069bbb86 2022-03-07 thomas local testroot=`test_init patch_prepend_line`
153 069bbb86 2022-03-07 thomas got checkout $testroot/repo $testroot/wt > /dev/null
155 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
156 069bbb86 2022-03-07 thomas test_done $testroot $ret
160 069bbb86 2022-03-07 thomas cat <<EOF > $testroot/wt/patch
161 069bbb86 2022-03-07 thomas --- alpha
162 069bbb86 2022-03-07 thomas +++ alpha
163 069bbb86 2022-03-07 thomas @@ -1 +1,2 @@
164 069bbb86 2022-03-07 thomas +hatsuseno
168 069bbb86 2022-03-07 thomas echo "M alpha" > $testroot/stdout.expected
170 069bbb86 2022-03-07 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
172 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
173 069bbb86 2022-03-07 thomas test_done $testroot $ret
177 069bbb86 2022-03-07 thomas cmp -s $testroot/stdout.expected $testroot/stdout
179 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
180 069bbb86 2022-03-07 thomas diff -u $testroot/stdout.expected $testroot/stdout
181 069bbb86 2022-03-07 thomas test_done $testroot $ret
185 069bbb86 2022-03-07 thomas echo hatsuseno > $testroot/wt/alpha.expected
186 069bbb86 2022-03-07 thomas echo alpha >> $testroot/wt/alpha.expected
187 069bbb86 2022-03-07 thomas cmp -s $testroot/wt/alpha.expected $testroot/wt/alpha
189 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
190 069bbb86 2022-03-07 thomas diff -u $testroot/wt/alpha.expected $testroot/wt/alpha
192 069bbb86 2022-03-07 thomas test_done $testroot $ret
195 069bbb86 2022-03-07 thomas test_patch_replace_line() {
196 069bbb86 2022-03-07 thomas local testroot=`test_init patch_replace_line`
198 069bbb86 2022-03-07 thomas got checkout $testroot/repo $testroot/wt > /dev/null
200 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
201 069bbb86 2022-03-07 thomas test_done $testroot $ret
205 069bbb86 2022-03-07 thomas jot 10 > $testroot/wt/numbers
206 069bbb86 2022-03-07 thomas (cd $testroot/wt/ && got add numbers && got ci -m 'add numbers') \
207 069bbb86 2022-03-07 thomas >/dev/null
209 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
210 069bbb86 2022-03-07 thomas test_done $testroot $ret
214 069bbb86 2022-03-07 thomas cat <<EOF > $testroot/wt/patch
215 069bbb86 2022-03-07 thomas --- numbers
216 069bbb86 2022-03-07 thomas +++ numbers
217 069bbb86 2022-03-07 thomas @@ -3,7 +3,7 @@
228 069bbb86 2022-03-07 thomas echo "M numbers" > $testroot/stdout.expected
230 069bbb86 2022-03-07 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
232 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
233 069bbb86 2022-03-07 thomas test_done $testroot $ret
237 069bbb86 2022-03-07 thomas cmp -s $testroot/stdout.expected $testroot/stdout
239 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
240 069bbb86 2022-03-07 thomas diff -u $testroot/stdout.expected $testroot/stdout
241 069bbb86 2022-03-07 thomas test_done $testroot $ret
245 069bbb86 2022-03-07 thomas jot 10 | sed 's/6/foo/' > $testroot/wt/numbers.expected
246 069bbb86 2022-03-07 thomas cmp -s $testroot/wt/numbers.expected $testroot/wt/numbers
248 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
249 069bbb86 2022-03-07 thomas diff -u $testroot/wt/numbers.expected $testroot/wt/numbers
251 069bbb86 2022-03-07 thomas test_done $testroot $ret
254 069bbb86 2022-03-07 thomas test_patch_multiple_hunks() {
255 02e4f0d8 2022-03-08 thomas local testroot=`test_init patch_replace_multiple_hunks`
257 069bbb86 2022-03-07 thomas got checkout $testroot/repo $testroot/wt > /dev/null
259 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
260 069bbb86 2022-03-07 thomas test_done $testroot $ret
264 069bbb86 2022-03-07 thomas jot 100 > $testroot/wt/numbers
265 069bbb86 2022-03-07 thomas (cd $testroot/wt/ && got add numbers && got ci -m 'add numbers') \
266 069bbb86 2022-03-07 thomas >/dev/null
268 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
269 069bbb86 2022-03-07 thomas test_done $testroot $ret
273 069bbb86 2022-03-07 thomas cat <<EOF > $testroot/wt/patch
274 069bbb86 2022-03-07 thomas --- numbers
275 069bbb86 2022-03-07 thomas +++ numbers
276 069bbb86 2022-03-07 thomas @@ -3,7 +3,7 @@
285 069bbb86 2022-03-07 thomas @@ -57,7 +57,7 @@
294 069bbb86 2022-03-07 thomas @@ -98,3 +98,6 @@
303 069bbb86 2022-03-07 thomas echo "M numbers" > $testroot/stdout.expected
305 069bbb86 2022-03-07 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
307 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
308 069bbb86 2022-03-07 thomas test_done $testroot $ret
312 069bbb86 2022-03-07 thomas cmp -s $testroot/stdout.expected $testroot/stdout
314 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
315 069bbb86 2022-03-07 thomas diff -u $testroot/stdout.expected $testroot/stdout
316 069bbb86 2022-03-07 thomas test_done $testroot $ret
320 069bbb86 2022-03-07 thomas jot 100 | sed -e 's/^6$/foo/' -e 's/^60$/foo foo/' \
321 069bbb86 2022-03-07 thomas > $testroot/wt/numbers.expected
322 069bbb86 2022-03-07 thomas echo "101" >> $testroot/wt/numbers.expected
323 069bbb86 2022-03-07 thomas echo "102" >> $testroot/wt/numbers.expected
324 069bbb86 2022-03-07 thomas echo "..." >> $testroot/wt/numbers.expected
326 069bbb86 2022-03-07 thomas cmp -s $testroot/wt/numbers.expected $testroot/wt/numbers
328 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
329 069bbb86 2022-03-07 thomas diff -u $testroot/wt/numbers.expected $testroot/wt/numbers
331 069bbb86 2022-03-07 thomas test_done $testroot $ret
334 069bbb86 2022-03-07 thomas test_patch_multiple_files() {
335 069bbb86 2022-03-07 thomas local testroot=`test_init patch_multiple_files`
337 069bbb86 2022-03-07 thomas got checkout $testroot/repo $testroot/wt > /dev/null
339 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
340 069bbb86 2022-03-07 thomas test_done $testroot $ret
344 069bbb86 2022-03-07 thomas cat <<EOF > $testroot/wt/patch
345 069bbb86 2022-03-07 thomas --- alpha Mon Mar 7 19:02:07 2022
346 069bbb86 2022-03-07 thomas +++ alpha Mon Mar 7 19:01:53 2022
347 069bbb86 2022-03-07 thomas @@ -1 +1,3 @@
350 069bbb86 2022-03-07 thomas +available
351 069bbb86 2022-03-07 thomas --- beta Mon Mar 7 19:02:11 2022
352 069bbb86 2022-03-07 thomas +++ beta Mon Mar 7 19:01:46 2022
353 069bbb86 2022-03-07 thomas @@ -1 +1,3 @@
356 069bbb86 2022-03-07 thomas +improved
357 069bbb86 2022-03-07 thomas --- gamma/delta Mon Mar 7 19:02:17 2022
358 069bbb86 2022-03-07 thomas +++ gamma/delta Mon Mar 7 19:01:37 2022
359 069bbb86 2022-03-07 thomas @@ -1 +1 @@
361 069bbb86 2022-03-07 thomas +delta new
364 069bbb86 2022-03-07 thomas echo "M alpha" > $testroot/stdout.expected
365 069bbb86 2022-03-07 thomas echo "M beta" >> $testroot/stdout.expected
366 069bbb86 2022-03-07 thomas echo "M gamma/delta" >> $testroot/stdout.expected
368 069bbb86 2022-03-07 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
370 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
371 02e4f0d8 2022-03-08 thomas test_done $testroot $ret
375 069bbb86 2022-03-07 thomas cmp -s $testroot/stdout.expected $testroot/stdout
377 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
378 069bbb86 2022-03-07 thomas diff -u $testroot/stdout.expected $testroot/stdout
379 069bbb86 2022-03-07 thomas test_done $testroot $ret
383 069bbb86 2022-03-07 thomas printf 'new\nalpha\navailable\n' > $testroot/wt/alpha.expected
384 069bbb86 2022-03-07 thomas printf 'beta\nwas\nimproved\n' > $testroot/wt/beta.expected
385 069bbb86 2022-03-07 thomas printf 'delta new\n' > $testroot/wt/gamma/delta.expected
387 069bbb86 2022-03-07 thomas for f in alpha beta gamma/delta; do
388 069bbb86 2022-03-07 thomas cmp -s $testroot/wt/$f.expected $testroot/wt/$f
390 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
391 069bbb86 2022-03-07 thomas diff -u $testroot/wt/$f.expected $testroot/wt/$f
392 069bbb86 2022-03-07 thomas test_done $testroot $ret
397 069bbb86 2022-03-07 thomas test_done $testroot 0
400 069bbb86 2022-03-07 thomas test_patch_dont_apply() {
401 069bbb86 2022-03-07 thomas local testroot=`test_init patch_dont_apply`
403 069bbb86 2022-03-07 thomas got checkout $testroot/repo $testroot/wt > /dev/null
405 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
406 069bbb86 2022-03-07 thomas test_done $testroot $ret
410 7dd42450 2022-03-13 thomas jot 100 > $testroot/wt/numbers
411 7dd42450 2022-03-13 thomas (cd $testroot/wt && got add numbers && got commit -m 'add numbers') \
412 7dd42450 2022-03-13 thomas >/dev/null
414 7dd42450 2022-03-13 thomas if [ $ret -ne 0 ]; then
415 7dd42450 2022-03-13 thomas test_done $testroot $ret
419 7dd42450 2022-03-13 thomas cat <<EOF > $testroot/wt/patch
420 49114f01 2022-03-22 thomas --- alpha
421 49114f01 2022-03-22 thomas +++ alpha
422 49114f01 2022-03-22 thomas @@ -1 +1,2 @@
423 49114f01 2022-03-22 thomas +hatsuseno
424 49114f01 2022-03-22 thomas alpha something
425 7dd42450 2022-03-13 thomas --- numbers
426 7dd42450 2022-03-13 thomas +++ /dev/null
427 7dd42450 2022-03-13 thomas @@ -1,9 +0,0 @@
439 49114f01 2022-03-22 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout 2> /dev/null
441 7dd42450 2022-03-13 thomas if [ $ret -eq 0 ]; then # should fail
442 7dd42450 2022-03-13 thomas test_done $testroot 1
446 49114f01 2022-03-22 thomas cat <<EOF > $testroot/stdout.expected
448 49114f01 2022-03-22 thomas @@ -1,1 +1,2 @@ hunk failed to apply
449 49114f01 2022-03-22 thomas # numbers
450 49114f01 2022-03-22 thomas @@ -1,9 +0,0 @@ hunk failed to apply
453 49114f01 2022-03-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
455 7dd42450 2022-03-13 thomas if [ $ret -ne 0 ]; then
456 49114f01 2022-03-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
458 069bbb86 2022-03-07 thomas test_done $testroot $ret
461 069bbb86 2022-03-07 thomas test_patch_malformed() {
462 069bbb86 2022-03-07 thomas local testroot=`test_init patch_malformed`
464 069bbb86 2022-03-07 thomas got checkout $testroot/repo $testroot/wt > /dev/null
466 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
467 069bbb86 2022-03-07 thomas test_done $testroot $ret
471 069bbb86 2022-03-07 thomas # missing "@@"
472 069bbb86 2022-03-07 thomas cat <<EOF > $testroot/wt/patch
473 069bbb86 2022-03-07 thomas --- alpha
474 069bbb86 2022-03-07 thomas +++ alpha
475 069bbb86 2022-03-07 thomas @@ -1 +1,2
476 069bbb86 2022-03-07 thomas +hatsuseno
480 069bbb86 2022-03-07 thomas echo -n > $testroot/stdout.expected
481 069bbb86 2022-03-07 thomas echo "got: malformed patch" > $testroot/stderr.expected
483 069bbb86 2022-03-07 thomas (cd $testroot/wt && got patch patch) \
484 069bbb86 2022-03-07 thomas > $testroot/stdout \
485 069bbb86 2022-03-07 thomas 2> $testroot/stderr
487 10cdd9aa 2022-03-08 thomas if [ $ret -eq 0 ]; then
488 069bbb86 2022-03-07 thomas echo "got managed to apply an invalid patch"
489 069bbb86 2022-03-07 thomas test_done $testroot 1
493 069bbb86 2022-03-07 thomas cmp -s $testroot/stdout.expected $testroot/stdout
495 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
496 069bbb86 2022-03-07 thomas diff -u $testroot/stdout.expected $testroot/stdout
497 069bbb86 2022-03-07 thomas test_done $testroot $ret
501 069bbb86 2022-03-07 thomas cmp -s $testroot/stderr.expected $testroot/stderr
503 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
504 069bbb86 2022-03-07 thomas diff -u $testroot/stderr.expected $testroot/stderr
505 069bbb86 2022-03-07 thomas test_done $testroot $ret
509 069bbb86 2022-03-07 thomas # wrong first character
510 069bbb86 2022-03-07 thomas cat <<EOF > $testroot/wt/patch
511 069bbb86 2022-03-07 thomas --- alpha
512 069bbb86 2022-03-07 thomas +++ alpha
513 069bbb86 2022-03-07 thomas @@ -1 +1,2 @@
514 069bbb86 2022-03-07 thomas +hatsuseno
518 88c260f4 2022-05-14 thomas (cd $testroot/wt && got patch patch) \
519 88c260f4 2022-05-14 thomas > $testroot/stdout \
520 88c260f4 2022-05-14 thomas 2> $testroot/stderr
522 88c260f4 2022-05-14 thomas if [ $ret -eq 0 ]; then
523 88c260f4 2022-05-14 thomas echo "got managed to apply an invalid patch"
524 88c260f4 2022-05-14 thomas test_done $testroot 1
528 88c260f4 2022-05-14 thomas cmp -s $testroot/stdout.expected $testroot/stdout
530 88c260f4 2022-05-14 thomas if [ $ret -ne 0 ]; then
531 88c260f4 2022-05-14 thomas diff -u $testroot/stdout.expected $testroot/stdout
532 88c260f4 2022-05-14 thomas test_done $testroot $ret
536 88c260f4 2022-05-14 thomas cmp -s $testroot/stderr.expected $testroot/stderr
538 88c260f4 2022-05-14 thomas if [ $ret -ne 0 ]; then
539 88c260f4 2022-05-14 thomas diff -u $testroot/stderr.expected $testroot/stderr
540 88c260f4 2022-05-14 thomas test_done $testroot $ret
544 88c260f4 2022-05-14 thomas # empty hunk
545 88c260f4 2022-05-14 thomas cat <<EOF > $testroot/wt/patch
546 88c260f4 2022-05-14 thomas diff --git a/alpha b/iota
547 88c260f4 2022-05-14 thomas --- a/alpha
548 88c260f4 2022-05-14 thomas +++ b/iota
549 88c260f4 2022-05-14 thomas @@ -0,0 +0,0 @@
552 069bbb86 2022-03-07 thomas (cd $testroot/wt && got patch patch) \
553 069bbb86 2022-03-07 thomas > $testroot/stdout \
554 069bbb86 2022-03-07 thomas 2> $testroot/stderr
556 10cdd9aa 2022-03-08 thomas if [ $ret -eq 0 ]; then
557 069bbb86 2022-03-07 thomas echo "got managed to apply an invalid patch"
558 069bbb86 2022-03-07 thomas test_done $testroot 1
562 069bbb86 2022-03-07 thomas cmp -s $testroot/stdout.expected $testroot/stdout
564 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
565 069bbb86 2022-03-07 thomas diff -u $testroot/stdout.expected $testroot/stdout
566 069bbb86 2022-03-07 thomas test_done $testroot $ret
570 069bbb86 2022-03-07 thomas cmp -s $testroot/stderr.expected $testroot/stderr
572 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
573 069bbb86 2022-03-07 thomas diff -u $testroot/stderr.expected $testroot/stderr
574 069bbb86 2022-03-07 thomas test_done $testroot $ret
578 069bbb86 2022-03-07 thomas test_done $testroot $ret
581 069bbb86 2022-03-07 thomas test_patch_no_patch() {
582 069bbb86 2022-03-07 thomas local testroot=`test_init patch_no_patch`
584 069bbb86 2022-03-07 thomas got checkout $testroot/repo $testroot/wt > /dev/null
586 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
587 069bbb86 2022-03-07 thomas test_done $testroot $ret
591 069bbb86 2022-03-07 thomas cat <<EOF > $testroot/wt/patch
592 069bbb86 2022-03-07 thomas hello world!
595 069bbb86 2022-03-07 thomas some other nonsense
598 069bbb86 2022-03-07 thomas there's no patch in here!
601 069bbb86 2022-03-07 thomas echo -n > $testroot/stdout.expected
602 069bbb86 2022-03-07 thomas echo "got: no patch found" > $testroot/stderr.expected
604 069bbb86 2022-03-07 thomas (cd $testroot/wt && got patch patch) \
605 069bbb86 2022-03-07 thomas > $testroot/stdout \
606 069bbb86 2022-03-07 thomas 2> $testroot/stderr
608 10cdd9aa 2022-03-08 thomas if [ $ret -eq 0 ]; then # should fail
609 069bbb86 2022-03-07 thomas test_done $testroot 1
613 069bbb86 2022-03-07 thomas cmp -s $testroot/stdout.expected $testroot/stdout
615 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
616 069bbb86 2022-03-07 thomas diff -u $testroot/stdout.expected $testroot/stdout
617 069bbb86 2022-03-07 thomas test_done $testroot $ret
621 069bbb86 2022-03-07 thomas cmp -s $testroot/stderr.expected $testroot/stderr
623 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
624 069bbb86 2022-03-07 thomas diff -u $testroot/stderr.expected $testroot/stderr
625 069bbb86 2022-03-07 thomas test_done $testroot $ret
629 069bbb86 2022-03-07 thomas test_done $testroot $ret
632 069bbb86 2022-03-07 thomas test_patch_equals_for_context() {
633 9a49df74 2022-04-23 thomas local testroot=`test_init patch_equals_for_context`
635 069bbb86 2022-03-07 thomas got checkout $testroot/repo $testroot/wt > /dev/null
637 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
638 069bbb86 2022-03-07 thomas test_done $testroot $ret
642 069bbb86 2022-03-07 thomas cat <<EOF > $testroot/wt/patch
643 069bbb86 2022-03-07 thomas --- alpha
644 069bbb86 2022-03-07 thomas +++ alpha
645 069bbb86 2022-03-07 thomas @@ -1 +1,2 @@
646 069bbb86 2022-03-07 thomas +hatsuseno
650 069bbb86 2022-03-07 thomas echo "M alpha" > $testroot/stdout.expected
652 069bbb86 2022-03-07 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
654 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
655 069bbb86 2022-03-07 thomas test_done $testroot $ret
659 069bbb86 2022-03-07 thomas cmp -s $testroot/stdout.expected $testroot/stdout
661 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
662 069bbb86 2022-03-07 thomas diff -u $testroot/stdout.expected $testroot/stdout
663 069bbb86 2022-03-07 thomas test_done $testroot $ret
667 069bbb86 2022-03-07 thomas echo hatsuseno > $testroot/wt/alpha.expected
668 069bbb86 2022-03-07 thomas echo alpha >> $testroot/wt/alpha.expected
669 069bbb86 2022-03-07 thomas cmp -s $testroot/wt/alpha.expected $testroot/wt/alpha
671 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
672 069bbb86 2022-03-07 thomas diff -u $testroot/wt/alpha.expected $testroot/wt/alpha
674 069bbb86 2022-03-07 thomas test_done $testroot $ret
677 bb2ad8ff 2022-03-13 thomas test_patch_rename() {
678 bb2ad8ff 2022-03-13 thomas local testroot=`test_init patch_rename`
680 bb2ad8ff 2022-03-13 thomas got checkout $testroot/repo $testroot/wt > /dev/null
682 bb2ad8ff 2022-03-13 thomas if [ $ret -ne 0 ]; then
683 bb2ad8ff 2022-03-13 thomas test_done $testroot $ret
687 bb2ad8ff 2022-03-13 thomas cat <<EOF > $testroot/wt/patch
688 8afe1f71 2022-05-12 thomas diff --git a/beta b/iota
689 8afe1f71 2022-05-12 thomas similarity index 100%
690 8afe1f71 2022-05-12 thomas rename from beta
691 8afe1f71 2022-05-12 thomas rename to iota
692 be53ddb1 2022-03-22 thomas diff --git a/alpha b/eta
693 be53ddb1 2022-03-22 thomas --- a/alpha
694 be53ddb1 2022-03-22 thomas +++ b/eta
695 8afe1f71 2022-05-12 thomas @@ -1 +1 @@
700 8afe1f71 2022-05-12 thomas echo 'D beta' > $testroot/stdout.expected
701 8afe1f71 2022-05-12 thomas echo 'A iota' >> $testroot/stdout.expected
702 8afe1f71 2022-05-12 thomas echo 'D alpha' >> $testroot/stdout.expected
703 8afe1f71 2022-05-12 thomas echo 'A eta' >> $testroot/stdout.expected
705 bb2ad8ff 2022-03-13 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
707 bb2ad8ff 2022-03-13 thomas if [ $ret -ne 0 ]; then
708 bb2ad8ff 2022-03-13 thomas test_done $testroot $ret
712 bb2ad8ff 2022-03-13 thomas cmp -s $testroot/stdout.expected $testroot/stdout
714 bb2ad8ff 2022-03-13 thomas if [ $ret -ne 0 ]; then
715 bb2ad8ff 2022-03-13 thomas diff -u $testroot/stdout.expected $testroot/stdout
716 bb2ad8ff 2022-03-13 thomas test_done $testroot $ret
720 8afe1f71 2022-05-12 thomas if [ -f $testroot/wt/alpha -o -f $testroot/wt/beta ]; then
721 8afe1f71 2022-05-12 thomas echo "alpha or beta were not removed" >&2
722 bb2ad8ff 2022-03-13 thomas test_done $testroot 1
725 8afe1f71 2022-05-12 thomas if [ ! -f $testroot/wt/iota -o ! -f $testroot/wt/eta ]; then
726 8afe1f71 2022-05-12 thomas echo "iota or eta were not created" >&2
727 bb2ad8ff 2022-03-13 thomas test_done $testroot 1
731 8afe1f71 2022-05-12 thomas echo beta > $testroot/wt/iota.expected
732 8afe1f71 2022-05-12 thomas cmp -s $testroot/wt/iota.expected $testroot/wt/iota
734 bb2ad8ff 2022-03-13 thomas if [ $ret -ne 0 ]; then
735 8afe1f71 2022-05-12 thomas diff -u $testroot/wt/iota.expected $testroot/wt/iota
736 bb2ad8ff 2022-03-13 thomas test_done $testroot $ret
740 8afe1f71 2022-05-12 thomas echo eta > $testroot/wt/eta.expected
741 8afe1f71 2022-05-12 thomas cmp -s $testroot/wt/eta.expected $testroot/wt/eta
743 bb2ad8ff 2022-03-13 thomas if [ $ret -ne 0 ]; then
744 8afe1f71 2022-05-12 thomas diff -u $testroot/wt/eta.expected $testroot/wt/eta
745 bb2ad8ff 2022-03-13 thomas test_done $testroot $ret
749 bb2ad8ff 2022-03-13 thomas test_done $testroot $ret
752 10e55613 2022-03-22 thomas test_patch_illegal_status() {
753 10e55613 2022-03-22 thomas local testroot=`test_init patch_illegal_status`
755 10e55613 2022-03-22 thomas got checkout $testroot/repo $testroot/wt > /dev/null
757 10e55613 2022-03-22 thomas if [ $ret -ne 0 ]; then
758 10e55613 2022-03-22 thomas test_done $testroot $ret
762 49114f01 2022-03-22 thomas # try to patch an obstructed file, add a versioned one, edit a
763 49114f01 2022-03-22 thomas # non existent file and an unversioned one, and remove a
764 49114f01 2022-03-22 thomas # non existent file.
765 10e55613 2022-03-22 thomas cat <<EOF > $testroot/wt/patch
766 49114f01 2022-03-22 thomas --- alpha
767 49114f01 2022-03-22 thomas +++ alpha
768 49114f01 2022-03-22 thomas @@ -1 +1,2 @@
770 49114f01 2022-03-22 thomas +was edited
771 49114f01 2022-03-22 thomas --- /dev/null
773 49114f01 2022-03-22 thomas @@ -0,0 +1 @@
777 10e55613 2022-03-22 thomas @@ -1 +1 @@
780 49114f01 2022-03-22 thomas --- kappa
781 49114f01 2022-03-22 thomas +++ kappa
782 49114f01 2022-03-22 thomas @@ -1 +1 @@
785 49114f01 2022-03-22 thomas --- lambda
786 49114f01 2022-03-22 thomas +++ /dev/null
787 49114f01 2022-03-22 thomas @@ -1 +0,0 @@
791 49114f01 2022-03-22 thomas echo kappa > $testroot/wt/kappa
792 10e55613 2022-03-22 thomas rm $testroot/wt/alpha
793 10e55613 2022-03-22 thomas mkdir $testroot/wt/alpha
795 49114f01 2022-03-22 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout \
796 10e55613 2022-03-22 thomas 2> $testroot/stderr
798 10e55613 2022-03-22 thomas if [ $ret -eq 0 ]; then
799 10e55613 2022-03-22 thomas echo "edited a missing file" >&2
800 4e2bdb0d 2022-06-13 thomas test_done $testroot 1
804 49114f01 2022-03-22 thomas cat <<EOF > $testroot/stdout.expected
812 49114f01 2022-03-22 thomas cat <<EOF > $testroot/stderr.expected
813 49114f01 2022-03-22 thomas got: alpha: file has unexpected status
814 49114f01 2022-03-22 thomas got: beta: file has unexpected status
815 49114f01 2022-03-22 thomas got: iota: No such file or directory
816 49114f01 2022-03-22 thomas got: kappa: file has unexpected status
817 49114f01 2022-03-22 thomas got: lambda: No such file or directory
818 49114f01 2022-03-22 thomas got: patch failed to apply
821 49114f01 2022-03-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
823 49114f01 2022-03-22 thomas if [ $ret -ne 0 ]; then
824 49114f01 2022-03-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
825 10e55613 2022-03-22 thomas test_done $testroot $ret
829 10e55613 2022-03-22 thomas cmp -s $testroot/stderr.expected $testroot/stderr
831 49114f01 2022-03-22 thomas if [ $ret -ne 0 ]; then
832 10e55613 2022-03-22 thomas diff -u $testroot/stderr.expected $testroot/stderr
833 814624e7 2022-03-22 thomas test_done $testroot $ret
837 814624e7 2022-03-22 thomas (cd $testroot/wt && got status) > $testroot/stdout
838 814624e7 2022-03-22 thomas cat <<EOF > $testroot/stdout.expected
844 814624e7 2022-03-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
846 814624e7 2022-03-22 thomas if [ $ret -ne 0 ]; then
847 814624e7 2022-03-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
849 eaf99875 2022-03-22 thomas test_done $testroot $ret
852 eaf99875 2022-03-22 thomas test_patch_nop() {
853 eaf99875 2022-03-22 thomas local testroot=`test_init patch_nop`
855 eaf99875 2022-03-22 thomas got checkout $testroot/repo $testroot/wt > /dev/null
857 eaf99875 2022-03-22 thomas if [ $ret -ne 0 ]; then
858 eaf99875 2022-03-22 thomas test_done $testroot $ret
862 eaf99875 2022-03-22 thomas cat <<EOF > $testroot/wt/patch
863 eaf99875 2022-03-22 thomas --- alpha
864 eaf99875 2022-03-22 thomas +++ alpha
865 eaf99875 2022-03-22 thomas @@ -1 +1 @@
867 eaf99875 2022-03-22 thomas +cafe alpha
869 eaf99875 2022-03-22 thomas +++ /dev/null
870 eaf99875 2022-03-22 thomas @@ -1 +0,0 @@
872 be53ddb1 2022-03-22 thomas diff --git a/gamma/delta b/gamma/delta.new
873 eaf99875 2022-03-22 thomas --- gamma/delta
874 eaf99875 2022-03-22 thomas +++ gamma/delta.new
875 eaf99875 2022-03-22 thomas @@ -1 +1 @@
877 eaf99875 2022-03-22 thomas +delta updated and renamed!
880 eaf99875 2022-03-22 thomas (cd $testroot/wt && got patch -n patch)
882 eaf99875 2022-03-22 thomas if [ $ret -ne 0 ]; then
883 eaf99875 2022-03-22 thomas test_done $testroot $ret
887 eaf99875 2022-03-22 thomas # remove the patch to avoid the ? entry
888 eaf99875 2022-03-22 thomas rm $testroot/wt/patch
890 eaf99875 2022-03-22 thomas (cd $testroot/wt && got status) > $testroot/stdout
892 eaf99875 2022-03-22 thomas if [ $ret -ne 0 ]; then
893 eaf99875 2022-03-22 thomas test_done $testroot $ret
897 eaf99875 2022-03-22 thomas echo -n > $testroot/stdout.expected
898 eaf99875 2022-03-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
900 eaf99875 2022-03-22 thomas if [ $ret -ne 0 ]; then
901 eaf99875 2022-03-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
903 10e55613 2022-03-22 thomas test_done $testroot $ret
906 da09d8ed 2022-03-22 thomas test_patch_preserve_perm() {
907 da09d8ed 2022-03-22 thomas local testroot=`test_init patch_preserve_perm`
909 da09d8ed 2022-03-22 thomas got checkout $testroot/repo $testroot/wt > /dev/null
911 da09d8ed 2022-03-22 thomas if [ $ret -ne 0 ]; then
912 da09d8ed 2022-03-22 thomas test_done $testroot $ret
916 da09d8ed 2022-03-22 thomas chmod +x $testroot/wt/alpha
917 da09d8ed 2022-03-22 thomas (cd $testroot/wt && got commit -m 'alpha executable') > /dev/null
919 da09d8ed 2022-03-22 thomas if [ $ret -ne 0 ]; then
920 da09d8ed 2022-03-22 thomas test_done $testroot $ret
924 da09d8ed 2022-03-22 thomas cat <<EOF > $testroot/wt/patch
925 da09d8ed 2022-03-22 thomas --- alpha
926 da09d8ed 2022-03-22 thomas +++ alpha
927 da09d8ed 2022-03-22 thomas @@ -1 +1,2 @@
929 da09d8ed 2022-03-22 thomas +was edited
932 da09d8ed 2022-03-22 thomas (cd $testroot/wt && got patch patch) > /dev/null
934 da09d8ed 2022-03-22 thomas if [ $ret -ne 0 ]; then
935 da09d8ed 2022-03-22 thomas test_done $testroot $ret
939 da09d8ed 2022-03-22 thomas if [ ! -x $testroot/wt/alpha ]; then
940 da09d8ed 2022-03-22 thomas echo "alpha is no more executable!" >&2
941 da09d8ed 2022-03-22 thomas test_done $testroot 1
944 e0c1f81c 2022-03-22 thomas test_done $testroot 0
947 e0c1f81c 2022-03-22 thomas test_patch_create_dirs() {
948 e0c1f81c 2022-03-22 thomas local testroot=`test_init patch_create_dirs`
950 e0c1f81c 2022-03-22 thomas got checkout $testroot/repo $testroot/wt > /dev/null
952 e0c1f81c 2022-03-22 thomas if [ $ret -ne 0 ]; then
953 e0c1f81c 2022-03-22 thomas test_done $testroot $ret
957 e0c1f81c 2022-03-22 thomas cat <<EOF > $testroot/wt/patch
958 e0c1f81c 2022-03-22 thomas --- /dev/null
959 e0c1f81c 2022-03-22 thomas +++ iota/kappa/lambda
960 e0c1f81c 2022-03-22 thomas @@ -0,0 +1 @@
964 e0c1f81c 2022-03-22 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
966 e0c1f81c 2022-03-22 thomas if [ $ret -ne 0 ]; then
967 e0c1f81c 2022-03-22 thomas test_done $testroot $ret
971 e0c1f81c 2022-03-22 thomas echo 'A iota/kappa/lambda' >> $testroot/stdout.expected
972 e0c1f81c 2022-03-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
974 e0c1f81c 2022-03-22 thomas if [ $ret -ne 0 ]; then
975 e0c1f81c 2022-03-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
976 e0c1f81c 2022-03-22 thomas test_done $testroot $ret
980 e0c1f81c 2022-03-22 thomas if [ ! -f $testroot/wt/iota/kappa/lambda ]; then
981 e0c1f81c 2022-03-22 thomas echo "file not created!" >&2
982 e0c1f81c 2022-03-22 thomas test_done $testroot $ret
985 da09d8ed 2022-03-22 thomas test_done $testroot 0
988 49114f01 2022-03-22 thomas test_patch_with_offset() {
989 49114f01 2022-03-22 thomas local testroot=`test_init patch_with_offset`
991 49114f01 2022-03-22 thomas got checkout $testroot/repo $testroot/wt > /dev/null
993 49114f01 2022-03-22 thomas if [ $ret -ne 0 ]; then
994 49114f01 2022-03-22 thomas test_done $testroot $ret
998 49114f01 2022-03-22 thomas cat <<EOF > $testroot/wt/patch
999 49114f01 2022-03-22 thomas --- numbers
1000 49114f01 2022-03-22 thomas +++ numbers
1001 49114f01 2022-03-22 thomas @@ -47,7 +47,7 @@
1006 49114f01 2022-03-22 thomas +midway tru it!
1010 49114f01 2022-03-22 thomas @@ -87,7 +87,7 @@
1015 49114f01 2022-03-22 thomas +almost there!
1021 49114f01 2022-03-22 thomas jot 100 > $testroot/wt/numbers
1022 49114f01 2022-03-22 thomas ed $testroot/wt/numbers <<EOF > /dev/null 2> /dev/null
1024 49114f01 2022-03-22 thomas 50r !jot 20
1029 49114f01 2022-03-22 thomas (cd $testroot/wt && got add numbers && got commit -m '+numbers') \
1030 49114f01 2022-03-22 thomas > /dev/null
1032 49114f01 2022-03-22 thomas if [ $ret -ne 0 ]; then
1033 49114f01 2022-03-22 thomas test_done $testroot $ret
1034 49114f01 2022-03-22 thomas return 1
1037 49114f01 2022-03-22 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
1039 49114f01 2022-03-22 thomas if [ $ret -ne 0 ]; then
1040 49114f01 2022-03-22 thomas test_done $testroot/wt $ret
1041 49114f01 2022-03-22 thomas return 1
1044 49114f01 2022-03-22 thomas cat <<EOF > $testroot/stdout.expected
1045 49114f01 2022-03-22 thomas M numbers
1046 49114f01 2022-03-22 thomas @@ -47,7 +47,7 @@ applied with offset -10
1047 49114f01 2022-03-22 thomas @@ -87,7 +87,7 @@ applied with offset 10
1050 be53ddb1 2022-03-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1052 be53ddb1 2022-03-22 thomas if [ $ret -ne 0 ]; then
1053 be53ddb1 2022-03-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1055 be53ddb1 2022-03-22 thomas test_done $testroot $ret
1058 be53ddb1 2022-03-22 thomas test_patch_prefer_new_path() {
1059 be53ddb1 2022-03-22 thomas local testroot=`test_init patch_orig`
1061 be53ddb1 2022-03-22 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1063 be53ddb1 2022-03-22 thomas if [ $ret -ne 0 ]; then
1064 be53ddb1 2022-03-22 thomas test_done $testroot $ret
1065 be53ddb1 2022-03-22 thomas return 1
1068 be53ddb1 2022-03-22 thomas cat <<EOF > $testroot/wt/patch
1069 be53ddb1 2022-03-22 thomas --- alpha.orig
1070 be53ddb1 2022-03-22 thomas +++ alpha
1071 be53ddb1 2022-03-22 thomas @@ -1 +1,2 @@
1073 be53ddb1 2022-03-22 thomas +was edited
1076 be53ddb1 2022-03-22 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
1078 be53ddb1 2022-03-22 thomas if [ $ret -ne 0 ]; then
1079 be53ddb1 2022-03-22 thomas test_done $testroot $ret
1080 be53ddb1 2022-03-22 thomas return 1
1083 e1c219c8 2022-04-22 thomas echo 'M alpha' > $testroot/stdout.expected
1084 49114f01 2022-03-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1086 49114f01 2022-03-22 thomas if [ $ret -ne 0 ]; then
1087 49114f01 2022-03-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1089 49114f01 2022-03-22 thomas test_done $testroot $ret
1092 ff7f34d3 2022-03-22 thomas test_patch_no_newline() {
1093 ff7f34d3 2022-03-22 thomas local testroot=`test_init patch_no_newline`
1095 ff7f34d3 2022-03-22 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1097 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1098 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1099 ff7f34d3 2022-03-22 thomas return 1
1102 ff7f34d3 2022-03-22 thomas cat <<EOF > $testroot/wt/patch
1103 ff7f34d3 2022-03-22 thomas --- /dev/null
1105 ff7f34d3 2022-03-22 thomas @@ -0,0 +1 @@
1107 ff7f34d3 2022-03-22 thomas \ No newline at end of file
1110 ff7f34d3 2022-03-22 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
1112 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1113 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1114 ff7f34d3 2022-03-22 thomas return 1
1117 ff7f34d3 2022-03-22 thomas echo "A eta" > $testroot/stdout.expected
1118 ff7f34d3 2022-03-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1120 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1121 ff7f34d3 2022-03-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1122 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1123 ff7f34d3 2022-03-22 thomas return 1
1126 ff7f34d3 2022-03-22 thomas echo -n eta > $testroot/wt/eta.expected
1127 ff7f34d3 2022-03-22 thomas cmp -s $testroot/wt/eta.expected $testroot/wt/eta
1129 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1130 ff7f34d3 2022-03-22 thomas diff -u $testroot/wt/eta.expected $testroot/wt/eta
1131 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1132 ff7f34d3 2022-03-22 thomas return 1
1135 ff7f34d3 2022-03-22 thomas (cd $testroot/wt && got commit -m 'add eta') > /dev/null
1137 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1138 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1139 ff7f34d3 2022-03-22 thomas return 1
1142 ff7f34d3 2022-03-22 thomas cat <<EOF > $testroot/wt/patch
1145 ff7f34d3 2022-03-22 thomas @@ -1 +1 @@
1147 ff7f34d3 2022-03-22 thomas \ No newline at end of file
1149 ff7f34d3 2022-03-22 thomas \ No newline at end of file
1152 ff7f34d3 2022-03-22 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
1154 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1155 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1156 ff7f34d3 2022-03-22 thomas return 1
1159 ff7f34d3 2022-03-22 thomas echo "M eta" > $testroot/stdout.expected
1160 ff7f34d3 2022-03-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1162 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1163 ff7f34d3 2022-03-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1164 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1165 ff7f34d3 2022-03-22 thomas return 1
1168 ff7f34d3 2022-03-22 thomas echo -n ETA > $testroot/wt/eta.expected
1169 ff7f34d3 2022-03-22 thomas cmp -s $testroot/wt/eta.expected $testroot/wt/eta
1171 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1172 ff7f34d3 2022-03-22 thomas diff -u $testroot/wt/eta.expected $testroot/wt/eta
1173 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1174 ff7f34d3 2022-03-22 thomas return 1
1177 ff7f34d3 2022-03-22 thomas (cd $testroot/wt && got commit -m 'edit eta') > /dev/null
1179 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1180 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1181 ff7f34d3 2022-03-22 thomas return 1
1184 ff7f34d3 2022-03-22 thomas cat <<EOF > $testroot/wt/patch
1187 ff7f34d3 2022-03-22 thomas @@ -1 +1 @@
1189 ff7f34d3 2022-03-22 thomas \ No newline at end of file
1193 ff7f34d3 2022-03-22 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
1195 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1196 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1197 ff7f34d3 2022-03-22 thomas return 1
1200 ff7f34d3 2022-03-22 thomas echo "M eta" > $testroot/stdout.expected
1201 ff7f34d3 2022-03-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1203 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1204 ff7f34d3 2022-03-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1205 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1206 ff7f34d3 2022-03-22 thomas return 1
1209 ff7f34d3 2022-03-22 thomas echo eta > $testroot/wt/eta.expected
1210 ff7f34d3 2022-03-22 thomas cmp -s $testroot/wt/eta.expected $testroot/wt/eta
1212 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1213 ff7f34d3 2022-03-22 thomas diff -u $testroot/wt/eta.expected $testroot/wt/eta
1215 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1218 d9db2ff9 2022-04-16 thomas test_patch_strip() {
1219 d9db2ff9 2022-04-16 thomas local testroot=`test_init patch_strip`
1221 d9db2ff9 2022-04-16 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1223 d9db2ff9 2022-04-16 thomas if [ $ret -ne 0 ]; then
1224 d9db2ff9 2022-04-16 thomas test_done $testroot $ret
1225 d9db2ff9 2022-04-16 thomas return 1
1228 d9db2ff9 2022-04-16 thomas cat <<EOF > $testroot/wt/patch
1229 d9db2ff9 2022-04-16 thomas --- foo/bar/alpha.orig
1230 d9db2ff9 2022-04-16 thomas +++ foo/bar/alpha
1231 d9db2ff9 2022-04-16 thomas @@ -1 +1 @@
1236 d9db2ff9 2022-04-16 thomas (cd $testroot/wt && got patch -p2 patch) > $testroot/stdout
1238 d9db2ff9 2022-04-16 thomas if [ $ret -ne 0 ]; then
1239 d9db2ff9 2022-04-16 thomas test_done $testroot $ret
1240 d9db2ff9 2022-04-16 thomas return 1
1243 d9db2ff9 2022-04-16 thomas echo "M alpha" >> $testroot/stdout.expected
1244 d9db2ff9 2022-04-16 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1246 d9db2ff9 2022-04-16 thomas if [ $ret -ne 0 ]; then
1247 d9db2ff9 2022-04-16 thomas diff -u $testroot/stdout.expected $testroot/stdout
1248 d9db2ff9 2022-04-16 thomas test_done $testroot $ret
1249 d9db2ff9 2022-04-16 thomas return 1
1252 d9db2ff9 2022-04-16 thomas (cd $testroot/wt && got revert alpha) > /dev/null 2>&1
1254 d9db2ff9 2022-04-16 thomas if [ $ret -ne 0 ]; then
1255 d9db2ff9 2022-04-16 thomas test_done $testroot $ret
1256 d9db2ff9 2022-04-16 thomas return 1
1259 d9db2ff9 2022-04-16 thomas (cd $testroot/wt && got patch -p3 patch) \
1260 d9db2ff9 2022-04-16 thomas 2> $testroot/stderr
1262 d9db2ff9 2022-04-16 thomas if [ $ret -eq 0 ]; then
1263 d9db2ff9 2022-04-16 thomas echo "stripped more components than available!"
1264 d9db2ff9 2022-04-16 thomas test_done $testroot 1
1265 d9db2ff9 2022-04-16 thomas return 1
1268 d9db2ff9 2022-04-16 thomas cat <<EOF > $testroot/stderr.expected
1269 d9db2ff9 2022-04-16 thomas got: can't strip 1 path-components from foo/bar/alpha: bad path
1272 d9db2ff9 2022-04-16 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1274 d9db2ff9 2022-04-16 thomas if [ $ret -ne 0 ]; then
1275 d9db2ff9 2022-04-16 thomas diff -u $testroot/stderr.expected $testroot/stderr
1277 d9db2ff9 2022-04-16 thomas test_done $testroot 0
1280 bb90ca7b 2022-07-03 thomas test_patch_whitespace() {
1281 bb90ca7b 2022-07-03 thomas local testroot=`test_init patch_whitespace`
1283 bb90ca7b 2022-07-03 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1285 bb90ca7b 2022-07-03 thomas if [ $ret -ne 0 ]; then
1286 bb90ca7b 2022-07-03 thomas test_done $testroot $ret
1287 bb90ca7b 2022-07-03 thomas return 1
1290 bb90ca7b 2022-07-03 thomas trailing=" "
1292 bb90ca7b 2022-07-03 thomas cat <<EOF > $testroot/wt/hello.c
1293 bb90ca7b 2022-07-03 thomas #include <stdio.h>
1296 bb90ca7b 2022-07-03 thomas main(void)
1298 bb90ca7b 2022-07-03 thomas /* the trailing whitespace is on purpose */
1299 bb90ca7b 2022-07-03 thomas printf("hello, world\n");$trailing
1300 bb90ca7b 2022-07-03 thomas return 0;
1304 bb90ca7b 2022-07-03 thomas (cd $testroot/wt && got add hello.c && got ci -m '+hello.c') \
1305 bb90ca7b 2022-07-03 thomas > /dev/null
1307 bb90ca7b 2022-07-03 thomas if [ $ret -ne 0 ]; then
1308 bb90ca7b 2022-07-03 thomas test_done $testroot $ret
1309 bb90ca7b 2022-07-03 thomas return 1
1312 bb90ca7b 2022-07-03 thomas # test with a diff with various whitespace corruptions
1313 bb90ca7b 2022-07-03 thomas cat <<EOF > $testroot/wt/patch
1314 bb90ca7b 2022-07-03 thomas --- hello.c
1315 bb90ca7b 2022-07-03 thomas +++ hello.c
1316 bb90ca7b 2022-07-03 thomas @@ -5,5 +5,5 @@
1318 bb90ca7b 2022-07-03 thomas /* the trailing whitespace is on purpose */
1319 bb90ca7b 2022-07-03 thomas printf("hello, world\n");
1320 bb90ca7b 2022-07-03 thomas - return 0;
1321 bb90ca7b 2022-07-03 thomas + return 5; /* always fails */
1325 bb90ca7b 2022-07-03 thomas (cd $testroot/wt && got patch patch) \
1326 bb90ca7b 2022-07-03 thomas 2>$testroot/stderr >$testroot/stdout
1328 bb90ca7b 2022-07-03 thomas if [ $ret -ne 0 ]; then
1329 bb90ca7b 2022-07-03 thomas echo "failed to apply diff" >&2
1330 bb90ca7b 2022-07-03 thomas test_done $testroot $ret
1331 bb90ca7b 2022-07-03 thomas return 1
1334 bb90ca7b 2022-07-03 thomas echo 'M hello.c' > $testroot/stdout.expected
1335 bb90ca7b 2022-07-03 thomas echo '@@ -5,5 +5,5 @@ hunk contains mangled whitespace' \
1336 bb90ca7b 2022-07-03 thomas >> $testroot/stdout.expected
1337 bb90ca7b 2022-07-03 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1339 bb90ca7b 2022-07-03 thomas if [ $ret -ne 0 ]; then
1340 bb90ca7b 2022-07-03 thomas diff -u $testroot/stdout.expected $testroot/stdout
1341 bb90ca7b 2022-07-03 thomas test_done $testroot $ret
1342 bb90ca7b 2022-07-03 thomas return 1
1345 bb90ca7b 2022-07-03 thomas cat <<EOF > $testroot/wt/hello.c.expected
1346 bb90ca7b 2022-07-03 thomas #include <stdio.h>
1349 bb90ca7b 2022-07-03 thomas main(void)
1351 bb90ca7b 2022-07-03 thomas /* the trailing whitespace is on purpose */
1352 bb90ca7b 2022-07-03 thomas printf("hello, world\n");$trailing
1353 bb90ca7b 2022-07-03 thomas return 5; /* always fails */
1357 bb90ca7b 2022-07-03 thomas cmp -s $testroot/wt/hello.c.expected $testroot/wt/hello.c
1359 bb90ca7b 2022-07-03 thomas if [ $ret -ne 0 ]; then
1360 bb90ca7b 2022-07-03 thomas diff -u $testroot/wt/hello.c.expected $testroot/wt/hello.c
1362 bb90ca7b 2022-07-03 thomas test_done $testroot $ret
1365 72f46891 2022-04-23 thomas test_patch_relative_paths() {
1366 9a49df74 2022-04-23 thomas local testroot=`test_init patch_relative_paths`
1368 72f46891 2022-04-23 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1370 72f46891 2022-04-23 thomas if [ $ret -ne 0 ]; then
1371 72f46891 2022-04-23 thomas test_done $testroot $ret
1372 72f46891 2022-04-23 thomas return 1
1375 72f46891 2022-04-23 thomas cat <<EOF > $testroot/wt/gamma/patch
1376 72f46891 2022-04-23 thomas --- delta
1377 72f46891 2022-04-23 thomas +++ delta
1378 72f46891 2022-04-23 thomas @@ -1 +1 @@
1381 72f46891 2022-04-23 thomas --- /dev/null
1383 72f46891 2022-04-23 thomas @@ -0,0 +1 @@
1387 72f46891 2022-04-23 thomas (cd $testroot/wt/gamma && got patch patch) > $testroot/stdout
1389 72f46891 2022-04-23 thomas if [ $ret -ne 0 ]; then
1390 72f46891 2022-04-23 thomas test_done $testroot $ret
1391 72f46891 2022-04-23 thomas return 1
1394 72f46891 2022-04-23 thomas echo 'M gamma/delta' > $testroot/stdout.expected
1395 72f46891 2022-04-23 thomas echo 'A gamma/eta' >> $testroot/stdout.expected
1397 cfbf5531 2022-04-23 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1399 cfbf5531 2022-04-23 thomas if [ $ret -ne 0 ]; then
1400 cfbf5531 2022-04-23 thomas diff -u $testroot/stdout.expected $testroot/stdout
1402 cfbf5531 2022-04-23 thomas test_done $testroot $ret
1405 cfbf5531 2022-04-23 thomas test_patch_with_path_prefix() {
1406 cfbf5531 2022-04-23 thomas local testroot=`test_init patch_with_path_prefix`
1408 cfbf5531 2022-04-23 thomas got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
1410 cfbf5531 2022-04-23 thomas if [ $ret -ne 0 ]; then
1411 cfbf5531 2022-04-23 thomas test_done $testroot $ret
1412 cfbf5531 2022-04-23 thomas return 1
1415 cfbf5531 2022-04-23 thomas cat <<EOF > $testroot/wt/patch
1416 cfbf5531 2022-04-23 thomas --- delta
1417 cfbf5531 2022-04-23 thomas +++ delta
1418 cfbf5531 2022-04-23 thomas @@ -1 +1 @@
1421 cfbf5531 2022-04-23 thomas --- /dev/null
1423 cfbf5531 2022-04-23 thomas @@ -0,0 +1 @@
1427 cfbf5531 2022-04-23 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
1429 cfbf5531 2022-04-23 thomas if [ $ret -ne 0 ]; then
1430 cfbf5531 2022-04-23 thomas test_done $testroot $ret
1431 cfbf5531 2022-04-23 thomas return 1
1434 cfbf5531 2022-04-23 thomas echo 'M delta' > $testroot/stdout.expected
1435 cfbf5531 2022-04-23 thomas echo 'A eta' >> $testroot/stdout.expected
1437 cfbf5531 2022-04-23 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1439 cfbf5531 2022-04-23 thomas if [ $ret -ne 0 ]; then
1440 cfbf5531 2022-04-23 thomas diff -u $testroot/stdout.expected $testroot/stdout
1442 cfbf5531 2022-04-23 thomas test_done $testroot $ret
1445 cfbf5531 2022-04-23 thomas test_patch_relpath_with_path_prefix() {
1446 cfbf5531 2022-04-23 thomas local testroot=`test_init patch_relpaths_with_path_prefix`
1448 cfbf5531 2022-04-23 thomas got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
1450 cfbf5531 2022-04-23 thomas if [ $ret -ne 0 ]; then
1451 cfbf5531 2022-04-23 thomas test_done $testroot $ret
1452 cfbf5531 2022-04-23 thomas return 1
1455 cfbf5531 2022-04-23 thomas mkdir -p $testroot/wt/epsilon/zeta/
1457 cfbf5531 2022-04-23 thomas cat <<EOF > $testroot/wt/patch
1458 cfbf5531 2022-04-23 thomas --- /dev/null
1459 cfbf5531 2022-04-23 thomas +++ zeta/theta
1460 cfbf5531 2022-04-23 thomas @@ -0,0 +1 @@
1464 cfbf5531 2022-04-23 thomas (cd $testroot/wt/epsilon/zeta && got patch -p1 $testroot/wt/patch) \
1465 cfbf5531 2022-04-23 thomas > $testroot/stdout
1467 cfbf5531 2022-04-23 thomas if [ $ret -ne 0 ]; then
1468 cfbf5531 2022-04-23 thomas test_done $testroot $ret
1469 cfbf5531 2022-04-23 thomas return 1
1472 cfbf5531 2022-04-23 thomas echo 'A epsilon/zeta/theta' >> $testroot/stdout.expected
1474 72f46891 2022-04-23 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1476 72f46891 2022-04-23 thomas if [ $ret -ne 0 ]; then
1477 72f46891 2022-04-23 thomas diff -u $testroot/stdout.expected $testroot/stdout
1478 cfbf5531 2022-04-23 thomas test_done $testroot $ret
1479 cfbf5531 2022-04-23 thomas return 1
1482 cfbf5531 2022-04-23 thomas echo 'theta' > $testroot/theta.expected
1483 cfbf5531 2022-04-23 thomas cmp -s $testroot/wt/epsilon/zeta/theta $testroot/theta.expected
1485 cfbf5531 2022-04-23 thomas if [ $ret -ne 0 ]; then
1486 cfbf5531 2022-04-23 thomas diff -u $testroot/wt/epsilon/zeta/theta $testroot/theta.expected
1488 72f46891 2022-04-23 thomas test_done $testroot $ret
1491 eaef698f 2022-04-23 thomas test_patch_reverse() {
1492 eaef698f 2022-04-23 thomas local testroot=`test_init patch_reverse`
1494 eaef698f 2022-04-23 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1496 eaef698f 2022-04-23 thomas if [ $ret -ne 0 ]; then
1497 eaef698f 2022-04-23 thomas test_done $testroot $ret
1498 eaef698f 2022-04-23 thomas return 1
1501 eaef698f 2022-04-23 thomas cat <<EOF > $testroot/wt/patch
1502 eaef698f 2022-04-23 thomas --- alpha
1503 eaef698f 2022-04-23 thomas +++ alpha
1504 eaef698f 2022-04-23 thomas @@ -1 +1 @@
1506 eaef698f 2022-04-23 thomas \ No newline at end of file
1510 eaef698f 2022-04-23 thomas (cd $testroot/wt && got patch -R patch) > $testroot/stdout
1512 eaef698f 2022-04-23 thomas if [ $ret -ne 0 ]; then
1513 eaef698f 2022-04-23 thomas test_done $testroot $ret
1514 eaef698f 2022-04-23 thomas return 1
1517 eaef698f 2022-04-23 thomas echo "M alpha" > $testroot/stdout.expected
1518 eaef698f 2022-04-23 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1520 eaef698f 2022-04-23 thomas if [ $ret -ne 0 ]; then
1521 eaef698f 2022-04-23 thomas diff -u $testroot/stdout.expected $testroot/stdout
1522 eaef698f 2022-04-23 thomas test_done $testroot $ret
1523 eaef698f 2022-04-23 thomas return 1
1526 eaef698f 2022-04-23 thomas echo -n ALPHA > $testroot/wt/alpha.expected
1527 eaef698f 2022-04-23 thomas cmp -s $testroot/wt/alpha.expected $testroot/wt/alpha
1529 eaef698f 2022-04-23 thomas if [ $ret -ne 0 ]; then
1530 eaef698f 2022-04-23 thomas diff -u $testroot/wt/alpha.expected $testroot/wt/alpha
1532 0f76ab83 2022-06-23 thomas test_done $testroot $ret
1535 0f76ab83 2022-06-23 thomas test_patch_merge_simple() {
1536 0f76ab83 2022-06-23 thomas local testroot=`test_init patch_merge_simple`
1538 0f76ab83 2022-06-23 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1540 0f76ab83 2022-06-23 thomas if [ $ret -ne 0 ]; then
1541 0f76ab83 2022-06-23 thomas test_done $testroot $ret
1542 0f76ab83 2022-06-23 thomas return 1
1545 0f76ab83 2022-06-23 thomas jot 10 > $testroot/wt/numbers
1546 25a880e1 2022-07-03 thomas chmod +x $testroot/wt/numbers
1547 0f76ab83 2022-06-23 thomas (cd $testroot/wt && got add numbers && got commit -m +numbers) \
1548 0f76ab83 2022-06-23 thomas > /dev/null
1550 0f76ab83 2022-06-23 thomas if [ $ret -ne 0 ]; then
1551 0f76ab83 2022-06-23 thomas test_done $testroot $ret
1552 0f76ab83 2022-06-23 thomas return 1
1555 0f76ab83 2022-06-23 thomas jot 10 | sed 's/4/four/g' > $testroot/wt/numbers
1557 0f76ab83 2022-06-23 thomas (cd $testroot/wt && got diff > $testroot/old.diff \
1558 0f76ab83 2022-06-23 thomas && got revert numbers) >/dev/null
1560 0f76ab83 2022-06-23 thomas if [ $ret -ne 0 ]; then
1561 0f76ab83 2022-06-23 thomas test_done $testroot $ret
1562 0f76ab83 2022-06-23 thomas return 1
1565 0f76ab83 2022-06-23 thomas jot 10 | sed 's/6/six/g' > $testroot/wt/numbers
1566 0f76ab83 2022-06-23 thomas (cd $testroot/wt && got commit -m 'edit numbers') \
1567 0f76ab83 2022-06-23 thomas > /dev/null
1569 0f76ab83 2022-06-23 thomas if [ $ret -ne 0 ]; then
1570 0f76ab83 2022-06-23 thomas test_done $testroot $ret
1571 0f76ab83 2022-06-23 thomas return 1
1574 0f76ab83 2022-06-23 thomas (cd $testroot/wt && got patch $testroot/old.diff) \
1575 762b8e82 2022-06-23 thomas > $testroot/stdout
1577 0f76ab83 2022-06-23 thomas if [ $ret -ne 0 ]; then
1578 762b8e82 2022-06-23 thomas test_done $testroot $ret
1579 762b8e82 2022-06-23 thomas return 1
1582 762b8e82 2022-06-23 thomas echo 'G numbers' > $testroot/stdout.expected
1583 762b8e82 2022-06-23 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1585 762b8e82 2022-06-23 thomas if [ $ret -ne 0 ]; then
1586 762b8e82 2022-06-23 thomas diff -u $testroot/stdout $testroot/stdout.expected
1587 0f76ab83 2022-06-23 thomas test_done $testroot $ret
1588 0f76ab83 2022-06-23 thomas return 1
1591 0f76ab83 2022-06-23 thomas jot 10 | sed -e s/4/four/ -e s/6/six/ > $testroot/wt/numbers.expected
1592 0f76ab83 2022-06-23 thomas cmp -s $testroot/wt/numbers $testroot/wt/numbers.expected
1594 0f76ab83 2022-06-23 thomas if [ $ret -ne 0 ]; then
1595 0f76ab83 2022-06-23 thomas diff -u $testroot/wt/numbers $testroot/wt/numbers.expected
1596 25a880e1 2022-07-03 thomas test_done $testroot $ret
1597 25a880e1 2022-07-03 thomas return 1
1600 25a880e1 2022-07-03 thomas test -x $testroot/wt/numbers
1602 25a880e1 2022-07-03 thomas if [ $ret -ne 0 ]; then
1603 25a880e1 2022-07-03 thomas echo "numbers lost the executable bit" >&2
1605 19dd85cb 2022-07-01 thomas test_done $testroot $ret
1608 19dd85cb 2022-07-01 thomas test_patch_merge_gitdiff() {
1609 19dd85cb 2022-07-01 thomas local testroot=`test_init patch_merge_gitdiff`
1611 19dd85cb 2022-07-01 thomas jot 10 > $testroot/repo/numbers
1612 19dd85cb 2022-07-01 thomas (cd $testroot/repo && git add numbers && \
1613 19dd85cb 2022-07-01 thomas git_commit $testroot/repo -m "nums")
1615 19dd85cb 2022-07-01 thomas if [ $ret -ne 0 ]; then
1616 19dd85cb 2022-07-01 thomas test_done $testroot $ret
1617 19dd85cb 2022-07-01 thomas return 1
1620 19dd85cb 2022-07-01 thomas jot 10 | sed 's/4/four/g' > $testroot/repo/numbers
1621 19dd85cb 2022-07-01 thomas (cd $testroot/repo && git diff > $testroot/old.diff)
1623 19dd85cb 2022-07-01 thomas if [ $ret -ne 0 ]; then
1624 19dd85cb 2022-07-01 thomas test_done $testroot $ret
1625 19dd85cb 2022-07-01 thomas return 1
1628 19dd85cb 2022-07-01 thomas # restore numbers
1629 19dd85cb 2022-07-01 thomas jot 10 > $testroot/repo/numbers
1631 19dd85cb 2022-07-01 thomas jot 10 | sed 's/6/six/g' > $testroot/repo/numbers
1632 19dd85cb 2022-07-01 thomas (cd $testroot/repo && git add numbers && \
1633 19dd85cb 2022-07-01 thomas git_commit $testroot/repo -m "edit")
1635 19dd85cb 2022-07-01 thomas if [ $ret -ne 0 ]; then
1636 19dd85cb 2022-07-01 thomas test_done $testroot $ret
1637 19dd85cb 2022-07-01 thomas return 1
1640 19dd85cb 2022-07-01 thomas # now work with got:
1641 19dd85cb 2022-07-01 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1643 19dd85cb 2022-07-01 thomas if [ $ret -ne 0 ]; then
1644 19dd85cb 2022-07-01 thomas test_done $testroot $ret
1645 19dd85cb 2022-07-01 thomas return 1
1648 19dd85cb 2022-07-01 thomas (cd $testroot/wt && got patch $testroot/old.diff) > $testroot/stdout
1650 19dd85cb 2022-07-01 thomas if [ $ret -ne 0 ]; then
1651 19dd85cb 2022-07-01 thomas test_done $testroot $ret
1652 19dd85cb 2022-07-01 thomas return 1
1655 19dd85cb 2022-07-01 thomas echo 'G numbers' > $testroot/stdout.expected
1656 19dd85cb 2022-07-01 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1658 19dd85cb 2022-07-01 thomas if [ $ret -ne 0 ]; then
1659 19dd85cb 2022-07-01 thomas diff -u $testroot/stdout $testroot/stdout.expected
1661 0f76ab83 2022-06-23 thomas test_done $testroot $ret
1664 0f76ab83 2022-06-23 thomas test_patch_merge_conflict() {
1665 0f76ab83 2022-06-23 thomas local testroot=`test_init patch_merge_conflict`
1667 0f76ab83 2022-06-23 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1669 0f76ab83 2022-06-23 thomas if [ $ret -ne 0 ]; then
1670 0f76ab83 2022-06-23 thomas test_done $testroot $ret
1671 0f76ab83 2022-06-23 thomas return 1
1674 0f76ab83 2022-06-23 thomas jot 10 > $testroot/wt/numbers
1675 0f76ab83 2022-06-23 thomas (cd $testroot/wt && got add numbers && got commit -m +numbers) \
1676 0f76ab83 2022-06-23 thomas > /dev/null
1678 0f76ab83 2022-06-23 thomas if [ $ret -ne 0 ]; then
1679 0f76ab83 2022-06-23 thomas test_done $testroot $ret
1680 0f76ab83 2022-06-23 thomas return 1
1683 016bfe4b 2022-06-23 thomas local commit_id=`git_show_head $testroot/repo`
1685 0f76ab83 2022-06-23 thomas jot 10 | sed 's/6/six/g' > $testroot/wt/numbers
1686 68ceedb3 2022-07-03 thomas echo ALPHA > $testroot/wt/alpha
1688 0f76ab83 2022-06-23 thomas (cd $testroot/wt && got diff > $testroot/old.diff \
1689 68ceedb3 2022-07-03 thomas && got revert alpha numbers) >/dev/null
1691 0f76ab83 2022-06-23 thomas if [ $ret -ne 0 ]; then
1692 0f76ab83 2022-06-23 thomas test_done $testroot $ret
1693 0f76ab83 2022-06-23 thomas return 1
1696 0f76ab83 2022-06-23 thomas jot 10 | sed 's/6/3+3/g' > $testroot/wt/numbers
1697 68ceedb3 2022-07-03 thomas jot -c 3 a > $testroot/wt/alpha
1698 68ceedb3 2022-07-03 thomas (cd $testroot/wt && got commit -m 'edit alpha and numbers') \
1699 0f76ab83 2022-06-23 thomas > /dev/null
1701 0f76ab83 2022-06-23 thomas if [ $ret -ne 0 ]; then
1702 0f76ab83 2022-06-23 thomas test_done $testroot $ret
1703 0f76ab83 2022-06-23 thomas return 1
1706 0f76ab83 2022-06-23 thomas (cd $testroot/wt && got patch $testroot/old.diff) \
1707 762b8e82 2022-06-23 thomas > $testroot/stdout 2>/dev/null
1709 0f76ab83 2022-06-23 thomas if [ $ret -eq 0 ]; then
1710 0f76ab83 2022-06-23 thomas echo "got patch merged a diff that should conflict" >&2
1711 0f76ab83 2022-06-23 thomas test_done $testroot 0
1712 0f76ab83 2022-06-23 thomas return 1
1715 68ceedb3 2022-07-03 thomas echo 'C alpha' > $testroot/stdout.expected
1716 68ceedb3 2022-07-03 thomas echo 'C numbers' >> $testroot/stdout.expected
1717 762b8e82 2022-06-23 thomas cmp -s $testroot/stdout $testroot/stdout.expected
1719 762b8e82 2022-06-23 thomas if [ $ret -ne 0 ]; then
1720 762b8e82 2022-06-23 thomas diff -u $testroot/stdout $testroot/stdout.expected
1721 762b8e82 2022-06-23 thomas test_done $testroot $ret
1722 762b8e82 2022-06-23 thomas return 1
1725 0f76ab83 2022-06-23 thomas # XXX: prefixing every line with a tab otherwise got thinks
1726 0f76ab83 2022-06-23 thomas # the file has conflicts in it.
1727 68ceedb3 2022-07-03 thomas cat <<-EOF > $testroot/wt/alpha.expected
1728 68ceedb3 2022-07-03 thomas <<<<<<< --- alpha
1730 68ceedb3 2022-07-03 thomas ||||||| commit $commit_id
1736 68ceedb3 2022-07-03 thomas >>>>>>> +++ alpha
1739 0f76ab83 2022-06-23 thomas cat <<-EOF > $testroot/wt/numbers.expected
1745 0f76ab83 2022-06-23 thomas <<<<<<< --- numbers
1747 016bfe4b 2022-06-23 thomas ||||||| commit $commit_id
1751 0f76ab83 2022-06-23 thomas >>>>>>> +++ numbers
1758 68ceedb3 2022-07-03 thomas cmp -s $testroot/wt/alpha $testroot/wt/alpha.expected
1760 68ceedb3 2022-07-03 thomas if [ $ret -ne 0 ]; then
1761 68ceedb3 2022-07-03 thomas diff -u $testroot/wt/alpha $testroot/wt/alpha.expected
1762 68ceedb3 2022-07-03 thomas test_done $testroot $ret
1763 68ceedb3 2022-07-03 thomas return 1
1766 0f76ab83 2022-06-23 thomas cmp -s $testroot/wt/numbers $testroot/wt/numbers.expected
1768 0f76ab83 2022-06-23 thomas if [ $ret -ne 0 ]; then
1769 0f76ab83 2022-06-23 thomas diff -u $testroot/wt/numbers $testroot/wt/numbers.expected
1771 eaef698f 2022-04-23 thomas test_done $testroot $ret
1774 0f76ab83 2022-06-23 thomas test_patch_merge_unknown_blob() {
1775 0f76ab83 2022-06-23 thomas local testroot=`test_init patch_merge_unknown_blob`
1777 0f76ab83 2022-06-23 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1779 0f76ab83 2022-06-23 thomas if [ $ret -ne 0 ]; then
1780 0f76ab83 2022-06-23 thomas test_done $testroot $ret
1781 0f76ab83 2022-06-23 thomas return 1
1784 0f76ab83 2022-06-23 thomas cat <<EOF > $testroot/wt/patch
1785 0f76ab83 2022-06-23 thomas I've got a
1786 c9a4f4fa 2022-06-23 thomas diff aaaabbbbccccddddeeeeffff0000111122223333 foo/bar
1788 0f76ab83 2022-06-23 thomas blob - aaaabbbbccccddddeeeeffff0000111122223333
1789 0f76ab83 2022-06-23 thomas and also a
1790 c9a4f4fa 2022-06-23 thomas blob + 0000111122223333444455556666777788889999
1791 0f76ab83 2022-06-23 thomas for this dummy diff
1792 0f76ab83 2022-06-23 thomas --- alpha
1793 0f76ab83 2022-06-23 thomas +++ alpha
1794 0f76ab83 2022-06-23 thomas @@ -1 +1 @@
1797 0f76ab83 2022-06-23 thomas will it work?
1800 0f76ab83 2022-06-23 thomas (cd $testroot/wt/ && got patch patch) > $testroot/stdout
1802 0f76ab83 2022-06-23 thomas if [ $ret -ne 0 ]; then
1803 0f76ab83 2022-06-23 thomas test_done $testroot $ret
1804 0f76ab83 2022-06-23 thomas return 1
1807 0f76ab83 2022-06-23 thomas echo 'M alpha' > $testroot/stdout.expected
1808 0f76ab83 2022-06-23 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1810 0f76ab83 2022-06-23 thomas if [ $ret -ne 0 ]; then
1811 0f76ab83 2022-06-23 thomas diff -u $testroot/stdout.expected $testroot/stdout
1812 c9a4f4fa 2022-06-23 thomas test_done $testroot $ret
1813 c9a4f4fa 2022-06-23 thomas return 1
1816 c9a4f4fa 2022-06-23 thomas # try again without a `diff' header
1818 c9a4f4fa 2022-06-23 thomas cat <<EOF > $testroot/wt/patch
1819 c9a4f4fa 2022-06-23 thomas I've got a
1820 c9a4f4fa 2022-06-23 thomas blob - aaaabbbbccccddddeeeeffff0000111122223333
1821 c9a4f4fa 2022-06-23 thomas and also a
1822 c9a4f4fa 2022-06-23 thomas blob + 0000111122223333444455556666777788889999
1823 c9a4f4fa 2022-06-23 thomas for this dummy diff
1824 c9a4f4fa 2022-06-23 thomas --- alpha
1825 c9a4f4fa 2022-06-23 thomas +++ alpha
1826 c9a4f4fa 2022-06-23 thomas @@ -1 +1 @@
1829 c9a4f4fa 2022-06-23 thomas will it work?
1832 c9a4f4fa 2022-06-23 thomas (cd $testroot/wt && got revert alpha > /dev/null && got patch patch) \
1833 c9a4f4fa 2022-06-23 thomas > $testroot/stdout
1835 c9a4f4fa 2022-06-23 thomas if [ $ret -ne 0 ]; then
1836 c9a4f4fa 2022-06-23 thomas test_done $testroot $ret
1837 c9a4f4fa 2022-06-23 thomas return 1
1840 c9a4f4fa 2022-06-23 thomas echo 'M alpha' > $testroot/stdout.expected
1841 c9a4f4fa 2022-06-23 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1843 c9a4f4fa 2022-06-23 thomas if [ $ret -ne 0 ]; then
1844 c9a4f4fa 2022-06-23 thomas diff -u $testroot/stdout.expected $testroot/stdout
1845 19dd85cb 2022-07-01 thomas test_done $testroot $ret
1846 19dd85cb 2022-07-01 thomas return 1
1849 19dd85cb 2022-07-01 thomas # try again with a git-style diff
1851 19dd85cb 2022-07-01 thomas cat <<EOF > $testroot/wt/patch
1852 19dd85cb 2022-07-01 thomas diff --git a/alpha b/alpha
1853 19dd85cb 2022-07-01 thomas index 0123456789ab..abcdef012345 100644
1854 19dd85cb 2022-07-01 thomas --- a/alpha
1855 19dd85cb 2022-07-01 thomas +++ b/alpha
1856 19dd85cb 2022-07-01 thomas @@ -1 +1 @@
1861 19dd85cb 2022-07-01 thomas (cd $testroot/wt && got revert alpha > /dev/null && got patch patch) \
1862 19dd85cb 2022-07-01 thomas > $testroot/stdout
1864 19dd85cb 2022-07-01 thomas if [ $ret -ne 0 ]; then
1865 19dd85cb 2022-07-01 thomas test_done $testroot $ret
1866 19dd85cb 2022-07-01 thomas return 1
1869 19dd85cb 2022-07-01 thomas echo 'M alpha' > $testroot/stdout.expected
1870 19dd85cb 2022-07-01 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1872 19dd85cb 2022-07-01 thomas if [ $ret -ne 0 ]; then
1873 19dd85cb 2022-07-01 thomas diff -u $testroot/stdout.expected $testroot/stdout
1875 0f76ab83 2022-06-23 thomas test_done $testroot $ret
1878 069bbb86 2022-03-07 thomas test_parseargs "$@"
1879 8d8dc2a3 2022-07-03 thomas run_test test_patch_add_file
1880 762e07b8 2022-07-03 thomas run_test test_patch_rm_file
1881 069bbb86 2022-03-07 thomas run_test test_patch_simple_edit_file
1882 069bbb86 2022-03-07 thomas run_test test_patch_prepend_line
1883 069bbb86 2022-03-07 thomas run_test test_patch_replace_line
1884 069bbb86 2022-03-07 thomas run_test test_patch_multiple_hunks
1885 069bbb86 2022-03-07 thomas run_test test_patch_multiple_files
1886 069bbb86 2022-03-07 thomas run_test test_patch_dont_apply
1887 069bbb86 2022-03-07 thomas run_test test_patch_malformed
1888 069bbb86 2022-03-07 thomas run_test test_patch_no_patch
1889 069bbb86 2022-03-07 thomas run_test test_patch_equals_for_context
1890 bb2ad8ff 2022-03-13 thomas run_test test_patch_rename
1891 10e55613 2022-03-22 thomas run_test test_patch_illegal_status
1892 eaf99875 2022-03-22 thomas run_test test_patch_nop
1893 da09d8ed 2022-03-22 thomas run_test test_patch_preserve_perm
1894 e0c1f81c 2022-03-22 thomas run_test test_patch_create_dirs
1895 49114f01 2022-03-22 thomas run_test test_patch_with_offset
1896 be53ddb1 2022-03-22 thomas run_test test_patch_prefer_new_path
1897 ff7f34d3 2022-03-22 thomas run_test test_patch_no_newline
1898 d9db2ff9 2022-04-16 thomas run_test test_patch_strip
1899 bb90ca7b 2022-07-03 thomas run_test test_patch_whitespace
1900 72f46891 2022-04-23 thomas run_test test_patch_relative_paths
1901 cfbf5531 2022-04-23 thomas run_test test_patch_with_path_prefix
1902 cfbf5531 2022-04-23 thomas run_test test_patch_relpath_with_path_prefix
1903 eaef698f 2022-04-23 thomas run_test test_patch_reverse
1904 0f76ab83 2022-06-23 thomas run_test test_patch_merge_simple
1905 19dd85cb 2022-07-01 thomas run_test test_patch_merge_gitdiff
1906 0f76ab83 2022-06-23 thomas run_test test_patch_merge_conflict
1907 0f76ab83 2022-06-23 thomas run_test test_patch_merge_unknown_blob