3 e9ce266e 2022-03-07 op # Copyright (c) 2022 Omar Polo <op@openbsd.org>
5 e9ce266e 2022-03-07 op # Permission to use, copy, modify, and distribute this software for any
6 e9ce266e 2022-03-07 op # purpose with or without fee is hereby granted, provided that the above
7 e9ce266e 2022-03-07 op # copyright notice and this permission notice appear in all copies.
9 e9ce266e 2022-03-07 op # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 e9ce266e 2022-03-07 op # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 e9ce266e 2022-03-07 op # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 e9ce266e 2022-03-07 op # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 e9ce266e 2022-03-07 op # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 e9ce266e 2022-03-07 op # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 e9ce266e 2022-03-07 op # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 e9ce266e 2022-03-07 op test_patch_simple_add_file() {
20 e9ce266e 2022-03-07 op local testroot=`test_init patch_simple_add_file`
22 e9ce266e 2022-03-07 op got checkout $testroot/repo $testroot/wt > /dev/null
24 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
25 e9ce266e 2022-03-07 op test_done $testroot $ret
29 e9ce266e 2022-03-07 op cat <<EOF > $testroot/wt/patch
36 e9ce266e 2022-03-07 op (cd $testroot/wt && got patch patch) > $testroot/stdout
38 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
39 e9ce266e 2022-03-07 op test_done $testroot $ret
43 e9ce266e 2022-03-07 op echo "A eta" > $testroot/stdout.expected
44 e9ce266e 2022-03-07 op cmp -s $testroot/stdout.expected $testroot/stdout
46 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
47 e9ce266e 2022-03-07 op diff -u $testroot/stdout.expected $testroot/stdout
48 e9ce266e 2022-03-07 op test_done $testroot $ret
52 e9ce266e 2022-03-07 op echo eta > $testroot/wt/eta.expected
53 e9ce266e 2022-03-07 op cmp -s $testroot/wt/eta.expected $testroot/wt/eta
55 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
56 e9ce266e 2022-03-07 op diff -u $testroot/wt/eta.expected $testroot/wt/eta
58 e9ce266e 2022-03-07 op test_done $testroot $ret
61 e9ce266e 2022-03-07 op test_patch_simple_rm_file() {
62 e9ce266e 2022-03-07 op local testroot=`test_init patch_simple_rm_file`
64 e9ce266e 2022-03-07 op got checkout $testroot/repo $testroot/wt > /dev/null
66 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
67 e9ce266e 2022-03-07 op test_done $testroot $ret
71 e9ce266e 2022-03-07 op cat <<EOF > $testroot/wt/patch
78 e9ce266e 2022-03-07 op echo "D alpha" > $testroot/stdout.expected
80 e9ce266e 2022-03-07 op (cd $testroot/wt && got patch patch) > $testroot/stdout
82 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
83 e9ce266e 2022-03-07 op test_done $testroot $ret
87 e9ce266e 2022-03-07 op cmp -s $testroot/stdout.expected $testroot/stdout
89 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
90 e9ce266e 2022-03-07 op diff -u $testroot/stdout.expected $testroot/stdout
91 e9ce266e 2022-03-07 op test_done $testroot $ret
95 e9ce266e 2022-03-07 op if [ -f $testroot/wt/alpha ]; then
97 e9ce266e 2022-03-07 op echo "alpha still exists!"
99 e9ce266e 2022-03-07 op test_done $testroot $ret
102 e9ce266e 2022-03-07 op test_patch_simple_edit_file() {
103 e9ce266e 2022-03-07 op local testroot=`test_init patch_simple_edit_file`
105 e9ce266e 2022-03-07 op got checkout $testroot/repo $testroot/wt > /dev/null
107 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
108 e9ce266e 2022-03-07 op test_done $testroot $ret
112 e9ce266e 2022-03-07 op cat <<EOF > $testroot/wt/patch
117 e9ce266e 2022-03-07 op +alpha is my favourite character
120 e9ce266e 2022-03-07 op echo "M alpha" > $testroot/stdout.expected
122 e9ce266e 2022-03-07 op (cd $testroot/wt && got patch patch) > $testroot/stdout
124 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
125 e9ce266e 2022-03-07 op test_done $testroot $ret
129 e9ce266e 2022-03-07 op cmp -s $testroot/stdout.expected $testroot/stdout
131 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
132 e9ce266e 2022-03-07 op diff -u $testroot/stdout.expected $testroot/stdout
133 e9ce266e 2022-03-07 op test_done $testroot $ret
137 e9ce266e 2022-03-07 op echo 'alpha is my favourite character' > $testroot/wt/alpha.expected
138 e9ce266e 2022-03-07 op cmp -s $testroot/wt/alpha.expected $testroot/wt/alpha
140 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
141 e9ce266e 2022-03-07 op diff -u $testroot/wt/alpha.expected $testroot/wt/alpha
143 e9ce266e 2022-03-07 op test_done $testroot $ret
146 e9ce266e 2022-03-07 op test_patch_prepend_line() {
147 e9ce266e 2022-03-07 op local testroot=`test_init patch_prepend_line`
149 e9ce266e 2022-03-07 op got checkout $testroot/repo $testroot/wt > /dev/null
151 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
152 e9ce266e 2022-03-07 op test_done $testroot $ret
156 e9ce266e 2022-03-07 op cat <<EOF > $testroot/wt/patch
159 e9ce266e 2022-03-07 op @@ -1 +1,2 @@
164 e9ce266e 2022-03-07 op echo "M alpha" > $testroot/stdout.expected
166 e9ce266e 2022-03-07 op (cd $testroot/wt && got patch patch) > $testroot/stdout
168 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
169 e9ce266e 2022-03-07 op test_done $testroot $ret
173 e9ce266e 2022-03-07 op cmp -s $testroot/stdout.expected $testroot/stdout
175 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
176 e9ce266e 2022-03-07 op diff -u $testroot/stdout.expected $testroot/stdout
177 e9ce266e 2022-03-07 op test_done $testroot $ret
181 e9ce266e 2022-03-07 op echo hatsuseno > $testroot/wt/alpha.expected
182 e9ce266e 2022-03-07 op echo alpha >> $testroot/wt/alpha.expected
183 e9ce266e 2022-03-07 op cmp -s $testroot/wt/alpha.expected $testroot/wt/alpha
185 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
186 e9ce266e 2022-03-07 op diff -u $testroot/wt/alpha.expected $testroot/wt/alpha
188 e9ce266e 2022-03-07 op test_done $testroot $ret
191 e9ce266e 2022-03-07 op test_patch_replace_line() {
192 e9ce266e 2022-03-07 op local testroot=`test_init patch_replace_line`
194 e9ce266e 2022-03-07 op got checkout $testroot/repo $testroot/wt > /dev/null
196 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
197 e9ce266e 2022-03-07 op test_done $testroot $ret
201 e9ce266e 2022-03-07 op jot 10 > $testroot/wt/numbers
202 e9ce266e 2022-03-07 op (cd $testroot/wt/ && got add numbers && got ci -m 'add numbers') \
205 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
206 e9ce266e 2022-03-07 op test_done $testroot $ret
210 e9ce266e 2022-03-07 op cat <<EOF > $testroot/wt/patch
213 e9ce266e 2022-03-07 op @@ -3,7 +3,7 @@
224 e9ce266e 2022-03-07 op echo "M numbers" > $testroot/stdout.expected
226 e9ce266e 2022-03-07 op (cd $testroot/wt && got patch patch) > $testroot/stdout
228 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
229 e9ce266e 2022-03-07 op test_done $testroot $ret
233 e9ce266e 2022-03-07 op cmp -s $testroot/stdout.expected $testroot/stdout
235 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
236 e9ce266e 2022-03-07 op diff -u $testroot/stdout.expected $testroot/stdout
237 e9ce266e 2022-03-07 op test_done $testroot $ret
241 e9ce266e 2022-03-07 op jot 10 | sed 's/6/foo/' > $testroot/wt/numbers.expected
242 e9ce266e 2022-03-07 op cmp -s $testroot/wt/numbers.expected $testroot/wt/numbers
244 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
245 e9ce266e 2022-03-07 op diff -u $testroot/wt/numbers.expected $testroot/wt/numbers
247 e9ce266e 2022-03-07 op test_done $testroot $ret
250 e9ce266e 2022-03-07 op test_patch_multiple_hunks() {
251 fd79e2e0 2022-03-08 op local testroot=`test_init patch_replace_multiple_hunks`
253 e9ce266e 2022-03-07 op got checkout $testroot/repo $testroot/wt > /dev/null
255 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
256 e9ce266e 2022-03-07 op test_done $testroot $ret
260 e9ce266e 2022-03-07 op jot 100 > $testroot/wt/numbers
261 e9ce266e 2022-03-07 op (cd $testroot/wt/ && got add numbers && got ci -m 'add numbers') \
264 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
265 e9ce266e 2022-03-07 op test_done $testroot $ret
269 e9ce266e 2022-03-07 op cat <<EOF > $testroot/wt/patch
272 e9ce266e 2022-03-07 op @@ -3,7 +3,7 @@
281 e9ce266e 2022-03-07 op @@ -57,7 +57,7 @@
290 e9ce266e 2022-03-07 op @@ -98,3 +98,6 @@
299 e9ce266e 2022-03-07 op echo "M numbers" > $testroot/stdout.expected
301 e9ce266e 2022-03-07 op (cd $testroot/wt && got patch patch) > $testroot/stdout
303 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
304 e9ce266e 2022-03-07 op test_done $testroot $ret
308 e9ce266e 2022-03-07 op cmp -s $testroot/stdout.expected $testroot/stdout
310 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
311 e9ce266e 2022-03-07 op diff -u $testroot/stdout.expected $testroot/stdout
312 e9ce266e 2022-03-07 op test_done $testroot $ret
316 e9ce266e 2022-03-07 op jot 100 | sed -e 's/^6$/foo/' -e 's/^60$/foo foo/' \
317 e9ce266e 2022-03-07 op > $testroot/wt/numbers.expected
318 e9ce266e 2022-03-07 op echo "101" >> $testroot/wt/numbers.expected
319 e9ce266e 2022-03-07 op echo "102" >> $testroot/wt/numbers.expected
320 e9ce266e 2022-03-07 op echo "..." >> $testroot/wt/numbers.expected
322 e9ce266e 2022-03-07 op cmp -s $testroot/wt/numbers.expected $testroot/wt/numbers
324 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
325 e9ce266e 2022-03-07 op diff -u $testroot/wt/numbers.expected $testroot/wt/numbers
327 e9ce266e 2022-03-07 op test_done $testroot $ret
330 e9ce266e 2022-03-07 op test_patch_multiple_files() {
331 e9ce266e 2022-03-07 op local testroot=`test_init patch_multiple_files`
333 e9ce266e 2022-03-07 op got checkout $testroot/repo $testroot/wt > /dev/null
335 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
336 e9ce266e 2022-03-07 op test_done $testroot $ret
340 e9ce266e 2022-03-07 op cat <<EOF > $testroot/wt/patch
341 e9ce266e 2022-03-07 op --- alpha Mon Mar 7 19:02:07 2022
342 e9ce266e 2022-03-07 op +++ alpha Mon Mar 7 19:01:53 2022
343 e9ce266e 2022-03-07 op @@ -1 +1,3 @@
347 e9ce266e 2022-03-07 op --- beta Mon Mar 7 19:02:11 2022
348 e9ce266e 2022-03-07 op +++ beta Mon Mar 7 19:01:46 2022
349 e9ce266e 2022-03-07 op @@ -1 +1,3 @@
353 e9ce266e 2022-03-07 op --- gamma/delta Mon Mar 7 19:02:17 2022
354 e9ce266e 2022-03-07 op +++ gamma/delta Mon Mar 7 19:01:37 2022
360 e9ce266e 2022-03-07 op echo "M alpha" > $testroot/stdout.expected
361 e9ce266e 2022-03-07 op echo "M beta" >> $testroot/stdout.expected
362 e9ce266e 2022-03-07 op echo "M gamma/delta" >> $testroot/stdout.expected
364 e9ce266e 2022-03-07 op (cd $testroot/wt && got patch patch) > $testroot/stdout
366 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
367 fd79e2e0 2022-03-08 op test_done $testroot $ret
371 e9ce266e 2022-03-07 op cmp -s $testroot/stdout.expected $testroot/stdout
373 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
374 e9ce266e 2022-03-07 op diff -u $testroot/stdout.expected $testroot/stdout
375 e9ce266e 2022-03-07 op test_done $testroot $ret
379 e9ce266e 2022-03-07 op printf 'new\nalpha\navailable\n' > $testroot/wt/alpha.expected
380 e9ce266e 2022-03-07 op printf 'beta\nwas\nimproved\n' > $testroot/wt/beta.expected
381 e9ce266e 2022-03-07 op printf 'delta new\n' > $testroot/wt/gamma/delta.expected
383 e9ce266e 2022-03-07 op for f in alpha beta gamma/delta; do
384 e9ce266e 2022-03-07 op cmp -s $testroot/wt/$f.expected $testroot/wt/$f
386 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
387 e9ce266e 2022-03-07 op diff -u $testroot/wt/$f.expected $testroot/wt/$f
388 e9ce266e 2022-03-07 op test_done $testroot $ret
393 e9ce266e 2022-03-07 op test_done $testroot 0
396 e9ce266e 2022-03-07 op test_patch_dont_apply() {
397 e9ce266e 2022-03-07 op local testroot=`test_init patch_dont_apply`
399 e9ce266e 2022-03-07 op got checkout $testroot/repo $testroot/wt > /dev/null
401 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
402 e9ce266e 2022-03-07 op test_done $testroot $ret
406 5b67f96e 2022-03-13 op jot 100 > $testroot/wt/numbers
407 5b67f96e 2022-03-13 op (cd $testroot/wt && got add numbers && got commit -m 'add numbers') \
410 5b67f96e 2022-03-13 op if [ $ret -ne 0 ]; then
411 5b67f96e 2022-03-13 op test_done $testroot $ret
415 5b67f96e 2022-03-13 op cat <<EOF > $testroot/wt/patch
418 60aa1fa0 2022-03-17 op @@ -1 +1,2 @@
420 60aa1fa0 2022-03-17 op alpha something
422 5b67f96e 2022-03-13 op +++ /dev/null
423 5b67f96e 2022-03-13 op @@ -1,9 +0,0 @@
435 60aa1fa0 2022-03-17 op (cd $testroot/wt && got patch patch) > $testroot/stdout 2> /dev/null
437 5b67f96e 2022-03-13 op if [ $ret -eq 0 ]; then # should fail
438 5b67f96e 2022-03-13 op test_done $testroot 1
442 60aa1fa0 2022-03-17 op cat <<EOF > $testroot/stdout.expected
444 60aa1fa0 2022-03-17 op @@ -1,1 +1,2 @@ hunk failed to apply
446 60aa1fa0 2022-03-17 op @@ -1,9 +0,0 @@ hunk failed to apply
449 60aa1fa0 2022-03-17 op cmp -s $testroot/stdout.expected $testroot/stdout
451 5b67f96e 2022-03-13 op if [ $ret -ne 0 ]; then
452 60aa1fa0 2022-03-17 op diff -u $testroot/stdout.expected $testroot/stdout
454 e9ce266e 2022-03-07 op test_done $testroot $ret
457 e9ce266e 2022-03-07 op test_patch_malformed() {
458 e9ce266e 2022-03-07 op local testroot=`test_init patch_malformed`
460 e9ce266e 2022-03-07 op got checkout $testroot/repo $testroot/wt > /dev/null
462 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
463 e9ce266e 2022-03-07 op test_done $testroot $ret
467 e9ce266e 2022-03-07 op # missing "@@"
468 e9ce266e 2022-03-07 op cat <<EOF > $testroot/wt/patch
476 e9ce266e 2022-03-07 op echo -n > $testroot/stdout.expected
477 e9ce266e 2022-03-07 op echo "got: malformed patch" > $testroot/stderr.expected
479 e9ce266e 2022-03-07 op (cd $testroot/wt && got patch patch) \
480 e9ce266e 2022-03-07 op > $testroot/stdout \
481 e9ce266e 2022-03-07 op 2> $testroot/stderr
483 bfbccd0a 2022-03-08 op if [ $ret -eq 0 ]; then
484 e9ce266e 2022-03-07 op echo "got managed to apply an invalid patch"
485 e9ce266e 2022-03-07 op test_done $testroot 1
489 e9ce266e 2022-03-07 op cmp -s $testroot/stdout.expected $testroot/stdout
491 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
492 e9ce266e 2022-03-07 op diff -u $testroot/stdout.expected $testroot/stdout
493 e9ce266e 2022-03-07 op test_done $testroot $ret
497 e9ce266e 2022-03-07 op cmp -s $testroot/stderr.expected $testroot/stderr
499 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
500 e9ce266e 2022-03-07 op diff -u $testroot/stderr.expected $testroot/stderr
501 e9ce266e 2022-03-07 op test_done $testroot $ret
505 e9ce266e 2022-03-07 op # wrong first character
506 e9ce266e 2022-03-07 op cat <<EOF > $testroot/wt/patch
509 e9ce266e 2022-03-07 op @@ -1 +1,2 @@
514 e9ce266e 2022-03-07 op (cd $testroot/wt && got patch patch) \
515 e9ce266e 2022-03-07 op > $testroot/stdout \
516 e9ce266e 2022-03-07 op 2> $testroot/stderr
518 bfbccd0a 2022-03-08 op if [ $ret -eq 0 ]; then
519 e9ce266e 2022-03-07 op echo "got managed to apply an invalid patch"
520 e9ce266e 2022-03-07 op test_done $testroot 1
524 e9ce266e 2022-03-07 op cmp -s $testroot/stdout.expected $testroot/stdout
526 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
527 e9ce266e 2022-03-07 op diff -u $testroot/stdout.expected $testroot/stdout
528 e9ce266e 2022-03-07 op test_done $testroot $ret
532 e9ce266e 2022-03-07 op cmp -s $testroot/stderr.expected $testroot/stderr
534 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
535 e9ce266e 2022-03-07 op diff -u $testroot/stderr.expected $testroot/stderr
536 e9ce266e 2022-03-07 op test_done $testroot $ret
540 e9ce266e 2022-03-07 op test_done $testroot $ret
543 e9ce266e 2022-03-07 op test_patch_no_patch() {
544 e9ce266e 2022-03-07 op local testroot=`test_init patch_no_patch`
546 e9ce266e 2022-03-07 op got checkout $testroot/repo $testroot/wt > /dev/null
548 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
549 e9ce266e 2022-03-07 op test_done $testroot $ret
553 e9ce266e 2022-03-07 op cat <<EOF > $testroot/wt/patch
557 e9ce266e 2022-03-07 op some other nonsense
560 e9ce266e 2022-03-07 op there's no patch in here!
563 e9ce266e 2022-03-07 op echo -n > $testroot/stdout.expected
564 e9ce266e 2022-03-07 op echo "got: no patch found" > $testroot/stderr.expected
566 e9ce266e 2022-03-07 op (cd $testroot/wt && got patch patch) \
567 e9ce266e 2022-03-07 op > $testroot/stdout \
568 e9ce266e 2022-03-07 op 2> $testroot/stderr
570 bfbccd0a 2022-03-08 op if [ $ret -eq 0 ]; then # should fail
571 e9ce266e 2022-03-07 op test_done $testroot 1
575 e9ce266e 2022-03-07 op cmp -s $testroot/stdout.expected $testroot/stdout
577 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
578 e9ce266e 2022-03-07 op diff -u $testroot/stdout.expected $testroot/stdout
579 e9ce266e 2022-03-07 op test_done $testroot $ret
583 e9ce266e 2022-03-07 op cmp -s $testroot/stderr.expected $testroot/stderr
585 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
586 e9ce266e 2022-03-07 op diff -u $testroot/stderr.expected $testroot/stderr
587 e9ce266e 2022-03-07 op test_done $testroot $ret
591 e9ce266e 2022-03-07 op test_done $testroot $ret
594 e9ce266e 2022-03-07 op test_patch_equals_for_context() {
595 f1d6cebb 2022-04-23 op local testroot=`test_init patch_equals_for_context`
597 e9ce266e 2022-03-07 op got checkout $testroot/repo $testroot/wt > /dev/null
599 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
600 e9ce266e 2022-03-07 op test_done $testroot $ret
604 e9ce266e 2022-03-07 op cat <<EOF > $testroot/wt/patch
607 e9ce266e 2022-03-07 op @@ -1 +1,2 @@
612 e9ce266e 2022-03-07 op echo "M alpha" > $testroot/stdout.expected
614 e9ce266e 2022-03-07 op (cd $testroot/wt && got patch patch) > $testroot/stdout
616 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
617 e9ce266e 2022-03-07 op test_done $testroot $ret
621 e9ce266e 2022-03-07 op cmp -s $testroot/stdout.expected $testroot/stdout
623 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
624 e9ce266e 2022-03-07 op diff -u $testroot/stdout.expected $testroot/stdout
625 e9ce266e 2022-03-07 op test_done $testroot $ret
629 e9ce266e 2022-03-07 op echo hatsuseno > $testroot/wt/alpha.expected
630 e9ce266e 2022-03-07 op echo alpha >> $testroot/wt/alpha.expected
631 e9ce266e 2022-03-07 op cmp -s $testroot/wt/alpha.expected $testroot/wt/alpha
633 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
634 e9ce266e 2022-03-07 op diff -u $testroot/wt/alpha.expected $testroot/wt/alpha
636 e9ce266e 2022-03-07 op test_done $testroot $ret
639 6e96b326 2022-03-12 op test_patch_rename() {
640 6e96b326 2022-03-12 op local testroot=`test_init patch_rename`
642 6e96b326 2022-03-12 op got checkout $testroot/repo $testroot/wt > /dev/null
644 6e96b326 2022-03-12 op if [ $ret -ne 0 ]; then
645 6e96b326 2022-03-12 op test_done $testroot $ret
649 6e96b326 2022-03-12 op cat <<EOF > $testroot/wt/patch
650 4379a9aa 2022-05-02 op diff --git a/beta b/iota
651 4379a9aa 2022-05-02 op similarity index 100%
652 4379a9aa 2022-05-02 op rename from beta
653 4379a9aa 2022-05-02 op rename to iota
654 7a30b5cb 2022-03-20 op diff --git a/alpha b/eta
662 4379a9aa 2022-05-02 op echo 'D beta' > $testroot/stdout.expected
663 4379a9aa 2022-05-02 op echo 'A iota' >> $testroot/stdout.expected
664 4379a9aa 2022-05-02 op echo 'D alpha' >> $testroot/stdout.expected
665 4379a9aa 2022-05-02 op echo 'A eta' >> $testroot/stdout.expected
667 6e96b326 2022-03-12 op (cd $testroot/wt && got patch patch) > $testroot/stdout
669 6e96b326 2022-03-12 op if [ $ret -ne 0 ]; then
670 6e96b326 2022-03-12 op test_done $testroot $ret
674 6e96b326 2022-03-12 op cmp -s $testroot/stdout.expected $testroot/stdout
676 6e96b326 2022-03-12 op if [ $ret -ne 0 ]; then
677 6e96b326 2022-03-12 op diff -u $testroot/stdout.expected $testroot/stdout
678 6e96b326 2022-03-12 op test_done $testroot $ret
682 4379a9aa 2022-05-02 op if [ -f $testroot/wt/alpha -o -f $testroot/wt/beta ]; then
683 4379a9aa 2022-05-02 op echo "alpha or beta were not removed" >&2
684 6e96b326 2022-03-12 op test_done $testroot 1
687 4379a9aa 2022-05-02 op if [ ! -f $testroot/wt/iota -o ! -f $testroot/wt/eta ]; then
688 4379a9aa 2022-05-02 op echo "iota or eta were not created" >&2
689 6e96b326 2022-03-12 op test_done $testroot 1
693 4379a9aa 2022-05-02 op echo beta > $testroot/wt/iota.expected
694 4379a9aa 2022-05-02 op cmp -s $testroot/wt/iota.expected $testroot/wt/iota
696 6e96b326 2022-03-12 op if [ $ret -ne 0 ]; then
697 4379a9aa 2022-05-02 op diff -u $testroot/wt/iota.expected $testroot/wt/iota
698 6e96b326 2022-03-12 op test_done $testroot $ret
702 4379a9aa 2022-05-02 op echo eta > $testroot/wt/eta.expected
703 4379a9aa 2022-05-02 op cmp -s $testroot/wt/eta.expected $testroot/wt/eta
705 6e96b326 2022-03-12 op if [ $ret -ne 0 ]; then
706 4379a9aa 2022-05-02 op diff -u $testroot/wt/eta.expected $testroot/wt/eta
707 6e96b326 2022-03-12 op test_done $testroot $ret
711 6e96b326 2022-03-12 op test_done $testroot $ret
714 dbda770b 2022-03-13 op test_patch_illegal_status() {
715 dbda770b 2022-03-13 op local testroot=`test_init patch_illegal_status`
717 dbda770b 2022-03-13 op got checkout $testroot/repo $testroot/wt > /dev/null
719 dbda770b 2022-03-13 op if [ $ret -ne 0 ]; then
720 dbda770b 2022-03-13 op test_done $testroot $ret
724 60aa1fa0 2022-03-17 op # try to patch an obstructed file, add a versioned one, edit a
725 60aa1fa0 2022-03-17 op # non existent file and an unversioned one, and remove a
726 60aa1fa0 2022-03-17 op # non existent file.
727 dbda770b 2022-03-13 op cat <<EOF > $testroot/wt/patch
730 60aa1fa0 2022-03-17 op @@ -1 +1,2 @@
733 60aa1fa0 2022-03-17 op --- /dev/null
735 60aa1fa0 2022-03-17 op @@ -0,0 +1 @@
748 60aa1fa0 2022-03-17 op +++ /dev/null
749 60aa1fa0 2022-03-17 op @@ -1 +0,0 @@
753 60aa1fa0 2022-03-17 op echo kappa > $testroot/wt/kappa
754 dbda770b 2022-03-13 op rm $testroot/wt/alpha
755 dbda770b 2022-03-13 op mkdir $testroot/wt/alpha
757 60aa1fa0 2022-03-17 op (cd $testroot/wt && got patch patch) > $testroot/stdout \
758 dbda770b 2022-03-13 op 2> $testroot/stderr
760 dbda770b 2022-03-13 op if [ $ret -eq 0 ]; then
761 dbda770b 2022-03-13 op echo "edited a missing file" >&2
762 dbda770b 2022-03-13 op test_done $testroot $ret
766 60aa1fa0 2022-03-17 op cat <<EOF > $testroot/stdout.expected
774 60aa1fa0 2022-03-17 op cat <<EOF > $testroot/stderr.expected
775 60aa1fa0 2022-03-17 op got: alpha: file has unexpected status
776 60aa1fa0 2022-03-17 op got: beta: file has unexpected status
777 60aa1fa0 2022-03-17 op got: iota: No such file or directory
778 60aa1fa0 2022-03-17 op got: kappa: file has unexpected status
779 60aa1fa0 2022-03-17 op got: lambda: No such file or directory
780 60aa1fa0 2022-03-17 op got: patch failed to apply
783 60aa1fa0 2022-03-17 op cmp -s $testroot/stdout.expected $testroot/stdout
785 60aa1fa0 2022-03-17 op if [ $ret -ne 0 ]; then
786 60aa1fa0 2022-03-17 op diff -u $testroot/stdout.expected $testroot/stdout
787 dbda770b 2022-03-13 op test_done $testroot $ret
791 dbda770b 2022-03-13 op cmp -s $testroot/stderr.expected $testroot/stderr
793 60aa1fa0 2022-03-17 op if [ $ret -ne 0 ]; then
794 dbda770b 2022-03-13 op diff -u $testroot/stderr.expected $testroot/stderr
795 78f5ac24 2022-03-19 op test_done $testroot $ret
799 78f5ac24 2022-03-19 op (cd $testroot/wt && got status) > $testroot/stdout
800 78f5ac24 2022-03-19 op cat <<EOF > $testroot/stdout.expected
806 78f5ac24 2022-03-19 op cmp -s $testroot/stdout.expected $testroot/stdout
808 78f5ac24 2022-03-19 op if [ $ret -ne 0 ]; then
809 78f5ac24 2022-03-19 op diff -u $testroot/stdout.expected $testroot/stdout
811 899fcfdf 2022-03-13 op test_done $testroot $ret
814 899fcfdf 2022-03-13 op test_patch_nop() {
815 899fcfdf 2022-03-13 op local testroot=`test_init patch_nop`
817 899fcfdf 2022-03-13 op got checkout $testroot/repo $testroot/wt > /dev/null
819 899fcfdf 2022-03-13 op if [ $ret -ne 0 ]; then
820 899fcfdf 2022-03-13 op test_done $testroot $ret
824 899fcfdf 2022-03-13 op cat <<EOF > $testroot/wt/patch
831 899fcfdf 2022-03-13 op +++ /dev/null
832 899fcfdf 2022-03-13 op @@ -1 +0,0 @@
834 7a30b5cb 2022-03-20 op diff --git a/gamma/delta b/gamma/delta.new
835 899fcfdf 2022-03-13 op --- gamma/delta
836 899fcfdf 2022-03-13 op +++ gamma/delta.new
839 899fcfdf 2022-03-13 op +delta updated and renamed!
842 899fcfdf 2022-03-13 op (cd $testroot/wt && got patch -n patch)
844 899fcfdf 2022-03-13 op if [ $ret -ne 0 ]; then
845 899fcfdf 2022-03-13 op test_done $testroot $ret
849 899fcfdf 2022-03-13 op # remove the patch to avoid the ? entry
850 899fcfdf 2022-03-13 op rm $testroot/wt/patch
852 899fcfdf 2022-03-13 op (cd $testroot/wt && got status) > $testroot/stdout
854 899fcfdf 2022-03-13 op if [ $ret -ne 0 ]; then
855 899fcfdf 2022-03-13 op test_done $testroot $ret
859 899fcfdf 2022-03-13 op echo -n > $testroot/stdout.expected
860 899fcfdf 2022-03-13 op cmp -s $testroot/stdout.expected $testroot/stdout
862 899fcfdf 2022-03-13 op if [ $ret -ne 0 ]; then
863 899fcfdf 2022-03-13 op diff -u $testroot/stdout.expected $testroot/stdout
865 dbda770b 2022-03-13 op test_done $testroot $ret
868 2be5e1a2 2022-03-16 op test_patch_preserve_perm() {
869 2be5e1a2 2022-03-16 op local testroot=`test_init patch_preserve_perm`
871 2be5e1a2 2022-03-16 op got checkout $testroot/repo $testroot/wt > /dev/null
873 2be5e1a2 2022-03-16 op if [ $ret -ne 0 ]; then
874 2be5e1a2 2022-03-16 op test_done $testroot $ret
878 2be5e1a2 2022-03-16 op chmod +x $testroot/wt/alpha
879 2be5e1a2 2022-03-16 op (cd $testroot/wt && got commit -m 'alpha executable') > /dev/null
881 2be5e1a2 2022-03-16 op if [ $ret -ne 0 ]; then
882 2be5e1a2 2022-03-16 op test_done $testroot $ret
886 2be5e1a2 2022-03-16 op cat <<EOF > $testroot/wt/patch
889 2be5e1a2 2022-03-16 op @@ -1 +1,2 @@
894 2be5e1a2 2022-03-16 op (cd $testroot/wt && got patch patch) > /dev/null
896 2be5e1a2 2022-03-16 op if [ $ret -ne 0 ]; then
897 2be5e1a2 2022-03-16 op test_done $testroot $ret
901 2be5e1a2 2022-03-16 op if [ ! -x $testroot/wt/alpha ]; then
902 2be5e1a2 2022-03-16 op echo "alpha is no more executable!" >&2
903 2be5e1a2 2022-03-16 op test_done $testroot 1
906 95d68340 2022-03-16 op test_done $testroot 0
909 95d68340 2022-03-16 op test_patch_create_dirs() {
910 95d68340 2022-03-16 op local testroot=`test_init patch_create_dirs`
912 95d68340 2022-03-16 op got checkout $testroot/repo $testroot/wt > /dev/null
914 95d68340 2022-03-16 op if [ $ret -ne 0 ]; then
915 95d68340 2022-03-16 op test_done $testroot $ret
919 95d68340 2022-03-16 op cat <<EOF > $testroot/wt/patch
920 95d68340 2022-03-16 op --- /dev/null
921 95d68340 2022-03-16 op +++ iota/kappa/lambda
922 95d68340 2022-03-16 op @@ -0,0 +1 @@
926 95d68340 2022-03-16 op (cd $testroot/wt && got patch patch) > $testroot/stdout
928 95d68340 2022-03-16 op if [ $ret -ne 0 ]; then
929 95d68340 2022-03-16 op test_done $testroot $ret
933 95d68340 2022-03-16 op echo 'A iota/kappa/lambda' >> $testroot/stdout.expected
934 95d68340 2022-03-16 op cmp -s $testroot/stdout.expected $testroot/stdout
936 95d68340 2022-03-16 op if [ $ret -ne 0 ]; then
937 95d68340 2022-03-16 op diff -u $testroot/stdout.expected $testroot/stdout
938 95d68340 2022-03-16 op test_done $testroot $ret
942 95d68340 2022-03-16 op if [ ! -f $testroot/wt/iota/kappa/lambda ]; then
943 95d68340 2022-03-16 op echo "file not created!" >&2
944 95d68340 2022-03-16 op test_done $testroot $ret
947 2be5e1a2 2022-03-16 op test_done $testroot 0
950 60aa1fa0 2022-03-17 op test_patch_with_offset() {
951 60aa1fa0 2022-03-17 op local testroot=`test_init patch_with_offset`
953 60aa1fa0 2022-03-17 op got checkout $testroot/repo $testroot/wt > /dev/null
955 60aa1fa0 2022-03-17 op if [ $ret -ne 0 ]; then
956 60aa1fa0 2022-03-17 op test_done $testroot $ret
960 60aa1fa0 2022-03-17 op cat <<EOF > $testroot/wt/patch
963 60aa1fa0 2022-03-17 op @@ -47,7 +47,7 @@
968 60aa1fa0 2022-03-17 op +midway tru it!
972 60aa1fa0 2022-03-17 op @@ -87,7 +87,7 @@
977 60aa1fa0 2022-03-17 op +almost there!
983 60aa1fa0 2022-03-17 op jot 100 > $testroot/wt/numbers
984 60aa1fa0 2022-03-17 op ed $testroot/wt/numbers <<EOF > /dev/null 2> /dev/null
991 60aa1fa0 2022-03-17 op (cd $testroot/wt && got add numbers && got commit -m '+numbers') \
994 60aa1fa0 2022-03-17 op if [ $ret -ne 0 ]; then
995 60aa1fa0 2022-03-17 op test_done $testroot $ret
999 60aa1fa0 2022-03-17 op (cd $testroot/wt && got patch patch) > $testroot/stdout
1001 60aa1fa0 2022-03-17 op if [ $ret -ne 0 ]; then
1002 60aa1fa0 2022-03-17 op test_done $testroot/wt $ret
1006 60aa1fa0 2022-03-17 op cat <<EOF > $testroot/stdout.expected
1008 60aa1fa0 2022-03-17 op @@ -47,7 +47,7 @@ applied with offset -10
1009 60aa1fa0 2022-03-17 op @@ -87,7 +87,7 @@ applied with offset 10
1012 7a30b5cb 2022-03-20 op cmp -s $testroot/stdout.expected $testroot/stdout
1014 7a30b5cb 2022-03-20 op if [ $ret -ne 0 ]; then
1015 7a30b5cb 2022-03-20 op diff -u $testroot/stdout.expected $testroot/stdout
1017 7a30b5cb 2022-03-20 op test_done $testroot $ret
1020 7a30b5cb 2022-03-20 op test_patch_prefer_new_path() {
1021 7a30b5cb 2022-03-20 op local testroot=`test_init patch_orig`
1023 7a30b5cb 2022-03-20 op got checkout $testroot/repo $testroot/wt > /dev/null
1025 7a30b5cb 2022-03-20 op if [ $ret -ne 0 ]; then
1026 7a30b5cb 2022-03-20 op test_done $testroot $ret
1030 7a30b5cb 2022-03-20 op cat <<EOF > $testroot/wt/patch
1031 7a30b5cb 2022-03-20 op --- alpha.orig
1033 7a30b5cb 2022-03-20 op @@ -1 +1,2 @@
1038 7a30b5cb 2022-03-20 op (cd $testroot/wt && got patch patch) > $testroot/stdout
1040 7a30b5cb 2022-03-20 op if [ $ret -ne 0 ]; then
1041 7a30b5cb 2022-03-20 op test_done $testroot $ret
1045 3313bcd8 2022-04-19 op echo 'M alpha' > $testroot/stdout.expected
1046 60aa1fa0 2022-03-17 op cmp -s $testroot/stdout.expected $testroot/stdout
1048 60aa1fa0 2022-03-17 op if [ $ret -ne 0 ]; then
1049 60aa1fa0 2022-03-17 op diff -u $testroot/stdout.expected $testroot/stdout
1051 60aa1fa0 2022-03-17 op test_done $testroot $ret
1054 b3c57ab2 2022-03-22 op test_patch_no_newline() {
1055 b3c57ab2 2022-03-22 op local testroot=`test_init patch_no_newline`
1057 b3c57ab2 2022-03-22 op got checkout $testroot/repo $testroot/wt > /dev/null
1059 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
1060 b3c57ab2 2022-03-22 op test_done $testroot $ret
1064 b3c57ab2 2022-03-22 op cat <<EOF > $testroot/wt/patch
1065 b3c57ab2 2022-03-22 op --- /dev/null
1067 b3c57ab2 2022-03-22 op @@ -0,0 +1 @@
1069 b3c57ab2 2022-03-22 op \ No newline at end of file
1072 b3c57ab2 2022-03-22 op (cd $testroot/wt && got patch patch) > $testroot/stdout
1074 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
1075 b3c57ab2 2022-03-22 op test_done $testroot $ret
1079 b3c57ab2 2022-03-22 op echo "A eta" > $testroot/stdout.expected
1080 b3c57ab2 2022-03-22 op cmp -s $testroot/stdout.expected $testroot/stdout
1082 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
1083 b3c57ab2 2022-03-22 op diff -u $testroot/stdout.expected $testroot/stdout
1084 b3c57ab2 2022-03-22 op test_done $testroot $ret
1088 b3c57ab2 2022-03-22 op echo -n eta > $testroot/wt/eta.expected
1089 b3c57ab2 2022-03-22 op cmp -s $testroot/wt/eta.expected $testroot/wt/eta
1091 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
1092 b3c57ab2 2022-03-22 op diff -u $testroot/wt/eta.expected $testroot/wt/eta
1093 b3c57ab2 2022-03-22 op test_done $testroot $ret
1097 b3c57ab2 2022-03-22 op (cd $testroot/wt && got commit -m 'add eta') > /dev/null
1099 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
1100 b3c57ab2 2022-03-22 op test_done $testroot $ret
1104 b3c57ab2 2022-03-22 op cat <<EOF > $testroot/wt/patch
1109 b3c57ab2 2022-03-22 op \ No newline at end of file
1111 b3c57ab2 2022-03-22 op \ No newline at end of file
1114 b3c57ab2 2022-03-22 op (cd $testroot/wt && got patch patch) > $testroot/stdout
1116 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
1117 b3c57ab2 2022-03-22 op test_done $testroot $ret
1121 b3c57ab2 2022-03-22 op echo "M eta" > $testroot/stdout.expected
1122 b3c57ab2 2022-03-22 op cmp -s $testroot/stdout.expected $testroot/stdout
1124 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
1125 b3c57ab2 2022-03-22 op diff -u $testroot/stdout.expected $testroot/stdout
1126 b3c57ab2 2022-03-22 op test_done $testroot $ret
1130 b3c57ab2 2022-03-22 op echo -n ETA > $testroot/wt/eta.expected
1131 b3c57ab2 2022-03-22 op cmp -s $testroot/wt/eta.expected $testroot/wt/eta
1133 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
1134 b3c57ab2 2022-03-22 op diff -u $testroot/wt/eta.expected $testroot/wt/eta
1135 b3c57ab2 2022-03-22 op test_done $testroot $ret
1139 b3c57ab2 2022-03-22 op (cd $testroot/wt && got commit -m 'edit eta') > /dev/null
1141 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
1142 b3c57ab2 2022-03-22 op test_done $testroot $ret
1146 b3c57ab2 2022-03-22 op cat <<EOF > $testroot/wt/patch
1151 b3c57ab2 2022-03-22 op \ No newline at end of file
1155 b3c57ab2 2022-03-22 op (cd $testroot/wt && got patch patch) > $testroot/stdout
1157 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
1158 b3c57ab2 2022-03-22 op test_done $testroot $ret
1162 b3c57ab2 2022-03-22 op echo "M eta" > $testroot/stdout.expected
1163 b3c57ab2 2022-03-22 op cmp -s $testroot/stdout.expected $testroot/stdout
1165 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
1166 b3c57ab2 2022-03-22 op diff -u $testroot/stdout.expected $testroot/stdout
1167 b3c57ab2 2022-03-22 op test_done $testroot $ret
1171 b3c57ab2 2022-03-22 op echo eta > $testroot/wt/eta.expected
1172 b3c57ab2 2022-03-22 op cmp -s $testroot/wt/eta.expected $testroot/wt/eta
1174 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
1175 b3c57ab2 2022-03-22 op diff -u $testroot/wt/eta.expected $testroot/wt/eta
1177 b3c57ab2 2022-03-22 op test_done $testroot $ret
1180 9d6cabd5 2022-04-07 op test_patch_strip() {
1181 9d6cabd5 2022-04-07 op local testroot=`test_init patch_strip`
1183 9d6cabd5 2022-04-07 op got checkout $testroot/repo $testroot/wt > /dev/null
1185 9d6cabd5 2022-04-07 op if [ $ret -ne 0 ]; then
1186 9d6cabd5 2022-04-07 op test_done $testroot $ret
1190 9d6cabd5 2022-04-07 op cat <<EOF > $testroot/wt/patch
1191 9d6cabd5 2022-04-07 op --- foo/bar/alpha.orig
1192 9d6cabd5 2022-04-07 op +++ foo/bar/alpha
1198 9d6cabd5 2022-04-07 op (cd $testroot/wt && got patch -p2 patch) > $testroot/stdout
1200 9d6cabd5 2022-04-07 op if [ $ret -ne 0 ]; then
1201 9d6cabd5 2022-04-07 op test_done $testroot $ret
1205 9d6cabd5 2022-04-07 op echo "M alpha" >> $testroot/stdout.expected
1206 9d6cabd5 2022-04-07 op cmp -s $testroot/stdout.expected $testroot/stdout
1208 9d6cabd5 2022-04-07 op if [ $ret -ne 0 ]; then
1209 9d6cabd5 2022-04-07 op diff -u $testroot/stdout.expected $testroot/stdout
1210 9d6cabd5 2022-04-07 op test_done $testroot $ret
1214 9d6cabd5 2022-04-07 op (cd $testroot/wt && got revert alpha) > /dev/null 2>&1
1216 9d6cabd5 2022-04-07 op if [ $ret -ne 0 ]; then
1217 9d6cabd5 2022-04-07 op test_done $testroot $ret
1221 9d6cabd5 2022-04-07 op (cd $testroot/wt && got patch -p3 patch) \
1222 9d6cabd5 2022-04-07 op 2> $testroot/stderr
1224 9d6cabd5 2022-04-07 op if [ $ret -eq 0 ]; then
1225 9d6cabd5 2022-04-07 op echo "stripped more components than available!"
1226 9d6cabd5 2022-04-07 op test_done $testroot 1
1230 9d6cabd5 2022-04-07 op cat <<EOF > $testroot/stderr.expected
1231 9d6cabd5 2022-04-07 op got: can't strip 1 path-components from foo/bar/alpha: bad path
1234 9d6cabd5 2022-04-07 op cmp -s $testroot/stderr.expected $testroot/stderr
1236 9d6cabd5 2022-04-07 op if [ $ret -ne 0 ]; then
1237 9d6cabd5 2022-04-07 op diff -u $testroot/stderr.expected $testroot/stderr
1239 9d6cabd5 2022-04-07 op test_done $testroot 0
1242 ed3bff83 2022-04-23 op test_patch_relative_paths() {
1243 f1d6cebb 2022-04-23 op local testroot=`test_init patch_relative_paths`
1245 ed3bff83 2022-04-23 op got checkout $testroot/repo $testroot/wt > /dev/null
1247 ed3bff83 2022-04-23 op if [ $ret -ne 0 ]; then
1248 ed3bff83 2022-04-23 op test_done $testroot $ret
1252 ed3bff83 2022-04-23 op cat <<EOF > $testroot/wt/gamma/patch
1258 ed3bff83 2022-04-23 op --- /dev/null
1260 ed3bff83 2022-04-23 op @@ -0,0 +1 @@
1264 ed3bff83 2022-04-23 op (cd $testroot/wt/gamma && got patch patch) > $testroot/stdout
1266 ed3bff83 2022-04-23 op if [ $ret -ne 0 ]; then
1267 ed3bff83 2022-04-23 op test_done $testroot $ret
1271 ed3bff83 2022-04-23 op echo 'M gamma/delta' > $testroot/stdout.expected
1272 ed3bff83 2022-04-23 op echo 'A gamma/eta' >> $testroot/stdout.expected
1274 15e1bda6 2022-04-23 op cmp -s $testroot/stdout.expected $testroot/stdout
1276 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1277 15e1bda6 2022-04-23 op diff -u $testroot/stdout.expected $testroot/stdout
1279 15e1bda6 2022-04-23 op test_done $testroot $ret
1282 15e1bda6 2022-04-23 op test_patch_with_path_prefix() {
1283 15e1bda6 2022-04-23 op local testroot=`test_init patch_with_path_prefix`
1285 15e1bda6 2022-04-23 op got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
1287 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1288 15e1bda6 2022-04-23 op test_done $testroot $ret
1292 15e1bda6 2022-04-23 op cat <<EOF > $testroot/wt/patch
1298 15e1bda6 2022-04-23 op --- /dev/null
1300 15e1bda6 2022-04-23 op @@ -0,0 +1 @@
1304 15e1bda6 2022-04-23 op (cd $testroot/wt && got patch patch) > $testroot/stdout
1306 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1307 15e1bda6 2022-04-23 op test_done $testroot $ret
1311 15e1bda6 2022-04-23 op echo 'M delta' > $testroot/stdout.expected
1312 15e1bda6 2022-04-23 op echo 'A eta' >> $testroot/stdout.expected
1314 15e1bda6 2022-04-23 op cmp -s $testroot/stdout.expected $testroot/stdout
1316 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1317 15e1bda6 2022-04-23 op diff -u $testroot/stdout.expected $testroot/stdout
1319 15e1bda6 2022-04-23 op test_done $testroot $ret
1322 15e1bda6 2022-04-23 op test_patch_relpath_with_path_prefix() {
1323 15e1bda6 2022-04-23 op local testroot=`test_init patch_relpaths_with_path_prefix`
1325 15e1bda6 2022-04-23 op got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
1327 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1328 15e1bda6 2022-04-23 op test_done $testroot $ret
1332 15e1bda6 2022-04-23 op mkdir -p $testroot/wt/epsilon/zeta/
1334 15e1bda6 2022-04-23 op cat <<EOF > $testroot/wt/patch
1335 15e1bda6 2022-04-23 op --- /dev/null
1336 15e1bda6 2022-04-23 op +++ zeta/theta
1337 15e1bda6 2022-04-23 op @@ -0,0 +1 @@
1341 15e1bda6 2022-04-23 op (cd $testroot/wt/epsilon/zeta && got patch -p1 $testroot/wt/patch) \
1342 15e1bda6 2022-04-23 op > $testroot/stdout
1344 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1345 15e1bda6 2022-04-23 op test_done $testroot $ret
1349 15e1bda6 2022-04-23 op echo 'A epsilon/zeta/theta' >> $testroot/stdout.expected
1351 ed3bff83 2022-04-23 op cmp -s $testroot/stdout.expected $testroot/stdout
1353 ed3bff83 2022-04-23 op if [ $ret -ne 0 ]; then
1354 ed3bff83 2022-04-23 op diff -u $testroot/stdout.expected $testroot/stdout
1355 15e1bda6 2022-04-23 op test_done $testroot $ret
1359 15e1bda6 2022-04-23 op echo 'theta' > $testroot/theta.expected
1360 15e1bda6 2022-04-23 op cmp -s $testroot/wt/epsilon/zeta/theta $testroot/theta.expected
1362 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1363 15e1bda6 2022-04-23 op diff -u $testroot/wt/epsilon/zeta/theta $testroot/theta.expected
1365 ed3bff83 2022-04-23 op test_done $testroot $ret
1368 bad961bf 2022-04-23 op test_patch_reverse() {
1369 bad961bf 2022-04-23 op local testroot=`test_init patch_reverse`
1371 bad961bf 2022-04-23 op got checkout $testroot/repo $testroot/wt > /dev/null
1373 bad961bf 2022-04-23 op if [ $ret -ne 0 ]; then
1374 bad961bf 2022-04-23 op test_done $testroot $ret
1378 bad961bf 2022-04-23 op cat <<EOF > $testroot/wt/patch
1383 bad961bf 2022-04-23 op \ No newline at end of file
1387 bad961bf 2022-04-23 op (cd $testroot/wt && got patch -R patch) > $testroot/stdout
1389 bad961bf 2022-04-23 op if [ $ret -ne 0 ]; then
1390 bad961bf 2022-04-23 op test_done $testroot $ret
1394 bad961bf 2022-04-23 op echo "M alpha" > $testroot/stdout.expected
1395 bad961bf 2022-04-23 op cmp -s $testroot/stdout.expected $testroot/stdout
1397 bad961bf 2022-04-23 op if [ $ret -ne 0 ]; then
1398 bad961bf 2022-04-23 op diff -u $testroot/stdout.expected $testroot/stdout
1399 bad961bf 2022-04-23 op test_done $testroot $ret
1403 bad961bf 2022-04-23 op echo -n ALPHA > $testroot/wt/alpha.expected
1404 bad961bf 2022-04-23 op cmp -s $testroot/wt/alpha.expected $testroot/wt/alpha
1406 bad961bf 2022-04-23 op if [ $ret -ne 0 ]; then
1407 bad961bf 2022-04-23 op diff -u $testroot/wt/alpha.expected $testroot/wt/alpha
1409 bad961bf 2022-04-23 op test_done $testroot $ret
1412 e9ce266e 2022-03-07 op test_parseargs "$@"
1413 e9ce266e 2022-03-07 op run_test test_patch_simple_add_file
1414 e9ce266e 2022-03-07 op run_test test_patch_simple_rm_file
1415 e9ce266e 2022-03-07 op run_test test_patch_simple_edit_file
1416 e9ce266e 2022-03-07 op run_test test_patch_prepend_line
1417 e9ce266e 2022-03-07 op run_test test_patch_replace_line
1418 e9ce266e 2022-03-07 op run_test test_patch_multiple_hunks
1419 e9ce266e 2022-03-07 op run_test test_patch_multiple_files
1420 e9ce266e 2022-03-07 op run_test test_patch_dont_apply
1421 e9ce266e 2022-03-07 op run_test test_patch_malformed
1422 e9ce266e 2022-03-07 op run_test test_patch_no_patch
1423 e9ce266e 2022-03-07 op run_test test_patch_equals_for_context
1424 6e96b326 2022-03-12 op run_test test_patch_rename
1425 dbda770b 2022-03-13 op run_test test_patch_illegal_status
1426 899fcfdf 2022-03-13 op run_test test_patch_nop
1427 2be5e1a2 2022-03-16 op run_test test_patch_preserve_perm
1428 95d68340 2022-03-16 op run_test test_patch_create_dirs
1429 60aa1fa0 2022-03-17 op run_test test_patch_with_offset
1430 7a30b5cb 2022-03-20 op run_test test_patch_prefer_new_path
1431 b3c57ab2 2022-03-22 op run_test test_patch_no_newline
1432 9d6cabd5 2022-04-07 op run_test test_patch_strip
1433 ed3bff83 2022-04-23 op run_test test_patch_relative_paths
1434 15e1bda6 2022-04-23 op run_test test_patch_with_path_prefix
1435 15e1bda6 2022-04-23 op run_test test_patch_relpath_with_path_prefix
1436 bad961bf 2022-04-23 op run_test test_patch_reverse