xref: /aosp_15_r20/external/toybox/tests/patch.test (revision cf5a6c84e2b8763fc1a7db14496fd4742913b199)
1#!/bin/bash
2
3[ -f testing.sh ] && . testing.sh
4
5#testing "name" "command" "result" "infile" "stdin"
6
7testing "dry run doesn't create file" \
8  "patch --dry-run >/dev/null && [ ! -e bork ] && echo yes" "yes\n" "" "
9--- /dev/null
10+++ bork
11@@ -0,0 +1,1 @@
12+one
13"
14
15testing "create file" "patch >/dev/null && cat bork" "one\ntwo\nthree\n" "" "
16--- /dev/null
17+++ bork
18@@ -0,0 +1,3 @@
19+one
20+two
21+three
22"
23
24testing "insert in middle" "patch > /dev/null && cat bork" \
25  "one\nfour\ntwo\nthree\n" "" "
26--- bork
27+++ bork
28@@ -1,3 +1,4 @@
29 one
30+four
31 two
32 three
33"
34testing "append at end" "patch > /dev/null && cat bork" \
35  "one\nfour\ntwo\nthree\nfive\nsix\n" "" "
36--- bork
37+++ bork
38@@ -2,3 +2,5 @@
39 four
40 two
41 three
42+five
43+six
44"
45testing "insert at start" "patch > /dev/null && cat bork" \
46  "seven\none\nfour\ntwo\nthree\nfive\nsix\n" "" "
47--- bork
48+++ bork
49@@ -1,3 +1,4 @@
50+seven
51 one
52 four
53 two
54"
55testing "delete at end" "patch > /dev/null && cat bork" \
56  "seven\none\nfour\ntwo\nthree\nfive\n" "" "
57--- bork
58+++ bork
59@@ -4,4 +4,3 @@
60 two
61 three
62 five
63-six
64"
65
66testing "delete at start" "patch > /dev/null && cat bork" \
67  "four\ntwo\nthree\nfive\n" "" "
68--- bork
69+++ bork
70@@ -1,5 +1,3 @@
71-seven
72-one
73 four
74 two
75 three
76"
77
78testing "filter timestamps" "patch > /dev/null && cat bork" \
79  "four\ntwo\nthree\neight\nfive\n" "" "
80--- bork	2019-12-20 16:54:35.735630973 -0600
81+++ bork	2019-12-20 16:57:03.083625706 -0600
82@@ -1,4 +1,5 @@
83 four
84 two
85 three
86+eight
87 five
88"
89
90testing "quoted name" "patch > /dev/null && cat 'fruit bat'" \
91  "hello\n" "" '
92--- /dev/null
93+++ "fruit ba\164"
94@@ -0,0 +1 @@
95+hello
96'
97
98testing "bad quote" "patch 2>&1" $'patch: bad "filename\n' "" '--- "filename'
99
100testing "dry run doesn't delete file" \
101  "patch --dry-run > /dev/null && [ -e 'fruit bat' ] && echo yes" "yes\n" "" '
102--- "fruit bat"
103+++ /dev/null
104@@ -1 +0,0 @@
105-hello
106'
107
108testing "delete file" \
109  "patch > /dev/null && [ ! -e 'fruit bat' ] && echo yes" "yes\n" "" '
110--- "fruit bat"
111+++ /dev/null
112@@ -1 +0,0 @@
113-hello
114'
115
116# todo bork bork2
117
118# We hit a bug, test the bugfix.
119testing "fuzz" "patch > /dev/null && cat input" \
120"blah blah
121 */
122package org.yaml.snakeyaml.representer;
123
124import java.util.ArrayList;
125import java.util.Arrays;
126import java.util.Collections;
127import java.util.Iterator;
128" "blah blah
129 */
130package org.yaml.snakeyaml.representer;
131
132import java.beans.IntrospectionException;
133import java.util.ArrayList;
134import java.util.Arrays;
135import java.util.Collections;
136import java.util.Iterator;
137" "--- a/x/input
138+++ b/x/input
139@@ -15,7 +15,6 @@
140  */
141 package org.yaml.snakeyaml.representer;
142
143-import java.beans.IntrospectionException;
144 import java.util.ArrayList;
145 import java.util.Arrays;
146 import java.util.Iterator;
147"
148