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 069bbb86 2022-03-07 thomas test_patch_simple_add_file() {
20 069bbb86 2022-03-07 thomas local testroot=`test_init patch_simple_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 069bbb86 2022-03-07 thomas @@ -0,0 +1 @@
36 069bbb86 2022-03-07 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
38 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
39 069bbb86 2022-03-07 thomas test_done $testroot $ret
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
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
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
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
58 069bbb86 2022-03-07 thomas test_done $testroot $ret
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`
64 069bbb86 2022-03-07 thomas got checkout $testroot/repo $testroot/wt > /dev/null
66 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
67 069bbb86 2022-03-07 thomas test_done $testroot $ret
71 069bbb86 2022-03-07 thomas cat <<EOF > $testroot/wt/patch
73 069bbb86 2022-03-07 thomas +++ /dev/null
74 069bbb86 2022-03-07 thomas @@ -1 +0,0 @@
78 069bbb86 2022-03-07 thomas echo "D alpha" > $testroot/stdout.expected
80 069bbb86 2022-03-07 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
82 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
83 069bbb86 2022-03-07 thomas test_done $testroot $ret
87 069bbb86 2022-03-07 thomas cmp -s $testroot/stdout.expected $testroot/stdout
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
95 069bbb86 2022-03-07 thomas if [ -f $testroot/wt/alpha ]; then
97 069bbb86 2022-03-07 thomas echo "alpha still exists!"
99 069bbb86 2022-03-07 thomas test_done $testroot $ret
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`
105 069bbb86 2022-03-07 thomas got checkout $testroot/repo $testroot/wt > /dev/null
107 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
108 069bbb86 2022-03-07 thomas test_done $testroot $ret
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 @@
117 069bbb86 2022-03-07 thomas +alpha is my favourite character
120 069bbb86 2022-03-07 thomas echo "M alpha" > $testroot/stdout.expected
122 069bbb86 2022-03-07 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
124 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
125 069bbb86 2022-03-07 thomas test_done $testroot $ret
129 069bbb86 2022-03-07 thomas cmp -s $testroot/stdout.expected $testroot/stdout
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
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
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
143 069bbb86 2022-03-07 thomas test_done $testroot $ret
146 069bbb86 2022-03-07 thomas test_patch_prepend_line() {
147 069bbb86 2022-03-07 thomas local testroot=`test_init patch_prepend_line`
149 069bbb86 2022-03-07 thomas got checkout $testroot/repo $testroot/wt > /dev/null
151 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
152 069bbb86 2022-03-07 thomas test_done $testroot $ret
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
164 069bbb86 2022-03-07 thomas echo "M alpha" > $testroot/stdout.expected
166 069bbb86 2022-03-07 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
168 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
169 069bbb86 2022-03-07 thomas test_done $testroot $ret
173 069bbb86 2022-03-07 thomas cmp -s $testroot/stdout.expected $testroot/stdout
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
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
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
188 069bbb86 2022-03-07 thomas test_done $testroot $ret
191 069bbb86 2022-03-07 thomas test_patch_replace_line() {
192 069bbb86 2022-03-07 thomas local testroot=`test_init patch_replace_line`
194 069bbb86 2022-03-07 thomas got checkout $testroot/repo $testroot/wt > /dev/null
196 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
197 069bbb86 2022-03-07 thomas test_done $testroot $ret
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
205 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
206 069bbb86 2022-03-07 thomas test_done $testroot $ret
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 @@
224 069bbb86 2022-03-07 thomas echo "M numbers" > $testroot/stdout.expected
226 069bbb86 2022-03-07 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
228 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
229 069bbb86 2022-03-07 thomas test_done $testroot $ret
233 069bbb86 2022-03-07 thomas cmp -s $testroot/stdout.expected $testroot/stdout
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
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
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
247 069bbb86 2022-03-07 thomas test_done $testroot $ret
250 069bbb86 2022-03-07 thomas test_patch_multiple_hunks() {
251 02e4f0d8 2022-03-08 thomas local testroot=`test_init patch_replace_multiple_hunks`
253 069bbb86 2022-03-07 thomas got checkout $testroot/repo $testroot/wt > /dev/null
255 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
256 069bbb86 2022-03-07 thomas test_done $testroot $ret
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
264 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
265 069bbb86 2022-03-07 thomas test_done $testroot $ret
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 @@
281 069bbb86 2022-03-07 thomas @@ -57,7 +57,7 @@
290 069bbb86 2022-03-07 thomas @@ -98,3 +98,6 @@
299 069bbb86 2022-03-07 thomas echo "M numbers" > $testroot/stdout.expected
301 069bbb86 2022-03-07 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
303 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
304 069bbb86 2022-03-07 thomas test_done $testroot $ret
308 069bbb86 2022-03-07 thomas cmp -s $testroot/stdout.expected $testroot/stdout
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
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
322 069bbb86 2022-03-07 thomas cmp -s $testroot/wt/numbers.expected $testroot/wt/numbers
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
327 069bbb86 2022-03-07 thomas test_done $testroot $ret
330 069bbb86 2022-03-07 thomas test_patch_multiple_files() {
331 069bbb86 2022-03-07 thomas local testroot=`test_init patch_multiple_files`
333 069bbb86 2022-03-07 thomas got checkout $testroot/repo $testroot/wt > /dev/null
335 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
336 069bbb86 2022-03-07 thomas test_done $testroot $ret
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 @@
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 @@
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 @@
357 069bbb86 2022-03-07 thomas +delta new
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
364 069bbb86 2022-03-07 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
366 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
367 02e4f0d8 2022-03-08 thomas test_done $testroot $ret
371 069bbb86 2022-03-07 thomas cmp -s $testroot/stdout.expected $testroot/stdout
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
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
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
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
393 069bbb86 2022-03-07 thomas test_done $testroot 0
396 069bbb86 2022-03-07 thomas test_patch_dont_apply() {
397 069bbb86 2022-03-07 thomas local testroot=`test_init patch_dont_apply`
399 069bbb86 2022-03-07 thomas got checkout $testroot/repo $testroot/wt > /dev/null
401 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
402 069bbb86 2022-03-07 thomas test_done $testroot $ret
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
410 7dd42450 2022-03-13 thomas if [ $ret -ne 0 ]; then
411 7dd42450 2022-03-13 thomas test_done $testroot $ret
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 @@
435 49114f01 2022-03-22 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout 2> /dev/null
437 7dd42450 2022-03-13 thomas if [ $ret -eq 0 ]; then # should fail
438 7dd42450 2022-03-13 thomas test_done $testroot 1
442 49114f01 2022-03-22 thomas cat <<EOF > $testroot/stdout.expected
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
449 49114f01 2022-03-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
451 7dd42450 2022-03-13 thomas if [ $ret -ne 0 ]; then
452 49114f01 2022-03-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
454 069bbb86 2022-03-07 thomas test_done $testroot $ret
457 069bbb86 2022-03-07 thomas test_patch_malformed() {
458 069bbb86 2022-03-07 thomas local testroot=`test_init patch_malformed`
460 069bbb86 2022-03-07 thomas got checkout $testroot/repo $testroot/wt > /dev/null
462 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
463 069bbb86 2022-03-07 thomas test_done $testroot $ret
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
476 069bbb86 2022-03-07 thomas echo -n > $testroot/stdout.expected
477 069bbb86 2022-03-07 thomas echo "got: malformed patch" > $testroot/stderr.expected
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
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
489 069bbb86 2022-03-07 thomas cmp -s $testroot/stdout.expected $testroot/stdout
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
497 069bbb86 2022-03-07 thomas cmp -s $testroot/stderr.expected $testroot/stderr
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
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
514 069bbb86 2022-03-07 thomas (cd $testroot/wt && got patch patch) \
515 069bbb86 2022-03-07 thomas > $testroot/stdout \
516 069bbb86 2022-03-07 thomas 2> $testroot/stderr
518 10cdd9aa 2022-03-08 thomas if [ $ret -eq 0 ]; then
519 069bbb86 2022-03-07 thomas echo "got managed to apply an invalid patch"
520 069bbb86 2022-03-07 thomas test_done $testroot 1
524 069bbb86 2022-03-07 thomas cmp -s $testroot/stdout.expected $testroot/stdout
526 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
527 069bbb86 2022-03-07 thomas diff -u $testroot/stdout.expected $testroot/stdout
528 069bbb86 2022-03-07 thomas test_done $testroot $ret
532 069bbb86 2022-03-07 thomas cmp -s $testroot/stderr.expected $testroot/stderr
534 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
535 069bbb86 2022-03-07 thomas diff -u $testroot/stderr.expected $testroot/stderr
536 069bbb86 2022-03-07 thomas test_done $testroot $ret
540 069bbb86 2022-03-07 thomas test_done $testroot $ret
543 069bbb86 2022-03-07 thomas test_patch_no_patch() {
544 069bbb86 2022-03-07 thomas local testroot=`test_init patch_no_patch`
546 069bbb86 2022-03-07 thomas got checkout $testroot/repo $testroot/wt > /dev/null
548 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
549 069bbb86 2022-03-07 thomas test_done $testroot $ret
553 069bbb86 2022-03-07 thomas cat <<EOF > $testroot/wt/patch
554 069bbb86 2022-03-07 thomas hello world!
557 069bbb86 2022-03-07 thomas some other nonsense
560 069bbb86 2022-03-07 thomas there's no patch in here!
563 069bbb86 2022-03-07 thomas echo -n > $testroot/stdout.expected
564 069bbb86 2022-03-07 thomas echo "got: no patch found" > $testroot/stderr.expected
566 069bbb86 2022-03-07 thomas (cd $testroot/wt && got patch patch) \
567 069bbb86 2022-03-07 thomas > $testroot/stdout \
568 069bbb86 2022-03-07 thomas 2> $testroot/stderr
570 10cdd9aa 2022-03-08 thomas if [ $ret -eq 0 ]; then # should fail
571 069bbb86 2022-03-07 thomas test_done $testroot 1
575 069bbb86 2022-03-07 thomas cmp -s $testroot/stdout.expected $testroot/stdout
577 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
578 069bbb86 2022-03-07 thomas diff -u $testroot/stdout.expected $testroot/stdout
579 069bbb86 2022-03-07 thomas test_done $testroot $ret
583 069bbb86 2022-03-07 thomas cmp -s $testroot/stderr.expected $testroot/stderr
585 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
586 069bbb86 2022-03-07 thomas diff -u $testroot/stderr.expected $testroot/stderr
587 069bbb86 2022-03-07 thomas test_done $testroot $ret
591 069bbb86 2022-03-07 thomas test_done $testroot $ret
594 069bbb86 2022-03-07 thomas test_patch_equals_for_context() {
595 9a49df74 2022-04-23 thomas local testroot=`test_init patch_equals_for_context`
597 069bbb86 2022-03-07 thomas got checkout $testroot/repo $testroot/wt > /dev/null
599 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
600 069bbb86 2022-03-07 thomas test_done $testroot $ret
604 069bbb86 2022-03-07 thomas cat <<EOF > $testroot/wt/patch
605 069bbb86 2022-03-07 thomas --- alpha
606 069bbb86 2022-03-07 thomas +++ alpha
607 069bbb86 2022-03-07 thomas @@ -1 +1,2 @@
608 069bbb86 2022-03-07 thomas +hatsuseno
612 069bbb86 2022-03-07 thomas echo "M alpha" > $testroot/stdout.expected
614 069bbb86 2022-03-07 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
616 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
617 069bbb86 2022-03-07 thomas test_done $testroot $ret
621 069bbb86 2022-03-07 thomas cmp -s $testroot/stdout.expected $testroot/stdout
623 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
624 069bbb86 2022-03-07 thomas diff -u $testroot/stdout.expected $testroot/stdout
625 069bbb86 2022-03-07 thomas test_done $testroot $ret
629 069bbb86 2022-03-07 thomas echo hatsuseno > $testroot/wt/alpha.expected
630 069bbb86 2022-03-07 thomas echo alpha >> $testroot/wt/alpha.expected
631 069bbb86 2022-03-07 thomas cmp -s $testroot/wt/alpha.expected $testroot/wt/alpha
633 10cdd9aa 2022-03-08 thomas if [ $ret -ne 0 ]; then
634 069bbb86 2022-03-07 thomas diff -u $testroot/wt/alpha.expected $testroot/wt/alpha
636 069bbb86 2022-03-07 thomas test_done $testroot $ret
639 bb2ad8ff 2022-03-13 thomas test_patch_rename() {
640 bb2ad8ff 2022-03-13 thomas local testroot=`test_init patch_rename`
642 bb2ad8ff 2022-03-13 thomas got checkout $testroot/repo $testroot/wt > /dev/null
644 bb2ad8ff 2022-03-13 thomas if [ $ret -ne 0 ]; then
645 bb2ad8ff 2022-03-13 thomas test_done $testroot $ret
649 bb2ad8ff 2022-03-13 thomas cat <<EOF > $testroot/wt/patch
650 8afe1f71 2022-05-12 thomas diff --git a/beta b/iota
651 8afe1f71 2022-05-12 thomas similarity index 100%
652 8afe1f71 2022-05-12 thomas rename from beta
653 8afe1f71 2022-05-12 thomas rename to iota
654 be53ddb1 2022-03-22 thomas diff --git a/alpha b/eta
655 be53ddb1 2022-03-22 thomas --- a/alpha
656 be53ddb1 2022-03-22 thomas +++ b/eta
657 8afe1f71 2022-05-12 thomas @@ -1 +1 @@
662 8afe1f71 2022-05-12 thomas echo 'D beta' > $testroot/stdout.expected
663 8afe1f71 2022-05-12 thomas echo 'A iota' >> $testroot/stdout.expected
664 8afe1f71 2022-05-12 thomas echo 'D alpha' >> $testroot/stdout.expected
665 8afe1f71 2022-05-12 thomas echo 'A eta' >> $testroot/stdout.expected
667 bb2ad8ff 2022-03-13 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
669 bb2ad8ff 2022-03-13 thomas if [ $ret -ne 0 ]; then
670 bb2ad8ff 2022-03-13 thomas test_done $testroot $ret
674 bb2ad8ff 2022-03-13 thomas cmp -s $testroot/stdout.expected $testroot/stdout
676 bb2ad8ff 2022-03-13 thomas if [ $ret -ne 0 ]; then
677 bb2ad8ff 2022-03-13 thomas diff -u $testroot/stdout.expected $testroot/stdout
678 bb2ad8ff 2022-03-13 thomas test_done $testroot $ret
682 8afe1f71 2022-05-12 thomas if [ -f $testroot/wt/alpha -o -f $testroot/wt/beta ]; then
683 8afe1f71 2022-05-12 thomas echo "alpha or beta were not removed" >&2
684 bb2ad8ff 2022-03-13 thomas test_done $testroot 1
687 8afe1f71 2022-05-12 thomas if [ ! -f $testroot/wt/iota -o ! -f $testroot/wt/eta ]; then
688 8afe1f71 2022-05-12 thomas echo "iota or eta were not created" >&2
689 bb2ad8ff 2022-03-13 thomas test_done $testroot 1
693 8afe1f71 2022-05-12 thomas echo beta > $testroot/wt/iota.expected
694 8afe1f71 2022-05-12 thomas cmp -s $testroot/wt/iota.expected $testroot/wt/iota
696 bb2ad8ff 2022-03-13 thomas if [ $ret -ne 0 ]; then
697 8afe1f71 2022-05-12 thomas diff -u $testroot/wt/iota.expected $testroot/wt/iota
698 bb2ad8ff 2022-03-13 thomas test_done $testroot $ret
702 8afe1f71 2022-05-12 thomas echo eta > $testroot/wt/eta.expected
703 8afe1f71 2022-05-12 thomas cmp -s $testroot/wt/eta.expected $testroot/wt/eta
705 bb2ad8ff 2022-03-13 thomas if [ $ret -ne 0 ]; then
706 8afe1f71 2022-05-12 thomas diff -u $testroot/wt/eta.expected $testroot/wt/eta
707 bb2ad8ff 2022-03-13 thomas test_done $testroot $ret
711 bb2ad8ff 2022-03-13 thomas test_done $testroot $ret
714 10e55613 2022-03-22 thomas test_patch_illegal_status() {
715 10e55613 2022-03-22 thomas local testroot=`test_init patch_illegal_status`
717 10e55613 2022-03-22 thomas got checkout $testroot/repo $testroot/wt > /dev/null
719 10e55613 2022-03-22 thomas if [ $ret -ne 0 ]; then
720 10e55613 2022-03-22 thomas test_done $testroot $ret
724 49114f01 2022-03-22 thomas # try to patch an obstructed file, add a versioned one, edit a
725 49114f01 2022-03-22 thomas # non existent file and an unversioned one, and remove a
726 49114f01 2022-03-22 thomas # non existent file.
727 10e55613 2022-03-22 thomas cat <<EOF > $testroot/wt/patch
728 49114f01 2022-03-22 thomas --- alpha
729 49114f01 2022-03-22 thomas +++ alpha
730 49114f01 2022-03-22 thomas @@ -1 +1,2 @@
732 49114f01 2022-03-22 thomas +was edited
733 49114f01 2022-03-22 thomas --- /dev/null
735 49114f01 2022-03-22 thomas @@ -0,0 +1 @@
739 10e55613 2022-03-22 thomas @@ -1 +1 @@
742 49114f01 2022-03-22 thomas --- kappa
743 49114f01 2022-03-22 thomas +++ kappa
744 49114f01 2022-03-22 thomas @@ -1 +1 @@
747 49114f01 2022-03-22 thomas --- lambda
748 49114f01 2022-03-22 thomas +++ /dev/null
749 49114f01 2022-03-22 thomas @@ -1 +0,0 @@
753 49114f01 2022-03-22 thomas echo kappa > $testroot/wt/kappa
754 10e55613 2022-03-22 thomas rm $testroot/wt/alpha
755 10e55613 2022-03-22 thomas mkdir $testroot/wt/alpha
757 49114f01 2022-03-22 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout \
758 10e55613 2022-03-22 thomas 2> $testroot/stderr
760 10e55613 2022-03-22 thomas if [ $ret -eq 0 ]; then
761 10e55613 2022-03-22 thomas echo "edited a missing file" >&2
762 10e55613 2022-03-22 thomas test_done $testroot $ret
766 49114f01 2022-03-22 thomas cat <<EOF > $testroot/stdout.expected
774 49114f01 2022-03-22 thomas cat <<EOF > $testroot/stderr.expected
775 49114f01 2022-03-22 thomas got: alpha: file has unexpected status
776 49114f01 2022-03-22 thomas got: beta: file has unexpected status
777 49114f01 2022-03-22 thomas got: iota: No such file or directory
778 49114f01 2022-03-22 thomas got: kappa: file has unexpected status
779 49114f01 2022-03-22 thomas got: lambda: No such file or directory
780 49114f01 2022-03-22 thomas got: patch failed to apply
783 49114f01 2022-03-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
785 49114f01 2022-03-22 thomas if [ $ret -ne 0 ]; then
786 49114f01 2022-03-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
787 10e55613 2022-03-22 thomas test_done $testroot $ret
791 10e55613 2022-03-22 thomas cmp -s $testroot/stderr.expected $testroot/stderr
793 49114f01 2022-03-22 thomas if [ $ret -ne 0 ]; then
794 10e55613 2022-03-22 thomas diff -u $testroot/stderr.expected $testroot/stderr
795 814624e7 2022-03-22 thomas test_done $testroot $ret
799 814624e7 2022-03-22 thomas (cd $testroot/wt && got status) > $testroot/stdout
800 814624e7 2022-03-22 thomas cat <<EOF > $testroot/stdout.expected
806 814624e7 2022-03-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
808 814624e7 2022-03-22 thomas if [ $ret -ne 0 ]; then
809 814624e7 2022-03-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
811 eaf99875 2022-03-22 thomas test_done $testroot $ret
814 eaf99875 2022-03-22 thomas test_patch_nop() {
815 eaf99875 2022-03-22 thomas local testroot=`test_init patch_nop`
817 eaf99875 2022-03-22 thomas got checkout $testroot/repo $testroot/wt > /dev/null
819 eaf99875 2022-03-22 thomas if [ $ret -ne 0 ]; then
820 eaf99875 2022-03-22 thomas test_done $testroot $ret
824 eaf99875 2022-03-22 thomas cat <<EOF > $testroot/wt/patch
825 eaf99875 2022-03-22 thomas --- alpha
826 eaf99875 2022-03-22 thomas +++ alpha
827 eaf99875 2022-03-22 thomas @@ -1 +1 @@
829 eaf99875 2022-03-22 thomas +cafe alpha
831 eaf99875 2022-03-22 thomas +++ /dev/null
832 eaf99875 2022-03-22 thomas @@ -1 +0,0 @@
834 be53ddb1 2022-03-22 thomas diff --git a/gamma/delta b/gamma/delta.new
835 eaf99875 2022-03-22 thomas --- gamma/delta
836 eaf99875 2022-03-22 thomas +++ gamma/delta.new
837 eaf99875 2022-03-22 thomas @@ -1 +1 @@
839 eaf99875 2022-03-22 thomas +delta updated and renamed!
842 eaf99875 2022-03-22 thomas (cd $testroot/wt && got patch -n patch)
844 eaf99875 2022-03-22 thomas if [ $ret -ne 0 ]; then
845 eaf99875 2022-03-22 thomas test_done $testroot $ret
849 eaf99875 2022-03-22 thomas # remove the patch to avoid the ? entry
850 eaf99875 2022-03-22 thomas rm $testroot/wt/patch
852 eaf99875 2022-03-22 thomas (cd $testroot/wt && got status) > $testroot/stdout
854 eaf99875 2022-03-22 thomas if [ $ret -ne 0 ]; then
855 eaf99875 2022-03-22 thomas test_done $testroot $ret
859 eaf99875 2022-03-22 thomas echo -n > $testroot/stdout.expected
860 eaf99875 2022-03-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
862 eaf99875 2022-03-22 thomas if [ $ret -ne 0 ]; then
863 eaf99875 2022-03-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
865 10e55613 2022-03-22 thomas test_done $testroot $ret
868 da09d8ed 2022-03-22 thomas test_patch_preserve_perm() {
869 da09d8ed 2022-03-22 thomas local testroot=`test_init patch_preserve_perm`
871 da09d8ed 2022-03-22 thomas got checkout $testroot/repo $testroot/wt > /dev/null
873 da09d8ed 2022-03-22 thomas if [ $ret -ne 0 ]; then
874 da09d8ed 2022-03-22 thomas test_done $testroot $ret
878 da09d8ed 2022-03-22 thomas chmod +x $testroot/wt/alpha
879 da09d8ed 2022-03-22 thomas (cd $testroot/wt && got commit -m 'alpha executable') > /dev/null
881 da09d8ed 2022-03-22 thomas if [ $ret -ne 0 ]; then
882 da09d8ed 2022-03-22 thomas test_done $testroot $ret
886 da09d8ed 2022-03-22 thomas cat <<EOF > $testroot/wt/patch
887 da09d8ed 2022-03-22 thomas --- alpha
888 da09d8ed 2022-03-22 thomas +++ alpha
889 da09d8ed 2022-03-22 thomas @@ -1 +1,2 @@
891 da09d8ed 2022-03-22 thomas +was edited
894 da09d8ed 2022-03-22 thomas (cd $testroot/wt && got patch patch) > /dev/null
896 da09d8ed 2022-03-22 thomas if [ $ret -ne 0 ]; then
897 da09d8ed 2022-03-22 thomas test_done $testroot $ret
901 da09d8ed 2022-03-22 thomas if [ ! -x $testroot/wt/alpha ]; then
902 da09d8ed 2022-03-22 thomas echo "alpha is no more executable!" >&2
903 da09d8ed 2022-03-22 thomas test_done $testroot 1
906 e0c1f81c 2022-03-22 thomas test_done $testroot 0
909 e0c1f81c 2022-03-22 thomas test_patch_create_dirs() {
910 e0c1f81c 2022-03-22 thomas local testroot=`test_init patch_create_dirs`
912 e0c1f81c 2022-03-22 thomas got checkout $testroot/repo $testroot/wt > /dev/null
914 e0c1f81c 2022-03-22 thomas if [ $ret -ne 0 ]; then
915 e0c1f81c 2022-03-22 thomas test_done $testroot $ret
919 e0c1f81c 2022-03-22 thomas cat <<EOF > $testroot/wt/patch
920 e0c1f81c 2022-03-22 thomas --- /dev/null
921 e0c1f81c 2022-03-22 thomas +++ iota/kappa/lambda
922 e0c1f81c 2022-03-22 thomas @@ -0,0 +1 @@
926 e0c1f81c 2022-03-22 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
928 e0c1f81c 2022-03-22 thomas if [ $ret -ne 0 ]; then
929 e0c1f81c 2022-03-22 thomas test_done $testroot $ret
933 e0c1f81c 2022-03-22 thomas echo 'A iota/kappa/lambda' >> $testroot/stdout.expected
934 e0c1f81c 2022-03-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
936 e0c1f81c 2022-03-22 thomas if [ $ret -ne 0 ]; then
937 e0c1f81c 2022-03-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
938 e0c1f81c 2022-03-22 thomas test_done $testroot $ret
942 e0c1f81c 2022-03-22 thomas if [ ! -f $testroot/wt/iota/kappa/lambda ]; then
943 e0c1f81c 2022-03-22 thomas echo "file not created!" >&2
944 e0c1f81c 2022-03-22 thomas test_done $testroot $ret
947 da09d8ed 2022-03-22 thomas test_done $testroot 0
950 49114f01 2022-03-22 thomas test_patch_with_offset() {
951 49114f01 2022-03-22 thomas local testroot=`test_init patch_with_offset`
953 49114f01 2022-03-22 thomas got checkout $testroot/repo $testroot/wt > /dev/null
955 49114f01 2022-03-22 thomas if [ $ret -ne 0 ]; then
956 49114f01 2022-03-22 thomas test_done $testroot $ret
960 49114f01 2022-03-22 thomas cat <<EOF > $testroot/wt/patch
961 49114f01 2022-03-22 thomas --- numbers
962 49114f01 2022-03-22 thomas +++ numbers
963 49114f01 2022-03-22 thomas @@ -47,7 +47,7 @@
968 49114f01 2022-03-22 thomas +midway tru it!
972 49114f01 2022-03-22 thomas @@ -87,7 +87,7 @@
977 49114f01 2022-03-22 thomas +almost there!
983 49114f01 2022-03-22 thomas jot 100 > $testroot/wt/numbers
984 49114f01 2022-03-22 thomas ed $testroot/wt/numbers <<EOF > /dev/null 2> /dev/null
986 49114f01 2022-03-22 thomas 50r !jot 20
991 49114f01 2022-03-22 thomas (cd $testroot/wt && got add numbers && got commit -m '+numbers') \
992 49114f01 2022-03-22 thomas > /dev/null
994 49114f01 2022-03-22 thomas if [ $ret -ne 0 ]; then
995 49114f01 2022-03-22 thomas test_done $testroot $ret
999 49114f01 2022-03-22 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
1001 49114f01 2022-03-22 thomas if [ $ret -ne 0 ]; then
1002 49114f01 2022-03-22 thomas test_done $testroot/wt $ret
1003 49114f01 2022-03-22 thomas return 1
1006 49114f01 2022-03-22 thomas cat <<EOF > $testroot/stdout.expected
1007 49114f01 2022-03-22 thomas M numbers
1008 49114f01 2022-03-22 thomas @@ -47,7 +47,7 @@ applied with offset -10
1009 49114f01 2022-03-22 thomas @@ -87,7 +87,7 @@ applied with offset 10
1012 be53ddb1 2022-03-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1014 be53ddb1 2022-03-22 thomas if [ $ret -ne 0 ]; then
1015 be53ddb1 2022-03-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1017 be53ddb1 2022-03-22 thomas test_done $testroot $ret
1020 be53ddb1 2022-03-22 thomas test_patch_prefer_new_path() {
1021 be53ddb1 2022-03-22 thomas local testroot=`test_init patch_orig`
1023 be53ddb1 2022-03-22 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1025 be53ddb1 2022-03-22 thomas if [ $ret -ne 0 ]; then
1026 be53ddb1 2022-03-22 thomas test_done $testroot $ret
1027 be53ddb1 2022-03-22 thomas return 1
1030 be53ddb1 2022-03-22 thomas cat <<EOF > $testroot/wt/patch
1031 be53ddb1 2022-03-22 thomas --- alpha.orig
1032 be53ddb1 2022-03-22 thomas +++ alpha
1033 be53ddb1 2022-03-22 thomas @@ -1 +1,2 @@
1035 be53ddb1 2022-03-22 thomas +was edited
1038 be53ddb1 2022-03-22 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
1040 be53ddb1 2022-03-22 thomas if [ $ret -ne 0 ]; then
1041 be53ddb1 2022-03-22 thomas test_done $testroot $ret
1042 be53ddb1 2022-03-22 thomas return 1
1045 e1c219c8 2022-04-22 thomas echo 'M alpha' > $testroot/stdout.expected
1046 49114f01 2022-03-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1048 49114f01 2022-03-22 thomas if [ $ret -ne 0 ]; then
1049 49114f01 2022-03-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1051 49114f01 2022-03-22 thomas test_done $testroot $ret
1054 ff7f34d3 2022-03-22 thomas test_patch_no_newline() {
1055 ff7f34d3 2022-03-22 thomas local testroot=`test_init patch_no_newline`
1057 ff7f34d3 2022-03-22 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1059 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1060 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1061 ff7f34d3 2022-03-22 thomas return 1
1064 ff7f34d3 2022-03-22 thomas cat <<EOF > $testroot/wt/patch
1065 ff7f34d3 2022-03-22 thomas --- /dev/null
1067 ff7f34d3 2022-03-22 thomas @@ -0,0 +1 @@
1069 ff7f34d3 2022-03-22 thomas \ No newline at end of file
1072 ff7f34d3 2022-03-22 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
1074 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1075 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1076 ff7f34d3 2022-03-22 thomas return 1
1079 ff7f34d3 2022-03-22 thomas echo "A eta" > $testroot/stdout.expected
1080 ff7f34d3 2022-03-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1082 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1083 ff7f34d3 2022-03-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1084 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1085 ff7f34d3 2022-03-22 thomas return 1
1088 ff7f34d3 2022-03-22 thomas echo -n eta > $testroot/wt/eta.expected
1089 ff7f34d3 2022-03-22 thomas cmp -s $testroot/wt/eta.expected $testroot/wt/eta
1091 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1092 ff7f34d3 2022-03-22 thomas diff -u $testroot/wt/eta.expected $testroot/wt/eta
1093 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1094 ff7f34d3 2022-03-22 thomas return 1
1097 ff7f34d3 2022-03-22 thomas (cd $testroot/wt && got commit -m 'add eta') > /dev/null
1099 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1100 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1101 ff7f34d3 2022-03-22 thomas return 1
1104 ff7f34d3 2022-03-22 thomas cat <<EOF > $testroot/wt/patch
1107 ff7f34d3 2022-03-22 thomas @@ -1 +1 @@
1109 ff7f34d3 2022-03-22 thomas \ No newline at end of file
1111 ff7f34d3 2022-03-22 thomas \ No newline at end of file
1114 ff7f34d3 2022-03-22 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
1116 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1117 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1118 ff7f34d3 2022-03-22 thomas return 1
1121 ff7f34d3 2022-03-22 thomas echo "M eta" > $testroot/stdout.expected
1122 ff7f34d3 2022-03-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1124 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1125 ff7f34d3 2022-03-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1126 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1127 ff7f34d3 2022-03-22 thomas return 1
1130 ff7f34d3 2022-03-22 thomas echo -n ETA > $testroot/wt/eta.expected
1131 ff7f34d3 2022-03-22 thomas cmp -s $testroot/wt/eta.expected $testroot/wt/eta
1133 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1134 ff7f34d3 2022-03-22 thomas diff -u $testroot/wt/eta.expected $testroot/wt/eta
1135 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1136 ff7f34d3 2022-03-22 thomas return 1
1139 ff7f34d3 2022-03-22 thomas (cd $testroot/wt && got commit -m 'edit eta') > /dev/null
1141 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1142 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1143 ff7f34d3 2022-03-22 thomas return 1
1146 ff7f34d3 2022-03-22 thomas cat <<EOF > $testroot/wt/patch
1149 ff7f34d3 2022-03-22 thomas @@ -1 +1 @@
1151 ff7f34d3 2022-03-22 thomas \ No newline at end of file
1155 ff7f34d3 2022-03-22 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
1157 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1158 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1159 ff7f34d3 2022-03-22 thomas return 1
1162 ff7f34d3 2022-03-22 thomas echo "M eta" > $testroot/stdout.expected
1163 ff7f34d3 2022-03-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1165 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1166 ff7f34d3 2022-03-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1167 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1168 ff7f34d3 2022-03-22 thomas return 1
1171 ff7f34d3 2022-03-22 thomas echo eta > $testroot/wt/eta.expected
1172 ff7f34d3 2022-03-22 thomas cmp -s $testroot/wt/eta.expected $testroot/wt/eta
1174 ff7f34d3 2022-03-22 thomas if [ $ret -ne 0 ]; then
1175 ff7f34d3 2022-03-22 thomas diff -u $testroot/wt/eta.expected $testroot/wt/eta
1177 ff7f34d3 2022-03-22 thomas test_done $testroot $ret
1180 d9db2ff9 2022-04-16 thomas test_patch_strip() {
1181 d9db2ff9 2022-04-16 thomas local testroot=`test_init patch_strip`
1183 d9db2ff9 2022-04-16 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1185 d9db2ff9 2022-04-16 thomas if [ $ret -ne 0 ]; then
1186 d9db2ff9 2022-04-16 thomas test_done $testroot $ret
1187 d9db2ff9 2022-04-16 thomas return 1
1190 d9db2ff9 2022-04-16 thomas cat <<EOF > $testroot/wt/patch
1191 d9db2ff9 2022-04-16 thomas --- foo/bar/alpha.orig
1192 d9db2ff9 2022-04-16 thomas +++ foo/bar/alpha
1193 d9db2ff9 2022-04-16 thomas @@ -1 +1 @@
1198 d9db2ff9 2022-04-16 thomas (cd $testroot/wt && got patch -p2 patch) > $testroot/stdout
1200 d9db2ff9 2022-04-16 thomas if [ $ret -ne 0 ]; then
1201 d9db2ff9 2022-04-16 thomas test_done $testroot $ret
1202 d9db2ff9 2022-04-16 thomas return 1
1205 d9db2ff9 2022-04-16 thomas echo "M alpha" >> $testroot/stdout.expected
1206 d9db2ff9 2022-04-16 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1208 d9db2ff9 2022-04-16 thomas if [ $ret -ne 0 ]; then
1209 d9db2ff9 2022-04-16 thomas diff -u $testroot/stdout.expected $testroot/stdout
1210 d9db2ff9 2022-04-16 thomas test_done $testroot $ret
1211 d9db2ff9 2022-04-16 thomas return 1
1214 d9db2ff9 2022-04-16 thomas (cd $testroot/wt && got revert alpha) > /dev/null 2>&1
1216 d9db2ff9 2022-04-16 thomas if [ $ret -ne 0 ]; then
1217 d9db2ff9 2022-04-16 thomas test_done $testroot $ret
1218 d9db2ff9 2022-04-16 thomas return 1
1221 d9db2ff9 2022-04-16 thomas (cd $testroot/wt && got patch -p3 patch) \
1222 d9db2ff9 2022-04-16 thomas 2> $testroot/stderr
1224 d9db2ff9 2022-04-16 thomas if [ $ret -eq 0 ]; then
1225 d9db2ff9 2022-04-16 thomas echo "stripped more components than available!"
1226 d9db2ff9 2022-04-16 thomas test_done $testroot 1
1227 d9db2ff9 2022-04-16 thomas return 1
1230 d9db2ff9 2022-04-16 thomas cat <<EOF > $testroot/stderr.expected
1231 d9db2ff9 2022-04-16 thomas got: can't strip 1 path-components from foo/bar/alpha: bad path
1234 d9db2ff9 2022-04-16 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1236 d9db2ff9 2022-04-16 thomas if [ $ret -ne 0 ]; then
1237 d9db2ff9 2022-04-16 thomas diff -u $testroot/stderr.expected $testroot/stderr
1239 d9db2ff9 2022-04-16 thomas test_done $testroot 0
1242 72f46891 2022-04-23 thomas test_patch_relative_paths() {
1243 9a49df74 2022-04-23 thomas local testroot=`test_init patch_relative_paths`
1245 72f46891 2022-04-23 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1247 72f46891 2022-04-23 thomas if [ $ret -ne 0 ]; then
1248 72f46891 2022-04-23 thomas test_done $testroot $ret
1249 72f46891 2022-04-23 thomas return 1
1252 72f46891 2022-04-23 thomas cat <<EOF > $testroot/wt/gamma/patch
1253 72f46891 2022-04-23 thomas --- delta
1254 72f46891 2022-04-23 thomas +++ delta
1255 72f46891 2022-04-23 thomas @@ -1 +1 @@
1258 72f46891 2022-04-23 thomas --- /dev/null
1260 72f46891 2022-04-23 thomas @@ -0,0 +1 @@
1264 72f46891 2022-04-23 thomas (cd $testroot/wt/gamma && got patch patch) > $testroot/stdout
1266 72f46891 2022-04-23 thomas if [ $ret -ne 0 ]; then
1267 72f46891 2022-04-23 thomas test_done $testroot $ret
1268 72f46891 2022-04-23 thomas return 1
1271 72f46891 2022-04-23 thomas echo 'M gamma/delta' > $testroot/stdout.expected
1272 72f46891 2022-04-23 thomas echo 'A gamma/eta' >> $testroot/stdout.expected
1274 cfbf5531 2022-04-23 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1276 cfbf5531 2022-04-23 thomas if [ $ret -ne 0 ]; then
1277 cfbf5531 2022-04-23 thomas diff -u $testroot/stdout.expected $testroot/stdout
1279 cfbf5531 2022-04-23 thomas test_done $testroot $ret
1282 cfbf5531 2022-04-23 thomas test_patch_with_path_prefix() {
1283 cfbf5531 2022-04-23 thomas local testroot=`test_init patch_with_path_prefix`
1285 cfbf5531 2022-04-23 thomas got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
1287 cfbf5531 2022-04-23 thomas if [ $ret -ne 0 ]; then
1288 cfbf5531 2022-04-23 thomas test_done $testroot $ret
1289 cfbf5531 2022-04-23 thomas return 1
1292 cfbf5531 2022-04-23 thomas cat <<EOF > $testroot/wt/patch
1293 cfbf5531 2022-04-23 thomas --- delta
1294 cfbf5531 2022-04-23 thomas +++ delta
1295 cfbf5531 2022-04-23 thomas @@ -1 +1 @@
1298 cfbf5531 2022-04-23 thomas --- /dev/null
1300 cfbf5531 2022-04-23 thomas @@ -0,0 +1 @@
1304 cfbf5531 2022-04-23 thomas (cd $testroot/wt && got patch patch) > $testroot/stdout
1306 cfbf5531 2022-04-23 thomas if [ $ret -ne 0 ]; then
1307 cfbf5531 2022-04-23 thomas test_done $testroot $ret
1308 cfbf5531 2022-04-23 thomas return 1
1311 cfbf5531 2022-04-23 thomas echo 'M delta' > $testroot/stdout.expected
1312 cfbf5531 2022-04-23 thomas echo 'A eta' >> $testroot/stdout.expected
1314 cfbf5531 2022-04-23 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1316 cfbf5531 2022-04-23 thomas if [ $ret -ne 0 ]; then
1317 cfbf5531 2022-04-23 thomas diff -u $testroot/stdout.expected $testroot/stdout
1319 cfbf5531 2022-04-23 thomas test_done $testroot $ret
1322 cfbf5531 2022-04-23 thomas test_patch_relpath_with_path_prefix() {
1323 cfbf5531 2022-04-23 thomas local testroot=`test_init patch_relpaths_with_path_prefix`
1325 cfbf5531 2022-04-23 thomas got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
1327 cfbf5531 2022-04-23 thomas if [ $ret -ne 0 ]; then
1328 cfbf5531 2022-04-23 thomas test_done $testroot $ret
1329 cfbf5531 2022-04-23 thomas return 1
1332 cfbf5531 2022-04-23 thomas mkdir -p $testroot/wt/epsilon/zeta/
1334 cfbf5531 2022-04-23 thomas cat <<EOF > $testroot/wt/patch
1335 cfbf5531 2022-04-23 thomas --- /dev/null
1336 cfbf5531 2022-04-23 thomas +++ zeta/theta
1337 cfbf5531 2022-04-23 thomas @@ -0,0 +1 @@
1341 cfbf5531 2022-04-23 thomas (cd $testroot/wt/epsilon/zeta && got patch -p1 $testroot/wt/patch) \
1342 cfbf5531 2022-04-23 thomas > $testroot/stdout
1344 cfbf5531 2022-04-23 thomas if [ $ret -ne 0 ]; then
1345 cfbf5531 2022-04-23 thomas test_done $testroot $ret
1346 cfbf5531 2022-04-23 thomas return 1
1349 cfbf5531 2022-04-23 thomas echo 'A epsilon/zeta/theta' >> $testroot/stdout.expected
1351 72f46891 2022-04-23 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1353 72f46891 2022-04-23 thomas if [ $ret -ne 0 ]; then
1354 72f46891 2022-04-23 thomas diff -u $testroot/stdout.expected $testroot/stdout
1355 cfbf5531 2022-04-23 thomas test_done $testroot $ret
1356 cfbf5531 2022-04-23 thomas return 1
1359 cfbf5531 2022-04-23 thomas echo 'theta' > $testroot/theta.expected
1360 cfbf5531 2022-04-23 thomas cmp -s $testroot/wt/epsilon/zeta/theta $testroot/theta.expected
1362 cfbf5531 2022-04-23 thomas if [ $ret -ne 0 ]; then
1363 cfbf5531 2022-04-23 thomas diff -u $testroot/wt/epsilon/zeta/theta $testroot/theta.expected
1365 72f46891 2022-04-23 thomas test_done $testroot $ret
1368 eaef698f 2022-04-23 thomas test_patch_reverse() {
1369 eaef698f 2022-04-23 thomas local testroot=`test_init patch_reverse`
1371 eaef698f 2022-04-23 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1373 eaef698f 2022-04-23 thomas if [ $ret -ne 0 ]; then
1374 eaef698f 2022-04-23 thomas test_done $testroot $ret
1375 eaef698f 2022-04-23 thomas return 1
1378 eaef698f 2022-04-23 thomas cat <<EOF > $testroot/wt/patch
1379 eaef698f 2022-04-23 thomas --- alpha
1380 eaef698f 2022-04-23 thomas +++ alpha
1381 eaef698f 2022-04-23 thomas @@ -1 +1 @@
1383 eaef698f 2022-04-23 thomas \ No newline at end of file
1387 eaef698f 2022-04-23 thomas (cd $testroot/wt && got patch -R patch) > $testroot/stdout
1389 eaef698f 2022-04-23 thomas if [ $ret -ne 0 ]; then
1390 eaef698f 2022-04-23 thomas test_done $testroot $ret
1391 eaef698f 2022-04-23 thomas return 1
1394 eaef698f 2022-04-23 thomas echo "M alpha" > $testroot/stdout.expected
1395 eaef698f 2022-04-23 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1397 eaef698f 2022-04-23 thomas if [ $ret -ne 0 ]; then
1398 eaef698f 2022-04-23 thomas diff -u $testroot/stdout.expected $testroot/stdout
1399 eaef698f 2022-04-23 thomas test_done $testroot $ret
1400 eaef698f 2022-04-23 thomas return 1
1403 eaef698f 2022-04-23 thomas echo -n ALPHA > $testroot/wt/alpha.expected
1404 eaef698f 2022-04-23 thomas cmp -s $testroot/wt/alpha.expected $testroot/wt/alpha
1406 eaef698f 2022-04-23 thomas if [ $ret -ne 0 ]; then
1407 eaef698f 2022-04-23 thomas diff -u $testroot/wt/alpha.expected $testroot/wt/alpha
1409 eaef698f 2022-04-23 thomas test_done $testroot $ret
1412 069bbb86 2022-03-07 thomas test_parseargs "$@"
1413 069bbb86 2022-03-07 thomas run_test test_patch_simple_add_file
1414 069bbb86 2022-03-07 thomas run_test test_patch_simple_rm_file
1415 069bbb86 2022-03-07 thomas run_test test_patch_simple_edit_file
1416 069bbb86 2022-03-07 thomas run_test test_patch_prepend_line
1417 069bbb86 2022-03-07 thomas run_test test_patch_replace_line
1418 069bbb86 2022-03-07 thomas run_test test_patch_multiple_hunks
1419 069bbb86 2022-03-07 thomas run_test test_patch_multiple_files
1420 069bbb86 2022-03-07 thomas run_test test_patch_dont_apply
1421 069bbb86 2022-03-07 thomas run_test test_patch_malformed
1422 069bbb86 2022-03-07 thomas run_test test_patch_no_patch
1423 069bbb86 2022-03-07 thomas run_test test_patch_equals_for_context
1424 bb2ad8ff 2022-03-13 thomas run_test test_patch_rename
1425 10e55613 2022-03-22 thomas run_test test_patch_illegal_status
1426 eaf99875 2022-03-22 thomas run_test test_patch_nop
1427 da09d8ed 2022-03-22 thomas run_test test_patch_preserve_perm
1428 e0c1f81c 2022-03-22 thomas run_test test_patch_create_dirs
1429 49114f01 2022-03-22 thomas run_test test_patch_with_offset
1430 be53ddb1 2022-03-22 thomas run_test test_patch_prefer_new_path
1431 ff7f34d3 2022-03-22 thomas run_test test_patch_no_newline
1432 d9db2ff9 2022-04-16 thomas run_test test_patch_strip
1433 72f46891 2022-04-23 thomas run_test test_patch_relative_paths
1434 cfbf5531 2022-04-23 thomas run_test test_patch_with_path_prefix
1435 cfbf5531 2022-04-23 thomas run_test test_patch_relpath_with_path_prefix
1436 eaef698f 2022-04-23 thomas run_test test_patch_reverse