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 57b1c3f2 2022-08-01 op test_patch_basic() {
20 57b1c3f2 2022-08-01 op local testroot=`test_init patch_basic`
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 57b1c3f2 2022-08-01 op jot 100 > $testroot/wt/numbers
30 57b1c3f2 2022-08-01 op (cd $testroot/wt && got add numbers && got commit -m +numbers) \
33 57b1c3f2 2022-08-01 op if [ $ret -ne 0 ]; then
34 57b1c3f2 2022-08-01 op test_done "$testroot" $ret
38 e9ce266e 2022-03-07 op cat <<EOF > $testroot/wt/patch
43 57b1c3f2 2022-08-01 op +alpha is my favourite character
48 57b1c3f2 2022-08-01 op --- gamma/delta
49 57b1c3f2 2022-08-01 op +++ gamma/delta
55 ed2ff8b9 2022-07-02 op @@ -0,0 +5,5 @@
63 e9ce266e 2022-03-07 op @@ -3,7 +3,7 @@
72 e9ce266e 2022-03-07 op @@ -57,7 +57,7 @@
81 e9ce266e 2022-03-07 op @@ -98,3 +98,6 @@
90 9cda65e5 2022-10-15 stsp (cd $testroot/wt && got patch < patch) > $testroot/stdout
91 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
92 57b1c3f2 2022-08-01 op test_done "$testroot" $ret
96 57b1c3f2 2022-08-01 op echo 'M alpha' > $testroot/stdout.expected
97 57b1c3f2 2022-08-01 op echo 'D beta' >> $testroot/stdout.expected
98 57b1c3f2 2022-08-01 op echo 'M gamma/delta' >> $testroot/stdout.expected
99 57b1c3f2 2022-08-01 op echo 'A eta' >> $testroot/stdout.expected
100 57b1c3f2 2022-08-01 op echo 'M numbers' >> $testroot/stdout.expected
102 e9ce266e 2022-03-07 op cmp -s $testroot/stdout.expected $testroot/stdout
104 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
105 e9ce266e 2022-03-07 op diff -u $testroot/stdout.expected $testroot/stdout
106 e9ce266e 2022-03-07 op test_done $testroot $ret
110 57b1c3f2 2022-08-01 op echo 'alpha is my favourite character' > $testroot/wt/alpha.expected
111 57b1c3f2 2022-08-01 op cmp -s $testroot/wt/alpha.expected $testroot/wt/alpha
113 57b1c3f2 2022-08-01 op if [ $ret -ne 0 ]; then
114 57b1c3f2 2022-08-01 op diff -u $testroot/wt/alpha.expected $testroot/wt/alpha
115 57b1c3f2 2022-08-01 op test_done "$testroot" $ret
119 57b1c3f2 2022-08-01 op if [ -f "$testroot/wt/beta" ]; then
120 57b1c3f2 2022-08-01 op echo "beta was not deleted!" >&2
121 57b1c3f2 2022-08-01 op test_done "$testroot" 1
125 57b1c3f2 2022-08-01 op echo 'this is:' > $testroot/wt/gamma/delta.expected
126 57b1c3f2 2022-08-01 op echo 'delta' >> $testroot/wt/gamma/delta.expected
127 57b1c3f2 2022-08-01 op cmp -s $testroot/wt/gamma/delta.expected $testroot/wt/gamma/delta
129 57b1c3f2 2022-08-01 op if [ $ret -ne 0 ]; then
130 57b1c3f2 2022-08-01 op diff -u $testroot/wt/gamma/delta.expected $testroot/wt/gamma/delta
131 57b1c3f2 2022-08-01 op test_done "$testroot" $ret
135 57b1c3f2 2022-08-01 op jot 5 > $testroot/wt/eta.expected
136 57b1c3f2 2022-08-01 op cmp -s $testroot/wt/eta.expected $testroot/wt/eta
138 57b1c3f2 2022-08-01 op if [ $ret -ne 0 ]; then
139 57b1c3f2 2022-08-01 op diff -u $testroot/wt/eta.expected $testroot/wt/eta
140 57b1c3f2 2022-08-01 op test_done "$testroot" $ret
144 57b1c3f2 2022-08-01 op jot 103 | sed -e 's/^6$/six/' -e 's/60/sixty/' \
145 e9ce266e 2022-03-07 op > $testroot/wt/numbers.expected
146 e9ce266e 2022-03-07 op cmp -s $testroot/wt/numbers.expected $testroot/wt/numbers
148 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
149 e9ce266e 2022-03-07 op diff -u $testroot/wt/numbers.expected $testroot/wt/numbers
151 e9ce266e 2022-03-07 op test_done $testroot $ret
154 e9ce266e 2022-03-07 op test_patch_dont_apply() {
155 e9ce266e 2022-03-07 op local testroot=`test_init patch_dont_apply`
157 e9ce266e 2022-03-07 op got checkout $testroot/repo $testroot/wt > /dev/null
159 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
160 e9ce266e 2022-03-07 op test_done $testroot $ret
164 5b67f96e 2022-03-13 op jot 100 > $testroot/wt/numbers
165 5b67f96e 2022-03-13 op (cd $testroot/wt && got add numbers && got commit -m 'add numbers') \
168 5b67f96e 2022-03-13 op if [ $ret -ne 0 ]; then
169 5b67f96e 2022-03-13 op test_done $testroot $ret
173 5b67f96e 2022-03-13 op cat <<EOF > $testroot/wt/patch
176 60aa1fa0 2022-03-17 op @@ -1 +1,2 @@
178 60aa1fa0 2022-03-17 op alpha something
180 5b67f96e 2022-03-13 op +++ /dev/null
181 5b67f96e 2022-03-13 op @@ -1,9 +0,0 @@
193 60aa1fa0 2022-03-17 op (cd $testroot/wt && got patch patch) > $testroot/stdout 2> /dev/null
195 5b67f96e 2022-03-13 op if [ $ret -eq 0 ]; then # should fail
196 5b67f96e 2022-03-13 op test_done $testroot 1
200 60aa1fa0 2022-03-17 op cat <<EOF > $testroot/stdout.expected
202 60aa1fa0 2022-03-17 op @@ -1,1 +1,2 @@ hunk failed to apply
204 60aa1fa0 2022-03-17 op @@ -1,9 +0,0 @@ hunk failed to apply
207 60aa1fa0 2022-03-17 op cmp -s $testroot/stdout.expected $testroot/stdout
209 5b67f96e 2022-03-13 op if [ $ret -ne 0 ]; then
210 60aa1fa0 2022-03-17 op diff -u $testroot/stdout.expected $testroot/stdout
212 e9ce266e 2022-03-07 op test_done $testroot $ret
215 e9ce266e 2022-03-07 op test_patch_malformed() {
216 e9ce266e 2022-03-07 op local testroot=`test_init patch_malformed`
218 e9ce266e 2022-03-07 op got checkout $testroot/repo $testroot/wt > /dev/null
220 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
221 e9ce266e 2022-03-07 op test_done $testroot $ret
225 e9ce266e 2022-03-07 op # missing "@@"
226 e9ce266e 2022-03-07 op cat <<EOF > $testroot/wt/patch
234 e9ce266e 2022-03-07 op echo -n > $testroot/stdout.expected
235 e9ce266e 2022-03-07 op echo "got: malformed patch" > $testroot/stderr.expected
237 e9ce266e 2022-03-07 op (cd $testroot/wt && got patch patch) \
238 e9ce266e 2022-03-07 op > $testroot/stdout \
239 e9ce266e 2022-03-07 op 2> $testroot/stderr
241 bfbccd0a 2022-03-08 op if [ $ret -eq 0 ]; then
242 e9ce266e 2022-03-07 op echo "got managed to apply an invalid patch"
243 e9ce266e 2022-03-07 op test_done $testroot 1
247 e9ce266e 2022-03-07 op cmp -s $testroot/stdout.expected $testroot/stdout
249 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
250 e9ce266e 2022-03-07 op diff -u $testroot/stdout.expected $testroot/stdout
251 e9ce266e 2022-03-07 op test_done $testroot $ret
255 e9ce266e 2022-03-07 op cmp -s $testroot/stderr.expected $testroot/stderr
257 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
258 e9ce266e 2022-03-07 op diff -u $testroot/stderr.expected $testroot/stderr
259 e9ce266e 2022-03-07 op test_done $testroot $ret
263 e9ce266e 2022-03-07 op # wrong first character
264 e9ce266e 2022-03-07 op cat <<EOF > $testroot/wt/patch
267 e9ce266e 2022-03-07 op @@ -1 +1,2 @@
272 e9ce266e 2022-03-07 op (cd $testroot/wt && got patch patch) \
273 e9ce266e 2022-03-07 op > $testroot/stdout \
274 e9ce266e 2022-03-07 op 2> $testroot/stderr
276 bfbccd0a 2022-03-08 op if [ $ret -eq 0 ]; then
277 e9ce266e 2022-03-07 op echo "got managed to apply an invalid patch"
278 e9ce266e 2022-03-07 op test_done $testroot 1
282 e9ce266e 2022-03-07 op cmp -s $testroot/stdout.expected $testroot/stdout
284 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
285 e9ce266e 2022-03-07 op diff -u $testroot/stdout.expected $testroot/stdout
286 e9ce266e 2022-03-07 op test_done $testroot $ret
290 e9ce266e 2022-03-07 op cmp -s $testroot/stderr.expected $testroot/stderr
292 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
293 e9ce266e 2022-03-07 op diff -u $testroot/stderr.expected $testroot/stderr
294 e9ce266e 2022-03-07 op test_done $testroot $ret
299 be33dff7 2022-05-13 op cat <<EOF > $testroot/wt/patch
300 be33dff7 2022-05-13 op diff --git a/alpha b/iota
303 be33dff7 2022-05-13 op @@ -0,0 +0,0 @@
306 be33dff7 2022-05-13 op (cd $testroot/wt && got patch patch) \
307 be33dff7 2022-05-13 op > $testroot/stdout \
308 be33dff7 2022-05-13 op 2> $testroot/stderr
310 be33dff7 2022-05-13 op if [ $ret -eq 0 ]; then
311 be33dff7 2022-05-13 op echo "got managed to apply an invalid patch"
312 be33dff7 2022-05-13 op test_done $testroot 1
316 be33dff7 2022-05-13 op cmp -s $testroot/stdout.expected $testroot/stdout
318 be33dff7 2022-05-13 op if [ $ret -ne 0 ]; then
319 be33dff7 2022-05-13 op diff -u $testroot/stdout.expected $testroot/stdout
320 be33dff7 2022-05-13 op test_done $testroot $ret
324 be33dff7 2022-05-13 op cmp -s $testroot/stderr.expected $testroot/stderr
326 be33dff7 2022-05-13 op if [ $ret -ne 0 ]; then
327 be33dff7 2022-05-13 op diff -u $testroot/stderr.expected $testroot/stderr
328 be33dff7 2022-05-13 op test_done $testroot $ret
332 e9ce266e 2022-03-07 op test_done $testroot $ret
335 e9ce266e 2022-03-07 op test_patch_no_patch() {
336 e9ce266e 2022-03-07 op local testroot=`test_init patch_no_patch`
338 e9ce266e 2022-03-07 op got checkout $testroot/repo $testroot/wt > /dev/null
340 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
341 e9ce266e 2022-03-07 op test_done $testroot $ret
345 e9ce266e 2022-03-07 op cat <<EOF > $testroot/wt/patch
349 e9ce266e 2022-03-07 op some other nonsense
352 e9ce266e 2022-03-07 op there's no patch in here!
355 e9ce266e 2022-03-07 op echo -n > $testroot/stdout.expected
356 e9ce266e 2022-03-07 op echo "got: no patch found" > $testroot/stderr.expected
358 e9ce266e 2022-03-07 op (cd $testroot/wt && got patch patch) \
359 e9ce266e 2022-03-07 op > $testroot/stdout \
360 e9ce266e 2022-03-07 op 2> $testroot/stderr
362 bfbccd0a 2022-03-08 op if [ $ret -eq 0 ]; then # should fail
363 e9ce266e 2022-03-07 op test_done $testroot 1
367 e9ce266e 2022-03-07 op cmp -s $testroot/stdout.expected $testroot/stdout
369 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
370 e9ce266e 2022-03-07 op diff -u $testroot/stdout.expected $testroot/stdout
371 e9ce266e 2022-03-07 op test_done $testroot $ret
375 e9ce266e 2022-03-07 op cmp -s $testroot/stderr.expected $testroot/stderr
377 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
378 e9ce266e 2022-03-07 op diff -u $testroot/stderr.expected $testroot/stderr
379 e9ce266e 2022-03-07 op test_done $testroot $ret
383 e9ce266e 2022-03-07 op test_done $testroot $ret
386 e9ce266e 2022-03-07 op test_patch_equals_for_context() {
387 f1d6cebb 2022-04-23 op local testroot=`test_init patch_equals_for_context`
389 e9ce266e 2022-03-07 op got checkout $testroot/repo $testroot/wt > /dev/null
391 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
392 e9ce266e 2022-03-07 op test_done $testroot $ret
396 e9ce266e 2022-03-07 op cat <<EOF > $testroot/wt/patch
399 e9ce266e 2022-03-07 op @@ -1 +1,2 @@
404 e9ce266e 2022-03-07 op echo "M alpha" > $testroot/stdout.expected
406 e9ce266e 2022-03-07 op (cd $testroot/wt && got patch patch) > $testroot/stdout
408 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
409 e9ce266e 2022-03-07 op test_done $testroot $ret
413 e9ce266e 2022-03-07 op cmp -s $testroot/stdout.expected $testroot/stdout
415 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
416 e9ce266e 2022-03-07 op diff -u $testroot/stdout.expected $testroot/stdout
417 e9ce266e 2022-03-07 op test_done $testroot $ret
421 e9ce266e 2022-03-07 op echo hatsuseno > $testroot/wt/alpha.expected
422 e9ce266e 2022-03-07 op echo alpha >> $testroot/wt/alpha.expected
423 e9ce266e 2022-03-07 op cmp -s $testroot/wt/alpha.expected $testroot/wt/alpha
425 bfbccd0a 2022-03-08 op if [ $ret -ne 0 ]; then
426 e9ce266e 2022-03-07 op diff -u $testroot/wt/alpha.expected $testroot/wt/alpha
428 e9ce266e 2022-03-07 op test_done $testroot $ret
431 6e96b326 2022-03-12 op test_patch_rename() {
432 6e96b326 2022-03-12 op local testroot=`test_init patch_rename`
434 6e96b326 2022-03-12 op got checkout $testroot/repo $testroot/wt > /dev/null
436 6e96b326 2022-03-12 op if [ $ret -ne 0 ]; then
437 6e96b326 2022-03-12 op test_done $testroot $ret
441 6e96b326 2022-03-12 op cat <<EOF > $testroot/wt/patch
442 4379a9aa 2022-05-02 op diff --git a/beta b/iota
443 4379a9aa 2022-05-02 op similarity index 100%
444 4379a9aa 2022-05-02 op rename from beta
445 4379a9aa 2022-05-02 op rename to iota
446 7a30b5cb 2022-03-20 op diff --git a/alpha b/eta
454 4379a9aa 2022-05-02 op echo 'D beta' > $testroot/stdout.expected
455 4379a9aa 2022-05-02 op echo 'A iota' >> $testroot/stdout.expected
456 4379a9aa 2022-05-02 op echo 'D alpha' >> $testroot/stdout.expected
457 4379a9aa 2022-05-02 op echo 'A eta' >> $testroot/stdout.expected
459 6e96b326 2022-03-12 op (cd $testroot/wt && got patch patch) > $testroot/stdout
461 6e96b326 2022-03-12 op if [ $ret -ne 0 ]; then
462 6e96b326 2022-03-12 op test_done $testroot $ret
466 6e96b326 2022-03-12 op cmp -s $testroot/stdout.expected $testroot/stdout
468 6e96b326 2022-03-12 op if [ $ret -ne 0 ]; then
469 6e96b326 2022-03-12 op diff -u $testroot/stdout.expected $testroot/stdout
470 6e96b326 2022-03-12 op test_done $testroot $ret
474 4379a9aa 2022-05-02 op if [ -f $testroot/wt/alpha -o -f $testroot/wt/beta ]; then
475 4379a9aa 2022-05-02 op echo "alpha or beta were not removed" >&2
476 6e96b326 2022-03-12 op test_done $testroot 1
479 4379a9aa 2022-05-02 op if [ ! -f $testroot/wt/iota -o ! -f $testroot/wt/eta ]; then
480 4379a9aa 2022-05-02 op echo "iota or eta were not created" >&2
481 6e96b326 2022-03-12 op test_done $testroot 1
485 4379a9aa 2022-05-02 op echo beta > $testroot/wt/iota.expected
486 4379a9aa 2022-05-02 op cmp -s $testroot/wt/iota.expected $testroot/wt/iota
488 6e96b326 2022-03-12 op if [ $ret -ne 0 ]; then
489 4379a9aa 2022-05-02 op diff -u $testroot/wt/iota.expected $testroot/wt/iota
490 6e96b326 2022-03-12 op test_done $testroot $ret
494 4379a9aa 2022-05-02 op echo eta > $testroot/wt/eta.expected
495 4379a9aa 2022-05-02 op cmp -s $testroot/wt/eta.expected $testroot/wt/eta
497 6e96b326 2022-03-12 op if [ $ret -ne 0 ]; then
498 4379a9aa 2022-05-02 op diff -u $testroot/wt/eta.expected $testroot/wt/eta
499 6e96b326 2022-03-12 op test_done $testroot $ret
503 6e96b326 2022-03-12 op test_done $testroot $ret
506 dbda770b 2022-03-13 op test_patch_illegal_status() {
507 dbda770b 2022-03-13 op local testroot=`test_init patch_illegal_status`
509 dbda770b 2022-03-13 op got checkout $testroot/repo $testroot/wt > /dev/null
511 dbda770b 2022-03-13 op if [ $ret -ne 0 ]; then
512 dbda770b 2022-03-13 op test_done $testroot $ret
516 60aa1fa0 2022-03-17 op # try to patch an obstructed file, add a versioned one, edit a
517 60aa1fa0 2022-03-17 op # non existent file and an unversioned one, and remove a
518 60aa1fa0 2022-03-17 op # non existent file.
519 dbda770b 2022-03-13 op cat <<EOF > $testroot/wt/patch
522 60aa1fa0 2022-03-17 op @@ -1 +1,2 @@
525 60aa1fa0 2022-03-17 op --- /dev/null
527 60aa1fa0 2022-03-17 op @@ -0,0 +1 @@
540 60aa1fa0 2022-03-17 op +++ /dev/null
541 60aa1fa0 2022-03-17 op @@ -1 +0,0 @@
545 60aa1fa0 2022-03-17 op echo kappa > $testroot/wt/kappa
546 dbda770b 2022-03-13 op rm $testroot/wt/alpha
547 dbda770b 2022-03-13 op mkdir $testroot/wt/alpha
549 60aa1fa0 2022-03-17 op (cd $testroot/wt && got patch patch) > $testroot/stdout \
550 dbda770b 2022-03-13 op 2> $testroot/stderr
552 dbda770b 2022-03-13 op if [ $ret -eq 0 ]; then
553 dbda770b 2022-03-13 op echo "edited a missing file" >&2
554 a19f439c 2022-06-03 op test_done $testroot 1
558 60aa1fa0 2022-03-17 op cat <<EOF > $testroot/stdout.expected
566 60aa1fa0 2022-03-17 op cat <<EOF > $testroot/stderr.expected
567 60aa1fa0 2022-03-17 op got: alpha: file has unexpected status
568 60aa1fa0 2022-03-17 op got: beta: file has unexpected status
569 60aa1fa0 2022-03-17 op got: iota: No such file or directory
570 60aa1fa0 2022-03-17 op got: kappa: file has unexpected status
571 60aa1fa0 2022-03-17 op got: lambda: No such file or directory
572 60aa1fa0 2022-03-17 op got: patch failed to apply
575 60aa1fa0 2022-03-17 op cmp -s $testroot/stdout.expected $testroot/stdout
577 60aa1fa0 2022-03-17 op if [ $ret -ne 0 ]; then
578 60aa1fa0 2022-03-17 op diff -u $testroot/stdout.expected $testroot/stdout
579 dbda770b 2022-03-13 op test_done $testroot $ret
583 dbda770b 2022-03-13 op cmp -s $testroot/stderr.expected $testroot/stderr
585 60aa1fa0 2022-03-17 op if [ $ret -ne 0 ]; then
586 dbda770b 2022-03-13 op diff -u $testroot/stderr.expected $testroot/stderr
587 78f5ac24 2022-03-19 op test_done $testroot $ret
591 78f5ac24 2022-03-19 op (cd $testroot/wt && got status) > $testroot/stdout
592 78f5ac24 2022-03-19 op cat <<EOF > $testroot/stdout.expected
598 78f5ac24 2022-03-19 op cmp -s $testroot/stdout.expected $testroot/stdout
600 78f5ac24 2022-03-19 op if [ $ret -ne 0 ]; then
601 78f5ac24 2022-03-19 op diff -u $testroot/stdout.expected $testroot/stdout
603 dbda770b 2022-03-13 op test_done $testroot $ret
606 899fcfdf 2022-03-13 op test_patch_nop() {
607 899fcfdf 2022-03-13 op local testroot=`test_init patch_nop`
609 899fcfdf 2022-03-13 op got checkout $testroot/repo $testroot/wt > /dev/null
611 899fcfdf 2022-03-13 op if [ $ret -ne 0 ]; then
612 899fcfdf 2022-03-13 op test_done $testroot $ret
616 899fcfdf 2022-03-13 op cat <<EOF > $testroot/wt/patch
623 899fcfdf 2022-03-13 op +++ /dev/null
624 899fcfdf 2022-03-13 op @@ -1 +0,0 @@
626 7a30b5cb 2022-03-20 op diff --git a/gamma/delta b/gamma/delta.new
627 899fcfdf 2022-03-13 op --- gamma/delta
628 899fcfdf 2022-03-13 op +++ gamma/delta.new
631 899fcfdf 2022-03-13 op +delta updated and renamed!
634 899fcfdf 2022-03-13 op (cd $testroot/wt && got patch -n patch)
636 899fcfdf 2022-03-13 op if [ $ret -ne 0 ]; then
637 899fcfdf 2022-03-13 op test_done $testroot $ret
641 899fcfdf 2022-03-13 op # remove the patch to avoid the ? entry
642 899fcfdf 2022-03-13 op rm $testroot/wt/patch
644 899fcfdf 2022-03-13 op (cd $testroot/wt && got status) > $testroot/stdout
646 899fcfdf 2022-03-13 op if [ $ret -ne 0 ]; then
647 899fcfdf 2022-03-13 op test_done $testroot $ret
651 899fcfdf 2022-03-13 op echo -n > $testroot/stdout.expected
652 899fcfdf 2022-03-13 op cmp -s $testroot/stdout.expected $testroot/stdout
654 899fcfdf 2022-03-13 op if [ $ret -ne 0 ]; then
655 899fcfdf 2022-03-13 op diff -u $testroot/stdout.expected $testroot/stdout
657 899fcfdf 2022-03-13 op test_done $testroot $ret
660 2be5e1a2 2022-03-16 op test_patch_preserve_perm() {
661 2be5e1a2 2022-03-16 op local testroot=`test_init patch_preserve_perm`
663 2be5e1a2 2022-03-16 op got checkout $testroot/repo $testroot/wt > /dev/null
665 2be5e1a2 2022-03-16 op if [ $ret -ne 0 ]; then
666 2be5e1a2 2022-03-16 op test_done $testroot $ret
670 2be5e1a2 2022-03-16 op chmod +x $testroot/wt/alpha
671 2be5e1a2 2022-03-16 op (cd $testroot/wt && got commit -m 'alpha executable') > /dev/null
673 2be5e1a2 2022-03-16 op if [ $ret -ne 0 ]; then
674 2be5e1a2 2022-03-16 op test_done $testroot $ret
678 2be5e1a2 2022-03-16 op cat <<EOF > $testroot/wt/patch
681 2be5e1a2 2022-03-16 op @@ -1 +1,2 @@
686 2be5e1a2 2022-03-16 op (cd $testroot/wt && got patch patch) > /dev/null
688 2be5e1a2 2022-03-16 op if [ $ret -ne 0 ]; then
689 2be5e1a2 2022-03-16 op test_done $testroot $ret
693 2be5e1a2 2022-03-16 op if [ ! -x $testroot/wt/alpha ]; then
694 2be5e1a2 2022-03-16 op echo "alpha is no more executable!" >&2
695 2be5e1a2 2022-03-16 op test_done $testroot 1
698 2be5e1a2 2022-03-16 op test_done $testroot 0
701 95d68340 2022-03-16 op test_patch_create_dirs() {
702 95d68340 2022-03-16 op local testroot=`test_init patch_create_dirs`
704 95d68340 2022-03-16 op got checkout $testroot/repo $testroot/wt > /dev/null
706 95d68340 2022-03-16 op if [ $ret -ne 0 ]; then
707 95d68340 2022-03-16 op test_done $testroot $ret
711 95d68340 2022-03-16 op cat <<EOF > $testroot/wt/patch
712 95d68340 2022-03-16 op --- /dev/null
713 95d68340 2022-03-16 op +++ iota/kappa/lambda
714 95d68340 2022-03-16 op @@ -0,0 +1 @@
718 95d68340 2022-03-16 op (cd $testroot/wt && got patch patch) > $testroot/stdout
720 95d68340 2022-03-16 op if [ $ret -ne 0 ]; then
721 95d68340 2022-03-16 op test_done $testroot $ret
725 95d68340 2022-03-16 op echo 'A iota/kappa/lambda' >> $testroot/stdout.expected
726 95d68340 2022-03-16 op cmp -s $testroot/stdout.expected $testroot/stdout
728 95d68340 2022-03-16 op if [ $ret -ne 0 ]; then
729 95d68340 2022-03-16 op diff -u $testroot/stdout.expected $testroot/stdout
730 95d68340 2022-03-16 op test_done $testroot $ret
734 95d68340 2022-03-16 op if [ ! -f $testroot/wt/iota/kappa/lambda ]; then
735 95d68340 2022-03-16 op echo "file not created!" >&2
736 95d68340 2022-03-16 op test_done $testroot $ret
739 95d68340 2022-03-16 op test_done $testroot 0
742 60aa1fa0 2022-03-17 op test_patch_with_offset() {
743 60aa1fa0 2022-03-17 op local testroot=`test_init patch_with_offset`
745 60aa1fa0 2022-03-17 op got checkout $testroot/repo $testroot/wt > /dev/null
747 60aa1fa0 2022-03-17 op if [ $ret -ne 0 ]; then
748 60aa1fa0 2022-03-17 op test_done $testroot $ret
752 60aa1fa0 2022-03-17 op cat <<EOF > $testroot/wt/patch
755 60aa1fa0 2022-03-17 op @@ -47,7 +47,7 @@
760 60aa1fa0 2022-03-17 op +midway tru it!
764 60aa1fa0 2022-03-17 op @@ -87,7 +87,7 @@
769 60aa1fa0 2022-03-17 op +almost there!
775 60aa1fa0 2022-03-17 op jot 100 > $testroot/wt/numbers
776 5f94a4e0 2022-11-18 op ed -s "$testroot/wt/numbers" <<EOF
783 60aa1fa0 2022-03-17 op (cd $testroot/wt && got add numbers && got commit -m '+numbers') \
786 60aa1fa0 2022-03-17 op if [ $ret -ne 0 ]; then
787 60aa1fa0 2022-03-17 op test_done $testroot $ret
791 60aa1fa0 2022-03-17 op (cd $testroot/wt && got patch patch) > $testroot/stdout
793 60aa1fa0 2022-03-17 op if [ $ret -ne 0 ]; then
794 60aa1fa0 2022-03-17 op test_done $testroot/wt $ret
798 60aa1fa0 2022-03-17 op cat <<EOF > $testroot/stdout.expected
800 60aa1fa0 2022-03-17 op @@ -47,7 +47,7 @@ applied with offset -10
801 60aa1fa0 2022-03-17 op @@ -87,7 +87,7 @@ applied with offset 10
804 60aa1fa0 2022-03-17 op cmp -s $testroot/stdout.expected $testroot/stdout
806 60aa1fa0 2022-03-17 op if [ $ret -ne 0 ]; then
807 60aa1fa0 2022-03-17 op diff -u $testroot/stdout.expected $testroot/stdout
809 60aa1fa0 2022-03-17 op test_done $testroot $ret
812 7a30b5cb 2022-03-20 op test_patch_prefer_new_path() {
813 7a30b5cb 2022-03-20 op local testroot=`test_init patch_orig`
815 7a30b5cb 2022-03-20 op got checkout $testroot/repo $testroot/wt > /dev/null
817 7a30b5cb 2022-03-20 op if [ $ret -ne 0 ]; then
818 7a30b5cb 2022-03-20 op test_done $testroot $ret
822 7a30b5cb 2022-03-20 op cat <<EOF > $testroot/wt/patch
823 7a30b5cb 2022-03-20 op --- alpha.orig
825 7a30b5cb 2022-03-20 op @@ -1 +1,2 @@
830 7a30b5cb 2022-03-20 op (cd $testroot/wt && got patch patch) > $testroot/stdout
832 7a30b5cb 2022-03-20 op if [ $ret -ne 0 ]; then
833 7a30b5cb 2022-03-20 op test_done $testroot $ret
837 3313bcd8 2022-04-19 op echo 'M alpha' > $testroot/stdout.expected
838 7a30b5cb 2022-03-20 op cmp -s $testroot/stdout.expected $testroot/stdout
840 7a30b5cb 2022-03-20 op if [ $ret -ne 0 ]; then
841 7a30b5cb 2022-03-20 op diff -u $testroot/stdout.expected $testroot/stdout
843 7a30b5cb 2022-03-20 op test_done $testroot $ret
846 b3c57ab2 2022-03-22 op test_patch_no_newline() {
847 b3c57ab2 2022-03-22 op local testroot=`test_init patch_no_newline`
849 b3c57ab2 2022-03-22 op got checkout $testroot/repo $testroot/wt > /dev/null
851 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
852 b3c57ab2 2022-03-22 op test_done $testroot $ret
856 b3c57ab2 2022-03-22 op cat <<EOF > $testroot/wt/patch
857 b3c57ab2 2022-03-22 op --- /dev/null
859 b3c57ab2 2022-03-22 op @@ -0,0 +1 @@
861 b3c57ab2 2022-03-22 op \ No newline at end of file
864 b3c57ab2 2022-03-22 op (cd $testroot/wt && got patch patch) > $testroot/stdout
866 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
867 b3c57ab2 2022-03-22 op test_done $testroot $ret
871 b3c57ab2 2022-03-22 op echo "A eta" > $testroot/stdout.expected
872 b3c57ab2 2022-03-22 op cmp -s $testroot/stdout.expected $testroot/stdout
874 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
875 b3c57ab2 2022-03-22 op diff -u $testroot/stdout.expected $testroot/stdout
876 b3c57ab2 2022-03-22 op test_done $testroot $ret
880 b3c57ab2 2022-03-22 op echo -n eta > $testroot/wt/eta.expected
881 b3c57ab2 2022-03-22 op cmp -s $testroot/wt/eta.expected $testroot/wt/eta
883 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
884 b3c57ab2 2022-03-22 op diff -u $testroot/wt/eta.expected $testroot/wt/eta
885 b3c57ab2 2022-03-22 op test_done $testroot $ret
889 b3c57ab2 2022-03-22 op (cd $testroot/wt && got commit -m 'add eta') > /dev/null
891 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
892 b3c57ab2 2022-03-22 op test_done $testroot $ret
896 b3c57ab2 2022-03-22 op cat <<EOF > $testroot/wt/patch
901 b3c57ab2 2022-03-22 op \ No newline at end of file
903 b3c57ab2 2022-03-22 op \ No newline at end of file
906 b3c57ab2 2022-03-22 op (cd $testroot/wt && got patch patch) > $testroot/stdout
908 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
909 b3c57ab2 2022-03-22 op test_done $testroot $ret
913 b3c57ab2 2022-03-22 op echo "M eta" > $testroot/stdout.expected
914 b3c57ab2 2022-03-22 op cmp -s $testroot/stdout.expected $testroot/stdout
916 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
917 b3c57ab2 2022-03-22 op diff -u $testroot/stdout.expected $testroot/stdout
918 b3c57ab2 2022-03-22 op test_done $testroot $ret
922 b3c57ab2 2022-03-22 op echo -n ETA > $testroot/wt/eta.expected
923 b3c57ab2 2022-03-22 op cmp -s $testroot/wt/eta.expected $testroot/wt/eta
925 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
926 b3c57ab2 2022-03-22 op diff -u $testroot/wt/eta.expected $testroot/wt/eta
927 b3c57ab2 2022-03-22 op test_done $testroot $ret
931 b3c57ab2 2022-03-22 op (cd $testroot/wt && got commit -m 'edit eta') > /dev/null
933 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
934 b3c57ab2 2022-03-22 op test_done $testroot $ret
938 b3c57ab2 2022-03-22 op cat <<EOF > $testroot/wt/patch
943 b3c57ab2 2022-03-22 op \ No newline at end of file
947 b3c57ab2 2022-03-22 op (cd $testroot/wt && got patch patch) > $testroot/stdout
949 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
950 b3c57ab2 2022-03-22 op test_done $testroot $ret
954 b3c57ab2 2022-03-22 op echo "M eta" > $testroot/stdout.expected
955 b3c57ab2 2022-03-22 op cmp -s $testroot/stdout.expected $testroot/stdout
957 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
958 b3c57ab2 2022-03-22 op diff -u $testroot/stdout.expected $testroot/stdout
959 b3c57ab2 2022-03-22 op test_done $testroot $ret
963 b3c57ab2 2022-03-22 op echo eta > $testroot/wt/eta.expected
964 b3c57ab2 2022-03-22 op cmp -s $testroot/wt/eta.expected $testroot/wt/eta
966 b3c57ab2 2022-03-22 op if [ $ret -ne 0 ]; then
967 b3c57ab2 2022-03-22 op diff -u $testroot/wt/eta.expected $testroot/wt/eta
969 b3c57ab2 2022-03-22 op test_done $testroot $ret
972 9d6cabd5 2022-04-07 op test_patch_strip() {
973 9d6cabd5 2022-04-07 op local testroot=`test_init patch_strip`
975 9d6cabd5 2022-04-07 op got checkout $testroot/repo $testroot/wt > /dev/null
977 9d6cabd5 2022-04-07 op if [ $ret -ne 0 ]; then
978 9d6cabd5 2022-04-07 op test_done $testroot $ret
982 9d6cabd5 2022-04-07 op cat <<EOF > $testroot/wt/patch
983 9d6cabd5 2022-04-07 op --- foo/bar/alpha.orig
984 9d6cabd5 2022-04-07 op +++ foo/bar/alpha
990 9d6cabd5 2022-04-07 op (cd $testroot/wt && got patch -p2 patch) > $testroot/stdout
992 9d6cabd5 2022-04-07 op if [ $ret -ne 0 ]; then
993 9d6cabd5 2022-04-07 op test_done $testroot $ret
997 9d6cabd5 2022-04-07 op echo "M alpha" >> $testroot/stdout.expected
998 9d6cabd5 2022-04-07 op cmp -s $testroot/stdout.expected $testroot/stdout
1000 9d6cabd5 2022-04-07 op if [ $ret -ne 0 ]; then
1001 9d6cabd5 2022-04-07 op diff -u $testroot/stdout.expected $testroot/stdout
1002 9d6cabd5 2022-04-07 op test_done $testroot $ret
1006 9d6cabd5 2022-04-07 op (cd $testroot/wt && got revert alpha) > /dev/null 2>&1
1008 9d6cabd5 2022-04-07 op if [ $ret -ne 0 ]; then
1009 9d6cabd5 2022-04-07 op test_done $testroot $ret
1013 9d6cabd5 2022-04-07 op (cd $testroot/wt && got patch -p3 patch) \
1014 9d6cabd5 2022-04-07 op 2> $testroot/stderr
1016 9d6cabd5 2022-04-07 op if [ $ret -eq 0 ]; then
1017 9d6cabd5 2022-04-07 op echo "stripped more components than available!"
1018 9d6cabd5 2022-04-07 op test_done $testroot 1
1022 9d6cabd5 2022-04-07 op cat <<EOF > $testroot/stderr.expected
1023 9d6cabd5 2022-04-07 op got: can't strip 1 path-components from foo/bar/alpha: bad path
1026 9d6cabd5 2022-04-07 op cmp -s $testroot/stderr.expected $testroot/stderr
1028 9d6cabd5 2022-04-07 op if [ $ret -ne 0 ]; then
1029 9d6cabd5 2022-04-07 op diff -u $testroot/stderr.expected $testroot/stderr
1031 9d6cabd5 2022-04-07 op test_done $testroot 0
1034 a92a2042 2022-07-02 op test_patch_whitespace() {
1035 a92a2042 2022-07-02 op local testroot=`test_init patch_whitespace`
1037 a92a2042 2022-07-02 op got checkout $testroot/repo $testroot/wt > /dev/null
1039 a92a2042 2022-07-02 op if [ $ret -ne 0 ]; then
1040 a92a2042 2022-07-02 op test_done $testroot $ret
1044 a92a2042 2022-07-02 op trailing=" "
1046 a92a2042 2022-07-02 op cat <<EOF > $testroot/wt/hello.c
1047 a92a2042 2022-07-02 op #include <stdio.h>
1052 a92a2042 2022-07-02 op /* the trailing whitespace is on purpose */
1053 a92a2042 2022-07-02 op printf("hello, world\n");$trailing
1058 a92a2042 2022-07-02 op (cd $testroot/wt && got add hello.c && got ci -m '+hello.c') \
1061 a92a2042 2022-07-02 op if [ $ret -ne 0 ]; then
1062 a92a2042 2022-07-02 op test_done $testroot $ret
1066 a92a2042 2022-07-02 op # test with a diff with various whitespace corruptions
1067 a92a2042 2022-07-02 op cat <<EOF > $testroot/wt/patch
1070 a92a2042 2022-07-02 op @@ -5,5 +5,5 @@
1072 a92a2042 2022-07-02 op /* the trailing whitespace is on purpose */
1073 a92a2042 2022-07-02 op printf("hello, world\n");
1075 a92a2042 2022-07-02 op + return 5; /* always fails */
1079 a92a2042 2022-07-02 op (cd $testroot/wt && got patch patch) \
1080 a92a2042 2022-07-02 op 2>$testroot/stderr >$testroot/stdout
1082 a92a2042 2022-07-02 op if [ $ret -ne 0 ]; then
1083 a92a2042 2022-07-02 op echo "failed to apply diff" >&2
1084 a92a2042 2022-07-02 op test_done $testroot $ret
1088 a92a2042 2022-07-02 op echo 'M hello.c' > $testroot/stdout.expected
1089 a92a2042 2022-07-02 op echo '@@ -5,5 +5,5 @@ hunk contains mangled whitespace' \
1090 a92a2042 2022-07-02 op >> $testroot/stdout.expected
1091 a92a2042 2022-07-02 op cmp -s $testroot/stdout.expected $testroot/stdout
1093 a92a2042 2022-07-02 op if [ $ret -ne 0 ]; then
1094 a92a2042 2022-07-02 op diff -u $testroot/stdout.expected $testroot/stdout
1095 a92a2042 2022-07-02 op test_done $testroot $ret
1099 a92a2042 2022-07-02 op cat <<EOF > $testroot/wt/hello.c.expected
1100 a92a2042 2022-07-02 op #include <stdio.h>
1105 a92a2042 2022-07-02 op /* the trailing whitespace is on purpose */
1106 a92a2042 2022-07-02 op printf("hello, world\n");$trailing
1107 a92a2042 2022-07-02 op return 5; /* always fails */
1111 a92a2042 2022-07-02 op cmp -s $testroot/wt/hello.c.expected $testroot/wt/hello.c
1113 a92a2042 2022-07-02 op if [ $ret -ne 0 ]; then
1114 a92a2042 2022-07-02 op diff -u $testroot/wt/hello.c.expected $testroot/wt/hello.c
1116 a92a2042 2022-07-02 op test_done $testroot $ret
1119 ed3bff83 2022-04-23 op test_patch_relative_paths() {
1120 f1d6cebb 2022-04-23 op local testroot=`test_init patch_relative_paths`
1122 ed3bff83 2022-04-23 op got checkout $testroot/repo $testroot/wt > /dev/null
1124 ed3bff83 2022-04-23 op if [ $ret -ne 0 ]; then
1125 ed3bff83 2022-04-23 op test_done $testroot $ret
1129 ed3bff83 2022-04-23 op cat <<EOF > $testroot/wt/gamma/patch
1135 ed3bff83 2022-04-23 op --- /dev/null
1137 ed3bff83 2022-04-23 op @@ -0,0 +1 @@
1141 ed3bff83 2022-04-23 op (cd $testroot/wt/gamma && got patch patch) > $testroot/stdout
1143 ed3bff83 2022-04-23 op if [ $ret -ne 0 ]; then
1144 ed3bff83 2022-04-23 op test_done $testroot $ret
1148 ed3bff83 2022-04-23 op echo 'M gamma/delta' > $testroot/stdout.expected
1149 ed3bff83 2022-04-23 op echo 'A gamma/eta' >> $testroot/stdout.expected
1151 ed3bff83 2022-04-23 op cmp -s $testroot/stdout.expected $testroot/stdout
1153 ed3bff83 2022-04-23 op if [ $ret -ne 0 ]; then
1154 ed3bff83 2022-04-23 op diff -u $testroot/stdout.expected $testroot/stdout
1156 ed3bff83 2022-04-23 op test_done $testroot $ret
1159 15e1bda6 2022-04-23 op test_patch_with_path_prefix() {
1160 15e1bda6 2022-04-23 op local testroot=`test_init patch_with_path_prefix`
1162 15e1bda6 2022-04-23 op got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
1164 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1165 15e1bda6 2022-04-23 op test_done $testroot $ret
1169 15e1bda6 2022-04-23 op cat <<EOF > $testroot/wt/patch
1175 15e1bda6 2022-04-23 op --- /dev/null
1177 15e1bda6 2022-04-23 op @@ -0,0 +1 @@
1181 15e1bda6 2022-04-23 op (cd $testroot/wt && got patch patch) > $testroot/stdout
1183 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1184 15e1bda6 2022-04-23 op test_done $testroot $ret
1188 15e1bda6 2022-04-23 op echo 'M delta' > $testroot/stdout.expected
1189 15e1bda6 2022-04-23 op echo 'A eta' >> $testroot/stdout.expected
1191 15e1bda6 2022-04-23 op cmp -s $testroot/stdout.expected $testroot/stdout
1193 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1194 15e1bda6 2022-04-23 op diff -u $testroot/stdout.expected $testroot/stdout
1196 15e1bda6 2022-04-23 op test_done $testroot $ret
1199 15e1bda6 2022-04-23 op test_patch_relpath_with_path_prefix() {
1200 15e1bda6 2022-04-23 op local testroot=`test_init patch_relpaths_with_path_prefix`
1202 15e1bda6 2022-04-23 op got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
1204 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1205 15e1bda6 2022-04-23 op test_done $testroot $ret
1209 15e1bda6 2022-04-23 op mkdir -p $testroot/wt/epsilon/zeta/
1211 15e1bda6 2022-04-23 op cat <<EOF > $testroot/wt/patch
1212 15e1bda6 2022-04-23 op --- /dev/null
1213 15e1bda6 2022-04-23 op +++ zeta/theta
1214 15e1bda6 2022-04-23 op @@ -0,0 +1 @@
1218 15e1bda6 2022-04-23 op (cd $testroot/wt/epsilon/zeta && got patch -p1 $testroot/wt/patch) \
1219 15e1bda6 2022-04-23 op > $testroot/stdout
1221 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1222 15e1bda6 2022-04-23 op test_done $testroot $ret
1226 15e1bda6 2022-04-23 op echo 'A epsilon/zeta/theta' >> $testroot/stdout.expected
1228 15e1bda6 2022-04-23 op cmp -s $testroot/stdout.expected $testroot/stdout
1230 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1231 15e1bda6 2022-04-23 op diff -u $testroot/stdout.expected $testroot/stdout
1232 15e1bda6 2022-04-23 op test_done $testroot $ret
1236 15e1bda6 2022-04-23 op echo 'theta' > $testroot/theta.expected
1237 15e1bda6 2022-04-23 op cmp -s $testroot/wt/epsilon/zeta/theta $testroot/theta.expected
1239 15e1bda6 2022-04-23 op if [ $ret -ne 0 ]; then
1240 15e1bda6 2022-04-23 op diff -u $testroot/wt/epsilon/zeta/theta $testroot/theta.expected
1242 15e1bda6 2022-04-23 op test_done $testroot $ret
1245 bad961bf 2022-04-23 op test_patch_reverse() {
1246 bad961bf 2022-04-23 op local testroot=`test_init patch_reverse`
1248 bad961bf 2022-04-23 op got checkout $testroot/repo $testroot/wt > /dev/null
1250 bad961bf 2022-04-23 op if [ $ret -ne 0 ]; then
1251 bad961bf 2022-04-23 op test_done $testroot $ret
1255 bad961bf 2022-04-23 op cat <<EOF > $testroot/wt/patch
1260 bad961bf 2022-04-23 op \ No newline at end of file
1264 bad961bf 2022-04-23 op (cd $testroot/wt && got patch -R patch) > $testroot/stdout
1266 bad961bf 2022-04-23 op if [ $ret -ne 0 ]; then
1267 bad961bf 2022-04-23 op test_done $testroot $ret
1271 bad961bf 2022-04-23 op echo "M alpha" > $testroot/stdout.expected
1272 bad961bf 2022-04-23 op cmp -s $testroot/stdout.expected $testroot/stdout
1274 bad961bf 2022-04-23 op if [ $ret -ne 0 ]; then
1275 bad961bf 2022-04-23 op diff -u $testroot/stdout.expected $testroot/stdout
1276 bad961bf 2022-04-23 op test_done $testroot $ret
1280 bad961bf 2022-04-23 op echo -n ALPHA > $testroot/wt/alpha.expected
1281 bad961bf 2022-04-23 op cmp -s $testroot/wt/alpha.expected $testroot/wt/alpha
1283 bad961bf 2022-04-23 op if [ $ret -ne 0 ]; then
1284 bad961bf 2022-04-23 op diff -u $testroot/wt/alpha.expected $testroot/wt/alpha
1286 bad961bf 2022-04-23 op test_done $testroot $ret
1289 55e9459f 2022-06-19 op test_patch_merge_simple() {
1290 55e9459f 2022-06-19 op local testroot=`test_init patch_merge_simple`
1292 55e9459f 2022-06-19 op got checkout $testroot/repo $testroot/wt > /dev/null
1294 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1295 55e9459f 2022-06-19 op test_done $testroot $ret
1299 55e9459f 2022-06-19 op jot 10 > $testroot/wt/numbers
1300 5dffb1a1 2022-07-02 op chmod +x $testroot/wt/numbers
1301 55e9459f 2022-06-19 op (cd $testroot/wt && got add numbers && got commit -m +numbers) \
1304 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1305 55e9459f 2022-06-19 op test_done $testroot $ret
1309 55e9459f 2022-06-19 op jot 10 | sed 's/4/four/g' > $testroot/wt/numbers
1311 55e9459f 2022-06-19 op (cd $testroot/wt && got diff > $testroot/old.diff \
1312 55e9459f 2022-06-19 op && got revert numbers) >/dev/null
1314 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1315 55e9459f 2022-06-19 op test_done $testroot $ret
1319 55e9459f 2022-06-19 op jot 10 | sed 's/6/six/g' > $testroot/wt/numbers
1320 55e9459f 2022-06-19 op (cd $testroot/wt && got commit -m 'edit numbers') \
1323 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1324 55e9459f 2022-06-19 op test_done $testroot $ret
1328 55e9459f 2022-06-19 op (cd $testroot/wt && got patch $testroot/old.diff) \
1329 9802c41c 2022-06-21 op > $testroot/stdout
1331 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1332 55e9459f 2022-06-19 op test_done $testroot $ret
1336 9802c41c 2022-06-21 op echo 'G numbers' > $testroot/stdout.expected
1337 9802c41c 2022-06-21 op cmp -s $testroot/stdout $testroot/stdout.expected
1339 9802c41c 2022-06-21 op if [ $ret -ne 0 ]; then
1340 9802c41c 2022-06-21 op diff -u $testroot/stdout $testroot/stdout.expected
1341 9802c41c 2022-06-21 op test_done $testroot $ret
1345 55e9459f 2022-06-19 op jot 10 | sed -e s/4/four/ -e s/6/six/ > $testroot/wt/numbers.expected
1346 55e9459f 2022-06-19 op cmp -s $testroot/wt/numbers $testroot/wt/numbers.expected
1348 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1349 55e9459f 2022-06-19 op diff -u $testroot/wt/numbers $testroot/wt/numbers.expected
1350 5dffb1a1 2022-07-02 op test_done $testroot $ret
1354 5dffb1a1 2022-07-02 op test -x $testroot/wt/numbers
1356 5dffb1a1 2022-07-02 op if [ $ret -ne 0 ]; then
1357 5dffb1a1 2022-07-02 op echo "numbers lost the executable bit" >&2
1359 55e9459f 2022-06-19 op test_done $testroot $ret
1362 db0dfdd7 2022-06-27 op test_patch_merge_gitdiff() {
1363 db0dfdd7 2022-06-27 op local testroot=`test_init patch_merge_gitdiff`
1365 db0dfdd7 2022-06-27 op jot 10 > $testroot/repo/numbers
1366 db0dfdd7 2022-06-27 op (cd $testroot/repo && git add numbers && \
1367 db0dfdd7 2022-06-27 op git_commit $testroot/repo -m "nums")
1369 db0dfdd7 2022-06-27 op if [ $ret -ne 0 ]; then
1370 db0dfdd7 2022-06-27 op test_done $testroot $ret
1374 db0dfdd7 2022-06-27 op jot 10 | sed 's/4/four/g' > $testroot/repo/numbers
1375 db0dfdd7 2022-06-27 op (cd $testroot/repo && git diff > $testroot/old.diff)
1377 db0dfdd7 2022-06-27 op if [ $ret -ne 0 ]; then
1378 db0dfdd7 2022-06-27 op test_done $testroot $ret
1382 db0dfdd7 2022-06-27 op # restore numbers
1383 db0dfdd7 2022-06-27 op jot 10 > $testroot/repo/numbers
1385 db0dfdd7 2022-06-27 op jot 10 | sed 's/6/six/g' > $testroot/repo/numbers
1386 db0dfdd7 2022-06-27 op (cd $testroot/repo && git add numbers && \
1387 db0dfdd7 2022-06-27 op git_commit $testroot/repo -m "edit")
1389 db0dfdd7 2022-06-27 op if [ $ret -ne 0 ]; then
1390 db0dfdd7 2022-06-27 op test_done $testroot $ret
1394 db0dfdd7 2022-06-27 op # now work with got:
1395 db0dfdd7 2022-06-27 op got checkout $testroot/repo $testroot/wt > /dev/null
1397 db0dfdd7 2022-06-27 op if [ $ret -ne 0 ]; then
1398 db0dfdd7 2022-06-27 op test_done $testroot $ret
1402 db0dfdd7 2022-06-27 op (cd $testroot/wt && got patch $testroot/old.diff) > $testroot/stdout
1404 db0dfdd7 2022-06-27 op if [ $ret -ne 0 ]; then
1405 db0dfdd7 2022-06-27 op test_done $testroot $ret
1409 db0dfdd7 2022-06-27 op echo 'G numbers' > $testroot/stdout.expected
1410 db0dfdd7 2022-06-27 op cmp -s $testroot/stdout $testroot/stdout.expected
1412 db0dfdd7 2022-06-27 op if [ $ret -ne 0 ]; then
1413 db0dfdd7 2022-06-27 op diff -u $testroot/stdout $testroot/stdout.expected
1415 db0dfdd7 2022-06-27 op test_done $testroot $ret
1418 5f56d41e 2022-07-28 op test_patch_merge_base_provided() {
1419 5f56d41e 2022-07-28 op local testroot=`test_init patch_merge_base_provided`
1421 5f56d41e 2022-07-28 op got checkout $testroot/repo $testroot/wt >/dev/null
1423 5f56d41e 2022-07-28 op if [ $ret -ne 0 ]; then
1424 5f56d41e 2022-07-28 op test_done $testroot $ret
1428 5f56d41e 2022-07-28 op jot 10 > $testroot/wt/numbers
1429 5f56d41e 2022-07-28 op (cd $testroot/wt && got add numbers && got commit -m +numbers) \
1432 5f56d41e 2022-07-28 op if [ $ret -ne 0 ]; then
1433 5f56d41e 2022-07-28 op test_done $testroot $ret
1437 5f56d41e 2022-07-28 op local commit_id=`git_show_head $testroot/repo`
1439 5f56d41e 2022-07-28 op jot 10 | sed s/4/four/ > $testroot/wt/numbers
1441 5f56d41e 2022-07-28 op # get rid of the metadata
1442 5f56d41e 2022-07-28 op (cd $testroot/wt && got diff | sed -n '/^---/,$p' > patch) \
1445 5f56d41e 2022-07-28 op jot 10 | sed s/6/six/ > $testroot/wt/numbers
1446 5f56d41e 2022-07-28 op (cd $testroot/wt && got commit -m 'edit numbers') >/dev/null
1448 5f56d41e 2022-07-28 op if [ $ret -ne 0 ]; then
1449 5f56d41e 2022-07-28 op test_done $testroot $ret
1453 5f56d41e 2022-07-28 op (cd $testroot/wt && got patch -c $commit_id patch) >$testroot/stdout
1455 5f56d41e 2022-07-28 op if [ $ret -ne 0 ]; then
1456 5f56d41e 2022-07-28 op test_done $testroot $ret
1460 5f56d41e 2022-07-28 op echo 'G numbers' > $testroot/stdout.expected
1461 5f56d41e 2022-07-28 op cmp -s $testroot/stdout $testroot/stdout.expected
1463 5f56d41e 2022-07-28 op if [ $ret -ne 0 ]; then
1464 5f56d41e 2022-07-28 op diff -u $testroot/stdout $testroot/stdout.expected
1465 5f56d41e 2022-07-28 op test_done $testroot $ret
1469 5f56d41e 2022-07-28 op jot 10 | sed -e s/4/four/ -e s/6/six/ > $testroot/wt/numbers.expected
1470 5f56d41e 2022-07-28 op cmp -s $testroot/wt/numbers $testroot/wt/numbers.expected
1472 5f56d41e 2022-07-28 op if [ $ret -ne 0 ]; then
1473 5f56d41e 2022-07-28 op diff -u $testroot/wt/numbers $testroot/wt/numbers.expected
1475 5f56d41e 2022-07-28 op test_done $testroot $ret
1478 55e9459f 2022-06-19 op test_patch_merge_conflict() {
1479 55e9459f 2022-06-19 op local testroot=`test_init patch_merge_conflict`
1481 55e9459f 2022-06-19 op got checkout $testroot/repo $testroot/wt > /dev/null
1483 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1484 55e9459f 2022-06-19 op test_done $testroot $ret
1488 55e9459f 2022-06-19 op jot 10 > $testroot/wt/numbers
1489 55e9459f 2022-06-19 op (cd $testroot/wt && got add numbers && got commit -m +numbers) \
1492 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1493 55e9459f 2022-06-19 op test_done $testroot $ret
1497 d8b5af43 2022-06-19 op local commit_id=`git_show_head $testroot/repo`
1499 55e9459f 2022-06-19 op jot 10 | sed 's/6/six/g' > $testroot/wt/numbers
1500 acf749fc 2022-07-02 op echo ALPHA > $testroot/wt/alpha
1502 55e9459f 2022-06-19 op (cd $testroot/wt && got diff > $testroot/old.diff \
1503 acf749fc 2022-07-02 op && got revert alpha numbers) >/dev/null
1505 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1506 55e9459f 2022-06-19 op test_done $testroot $ret
1510 55e9459f 2022-06-19 op jot 10 | sed 's/6/3+3/g' > $testroot/wt/numbers
1511 acf749fc 2022-07-02 op jot -c 3 a > $testroot/wt/alpha
1512 acf749fc 2022-07-02 op (cd $testroot/wt && got commit -m 'edit alpha and numbers') \
1515 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1516 55e9459f 2022-06-19 op test_done $testroot $ret
1520 55e9459f 2022-06-19 op (cd $testroot/wt && got patch $testroot/old.diff) \
1521 9802c41c 2022-06-21 op > $testroot/stdout 2>/dev/null
1523 55e9459f 2022-06-19 op if [ $ret -eq 0 ]; then
1524 55e9459f 2022-06-19 op echo "got patch merged a diff that should conflict" >&2
1525 55e9459f 2022-06-19 op test_done $testroot 0
1529 acf749fc 2022-07-02 op echo 'C alpha' > $testroot/stdout.expected
1530 acf749fc 2022-07-02 op echo 'C numbers' >> $testroot/stdout.expected
1531 9802c41c 2022-06-21 op cmp -s $testroot/stdout $testroot/stdout.expected
1533 9802c41c 2022-06-21 op if [ $ret -ne 0 ]; then
1534 9802c41c 2022-06-21 op diff -u $testroot/stdout $testroot/stdout.expected
1535 9802c41c 2022-06-21 op test_done $testroot $ret
1539 55e9459f 2022-06-19 op # XXX: prefixing every line with a tab otherwise got thinks
1540 55e9459f 2022-06-19 op # the file has conflicts in it.
1541 acf749fc 2022-07-02 op cat <<-EOF > $testroot/wt/alpha.expected
1542 acf749fc 2022-07-02 op <<<<<<< --- alpha
1544 acf749fc 2022-07-02 op ||||||| commit $commit_id
1550 acf749fc 2022-07-02 op >>>>>>> +++ alpha
1553 55e9459f 2022-06-19 op cat <<-EOF > $testroot/wt/numbers.expected
1559 55e9459f 2022-06-19 op <<<<<<< --- numbers
1561 d8b5af43 2022-06-19 op ||||||| commit $commit_id
1565 55e9459f 2022-06-19 op >>>>>>> +++ numbers
1572 acf749fc 2022-07-02 op cmp -s $testroot/wt/alpha $testroot/wt/alpha.expected
1574 acf749fc 2022-07-02 op if [ $ret -ne 0 ]; then
1575 acf749fc 2022-07-02 op diff -u $testroot/wt/alpha $testroot/wt/alpha.expected
1576 acf749fc 2022-07-02 op test_done $testroot $ret
1580 55e9459f 2022-06-19 op cmp -s $testroot/wt/numbers $testroot/wt/numbers.expected
1582 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1583 55e9459f 2022-06-19 op diff -u $testroot/wt/numbers $testroot/wt/numbers.expected
1585 55e9459f 2022-06-19 op test_done $testroot $ret
1588 55e9459f 2022-06-19 op test_patch_merge_unknown_blob() {
1589 55e9459f 2022-06-19 op local testroot=`test_init patch_merge_unknown_blob`
1591 55e9459f 2022-06-19 op got checkout $testroot/repo $testroot/wt > /dev/null
1593 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1594 55e9459f 2022-06-19 op test_done $testroot $ret
1598 55e9459f 2022-06-19 op cat <<EOF > $testroot/wt/patch
1600 dbc68eed 2022-06-21 op diff aaaabbbbccccddddeeeeffff0000111122223333 foo/bar
1602 55e9459f 2022-06-19 op blob - aaaabbbbccccddddeeeeffff0000111122223333
1604 dbc68eed 2022-06-21 op blob + 0000111122223333444455556666777788889999
1605 55e9459f 2022-06-19 op for this dummy diff
1611 55e9459f 2022-06-19 op will it work?
1614 55e9459f 2022-06-19 op (cd $testroot/wt/ && got patch patch) > $testroot/stdout
1616 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1617 55e9459f 2022-06-19 op test_done $testroot $ret
1621 55e9459f 2022-06-19 op echo 'M alpha' > $testroot/stdout.expected
1622 55e9459f 2022-06-19 op cmp -s $testroot/stdout.expected $testroot/stdout
1624 55e9459f 2022-06-19 op if [ $ret -ne 0 ]; then
1625 55e9459f 2022-06-19 op diff -u $testroot/stdout.expected $testroot/stdout
1626 dbc68eed 2022-06-21 op test_done $testroot $ret
1630 dbc68eed 2022-06-21 op # try again without a `diff' header
1632 dbc68eed 2022-06-21 op cat <<EOF > $testroot/wt/patch
1634 dbc68eed 2022-06-21 op blob - aaaabbbbccccddddeeeeffff0000111122223333
1636 dbc68eed 2022-06-21 op blob + 0000111122223333444455556666777788889999
1637 dbc68eed 2022-06-21 op for this dummy diff
1643 dbc68eed 2022-06-21 op will it work?
1646 dbc68eed 2022-06-21 op (cd $testroot/wt && got revert alpha > /dev/null && got patch patch) \
1647 dbc68eed 2022-06-21 op > $testroot/stdout
1649 dbc68eed 2022-06-21 op if [ $ret -ne 0 ]; then
1650 dbc68eed 2022-06-21 op test_done $testroot $ret
1654 dbc68eed 2022-06-21 op echo 'M alpha' > $testroot/stdout.expected
1655 dbc68eed 2022-06-21 op cmp -s $testroot/stdout.expected $testroot/stdout
1657 dbc68eed 2022-06-21 op if [ $ret -ne 0 ]; then
1658 dbc68eed 2022-06-21 op diff -u $testroot/stdout.expected $testroot/stdout
1659 db0dfdd7 2022-06-27 op test_done $testroot $ret
1663 db0dfdd7 2022-06-27 op # try again with a git-style diff
1665 db0dfdd7 2022-06-27 op cat <<EOF > $testroot/wt/patch
1666 db0dfdd7 2022-06-27 op diff --git a/alpha b/alpha
1667 db0dfdd7 2022-06-27 op index 0123456789ab..abcdef012345 100644
1675 db0dfdd7 2022-06-27 op (cd $testroot/wt && got revert alpha > /dev/null && got patch patch) \
1676 db0dfdd7 2022-06-27 op > $testroot/stdout
1678 db0dfdd7 2022-06-27 op if [ $ret -ne 0 ]; then
1679 db0dfdd7 2022-06-27 op test_done $testroot $ret
1683 db0dfdd7 2022-06-27 op echo 'M alpha' > $testroot/stdout.expected
1684 db0dfdd7 2022-06-27 op cmp -s $testroot/stdout.expected $testroot/stdout
1686 db0dfdd7 2022-06-27 op if [ $ret -ne 0 ]; then
1687 db0dfdd7 2022-06-27 op diff -u $testroot/stdout.expected $testroot/stdout
1689 55e9459f 2022-06-19 op test_done $testroot $ret
1692 38d61ead 2022-07-23 op test_patch_merge_reverse() {
1693 38d61ead 2022-07-23 op local testroot=`test_init patch_merge_simple`
1695 38d61ead 2022-07-23 op got checkout $testroot/repo $testroot/wt > /dev/null
1697 38d61ead 2022-07-23 op if [ $ret -ne 0 ]; then
1698 38d61ead 2022-07-23 op test_done $testroot $ret
1702 38d61ead 2022-07-23 op jot 10 > $testroot/wt/numbers
1703 38d61ead 2022-07-23 op (cd $testroot/wt && got add numbers && got commit -m +numbers) \
1706 38d61ead 2022-07-23 op if [ $ret -ne 0 ]; then
1707 38d61ead 2022-07-23 op test_done $testroot $ret
1711 38d61ead 2022-07-23 op local commit_id=`git_show_head $testroot/repo`
1713 38d61ead 2022-07-23 op jot 10 | sed s/5/five/g > $testroot/wt/numbers
1714 38d61ead 2022-07-23 op (cd $testroot/wt && got diff > $testroot/wt/patch \
1715 38d61ead 2022-07-23 op && got commit -m 'edit numbers') > /dev/null
1717 38d61ead 2022-07-23 op if [ $ret -ne 0 ]; then
1718 38d61ead 2022-07-23 op test_done $testroot $ret
1722 38d61ead 2022-07-23 op jot 10 | sed -e s/5/five/g -e s/6/six/g > $testroot/wt/numbers
1723 38d61ead 2022-07-23 op (cd $testroot/wt && got commit -m 'edit numbers again') >/dev/null
1725 38d61ead 2022-07-23 op if [ $ret -ne 0 ]; then
1726 38d61ead 2022-07-23 op test_done $testroot $ret
1730 38d61ead 2022-07-23 op (cd $testroot/wt && got patch -R patch) >/dev/null 2>&1
1732 38d61ead 2022-07-23 op if [ $ret -eq 0 ]; then
1733 38d61ead 2022-07-23 op echo "unexpectedly reverted the patch" >&2
1734 38d61ead 2022-07-23 op test_done $testroot 1
1738 38d61ead 2022-07-23 op cat <<-EOF > $testroot/wt/numbers.expected
1743 38d61ead 2022-07-23 op <<<<<<< --- numbers
1746 38d61ead 2022-07-23 op ||||||| +++ numbers
1751 38d61ead 2022-07-23 op >>>>>>> commit $commit_id
1758 38d61ead 2022-07-23 op cmp -s $testroot/wt/numbers $testroot/wt/numbers.expected
1760 38d61ead 2022-07-23 op if [ $ret -ne 0 ]; then
1761 38d61ead 2022-07-23 op diff -u $testroot/wt/numbers $testroot/wt/numbers.expected
1763 38d61ead 2022-07-23 op test_done $testroot $ret
1766 611e5fc2 2022-09-21 mark test_patch_newfile_xbit_got_diff() {
1767 611e5fc2 2022-09-21 mark local testroot=`test_init patch_newfile_xbit`
1769 611e5fc2 2022-09-21 mark got checkout $testroot/repo $testroot/wt > /dev/null
1771 611e5fc2 2022-09-21 mark if [ $ret -ne 0 ]; then
1772 611e5fc2 2022-09-21 mark test_done $testroot $ret
1776 611e5fc2 2022-09-21 mark cat <<EOF > $testroot/wt/patch
1777 611e5fc2 2022-09-21 mark blob - /dev/null
1778 611e5fc2 2022-09-21 mark blob + abcdef0123456789abcdef012345678901234567 (mode 755)
1779 611e5fc2 2022-09-21 mark --- /dev/null
1781 611e5fc2 2022-09-21 mark @@ -0,0 +1,1 @@
1785 611e5fc2 2022-09-21 mark (cd $testroot/wt && got patch patch) > /dev/null
1787 611e5fc2 2022-09-21 mark if [ $ret -ne 0 ]; then
1788 611e5fc2 2022-09-21 mark test_done $testroot $ret
1792 611e5fc2 2022-09-21 mark if [ ! -x $testroot/wt/xfile ]; then
1793 611e5fc2 2022-09-21 mark echo "failed to set xbit on newfile" >&2
1794 611e5fc2 2022-09-21 mark test_done $testroot 1
1798 611e5fc2 2022-09-21 mark echo xfile > $testroot/wt/xfile.expected
1799 611e5fc2 2022-09-21 mark cmp -s $testroot/wt/xfile $testroot/wt/xfile.expected
1801 611e5fc2 2022-09-21 mark if [ $ret -ne 0 ]; then
1802 611e5fc2 2022-09-21 mark echo "fail"
1803 611e5fc2 2022-09-21 mark diff -u $testroot/wt/xfile $testroot/wt/xfile.expected
1806 611e5fc2 2022-09-21 mark test_done $testroot $ret
1809 611e5fc2 2022-09-21 mark test_patch_newfile_xbit_git_diff() {
1810 611e5fc2 2022-09-21 mark local testroot=`test_init patch_newfile_xbit`
1812 611e5fc2 2022-09-21 mark got checkout $testroot/repo $testroot/wt > /dev/null
1814 611e5fc2 2022-09-21 mark if [ $ret -ne 0 ]; then
1815 611e5fc2 2022-09-21 mark test_done $testroot $ret
1819 611e5fc2 2022-09-21 mark cat <<EOF > $testroot/wt/patch
1820 611e5fc2 2022-09-21 mark diff --git a/xfile b/xfile
1821 611e5fc2 2022-09-21 mark new file mode 100755
1822 611e5fc2 2022-09-21 mark index 00000000..abcdef01
1823 611e5fc2 2022-09-21 mark --- /dev/null
1824 611e5fc2 2022-09-21 mark +++ b/xfile
1825 611e5fc2 2022-09-21 mark @@ -0,0 +1,1 @@
1829 611e5fc2 2022-09-21 mark (cd $testroot/wt && got patch patch) > /dev/null
1831 611e5fc2 2022-09-21 mark if [ $ret -ne 0 ]; then
1832 611e5fc2 2022-09-21 mark test_done $testroot $ret
1836 611e5fc2 2022-09-21 mark if [ ! -x $testroot/wt/xfile ]; then
1837 611e5fc2 2022-09-21 mark echo "failed to set xbit on newfile" >&2
1838 611e5fc2 2022-09-21 mark test_done $testroot 1
1842 611e5fc2 2022-09-21 mark echo xfile > $testroot/wt/xfile.expected
1843 611e5fc2 2022-09-21 mark cmp -s $testroot/wt/xfile $testroot/wt/xfile.expected
1845 611e5fc2 2022-09-21 mark if [ $ret -ne 0 ]; then
1846 611e5fc2 2022-09-21 mark echo "fail"
1847 611e5fc2 2022-09-21 mark diff -u $testroot/wt/xfile $testroot/wt/xfile.expected
1850 611e5fc2 2022-09-21 mark test_done $testroot $ret
1853 b2b3fce1 2022-10-29 op test_patch_umask() {
1854 b2b3fce1 2022-10-29 op local testroot=`test_init patch_umask`
1856 b2b3fce1 2022-10-29 op got checkout "$testroot/repo" "$testroot/wt" >/dev/null
1858 b2b3fce1 2022-10-29 op cat <<EOF >$testroot/wt/patch
1863 b2b3fce1 2022-10-29 op +modified alpha
1866 b2b3fce1 2022-10-29 op # using a subshell to avoid clobbering global umask
1867 b2b3fce1 2022-10-29 op (umask 077 && cd "$testroot/wt" && got patch <patch) >/dev/null
1869 b2b3fce1 2022-10-29 op if [ $ret -ne 0 ]; then
1870 b2b3fce1 2022-10-29 op test_done "$testroot" $ret
1874 b2b3fce1 2022-10-29 op if ! ls -l "$testroot/wt/alpha" | grep -q ^-rw-------; then
1875 b2b3fce1 2022-10-29 op echo "alpha is not 0600 after patch" >&2
1876 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/alpha" >&2
1877 b2b3fce1 2022-10-29 op test_done "$testroot" 1
1881 b2b3fce1 2022-10-29 op test_done "$testroot" 0
1884 e9ce266e 2022-03-07 op test_parseargs "$@"
1885 57b1c3f2 2022-08-01 op run_test test_patch_basic
1886 e9ce266e 2022-03-07 op run_test test_patch_dont_apply
1887 e9ce266e 2022-03-07 op run_test test_patch_malformed
1888 e9ce266e 2022-03-07 op run_test test_patch_no_patch
1889 e9ce266e 2022-03-07 op run_test test_patch_equals_for_context
1890 6e96b326 2022-03-12 op run_test test_patch_rename
1891 dbda770b 2022-03-13 op run_test test_patch_illegal_status
1892 899fcfdf 2022-03-13 op run_test test_patch_nop
1893 2be5e1a2 2022-03-16 op run_test test_patch_preserve_perm
1894 95d68340 2022-03-16 op run_test test_patch_create_dirs
1895 60aa1fa0 2022-03-17 op run_test test_patch_with_offset
1896 7a30b5cb 2022-03-20 op run_test test_patch_prefer_new_path
1897 b3c57ab2 2022-03-22 op run_test test_patch_no_newline
1898 9d6cabd5 2022-04-07 op run_test test_patch_strip
1899 a92a2042 2022-07-02 op run_test test_patch_whitespace
1900 ed3bff83 2022-04-23 op run_test test_patch_relative_paths
1901 15e1bda6 2022-04-23 op run_test test_patch_with_path_prefix
1902 15e1bda6 2022-04-23 op run_test test_patch_relpath_with_path_prefix
1903 bad961bf 2022-04-23 op run_test test_patch_reverse
1904 55e9459f 2022-06-19 op run_test test_patch_merge_simple
1905 db0dfdd7 2022-06-27 op run_test test_patch_merge_gitdiff
1906 5f56d41e 2022-07-28 op run_test test_patch_merge_base_provided
1907 55e9459f 2022-06-19 op run_test test_patch_merge_conflict
1908 55e9459f 2022-06-19 op run_test test_patch_merge_unknown_blob
1909 38d61ead 2022-07-23 op run_test test_patch_merge_reverse
1910 611e5fc2 2022-09-21 mark run_test test_patch_newfile_xbit_got_diff
1911 611e5fc2 2022-09-21 mark run_test test_patch_newfile_xbit_git_diff
1912 b2b3fce1 2022-10-29 op run_test test_patch_umask