Mercurial > hg
annotate tests/test-diff-indent-heuristic.t @ 52050:de317a87ea6a
rust-pathauditor: match more of Python's behavior and display messages
We will make use of the path auditor when running our update fast-path,
and we want to output of it to be close enough.
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Wed, 02 Oct 2024 20:29:48 +0200 |
parents | 55c6ebd11cb9 |
children |
rev | line source |
---|---|
36678 | 1 #testcases bdiff xdiff |
2 | |
3 #if xdiff | |
4 #require xdiff | |
5 $ cat >> $HGRCPATH <<EOF | |
6 > [experimental] | |
7 > xdiff = true | |
8 > EOF | |
9 #endif | |
10 | |
49621
55c6ebd11cb9
tests: run many tests in $TESTTMP/repo instead of $TESTTMP
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
36678
diff
changeset
|
11 $ hg init repo |
55c6ebd11cb9
tests: run many tests in $TESTTMP/repo instead of $TESTTMP
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents:
36678
diff
changeset
|
12 $ cd repo |
36678 | 13 |
14 $ cat > a.c <<'EOF' | |
15 > /* | |
16 > * This function returns 1. | |
17 > */ | |
18 > int f() { | |
19 > return 1; | |
20 > } | |
21 > /* | |
22 > * This function returns 2. | |
23 > */ | |
24 > int g() { | |
25 > return 2; | |
26 > } | |
27 > /* | |
28 > * This function returns 3. | |
29 > */ | |
30 > int h() { | |
31 > return 3; | |
32 > } | |
33 > EOF | |
34 | |
35 $ cat > b.c <<'EOF' | |
36 > if (x) { | |
37 > do_something(); | |
38 > } | |
39 > | |
40 > if (y) { | |
41 > do_something_else(); | |
42 > } | |
43 > EOF | |
44 | |
45 $ cat > c.rb <<'EOF' | |
46 > #!ruby | |
47 > ["foo", "bar", "baz"].map do |i| | |
48 > i.upcase | |
49 > end | |
50 > EOF | |
51 | |
52 $ cat > d.py <<'EOF' | |
53 > try: | |
54 > import foo | |
55 > except ImportError: | |
56 > pass | |
57 > try: | |
58 > import bar | |
59 > except ImportError: | |
60 > pass | |
61 > EOF | |
62 | |
63 The below two files are taken from git: t/t4061-diff-indent.sh | |
64 | |
65 $ cat > spaces.txt <<'EOF' | |
66 > 1 | |
67 > 2 | |
68 > a | |
69 > | |
70 > b | |
71 > 3 | |
72 > 4 | |
73 > EOF | |
74 | |
75 $ cat > functions.c <<'EOF' | |
76 > 1 | |
77 > 2 | |
78 > /* function */ | |
79 > foo() { | |
80 > foo | |
81 > } | |
82 > | |
83 > 3 | |
84 > 4 | |
85 > EOF | |
86 | |
87 $ hg commit -m 1 -A . -q | |
88 | |
89 $ cat > a.c <<'EOF' | |
90 > /* | |
91 > * This function returns 1. | |
92 > */ | |
93 > int f() { | |
94 > return 1; | |
95 > } | |
96 > /* | |
97 > * This function returns 3. | |
98 > */ | |
99 > int h() { | |
100 > return 3; | |
101 > } | |
102 > EOF | |
103 | |
104 $ cat > b.c <<'EOF' | |
105 > if (x) { | |
106 > do_something(); | |
107 > } | |
108 > | |
109 > if (y) { | |
110 > do_another_thing(); | |
111 > } | |
112 > | |
113 > if (y) { | |
114 > do_something_else(); | |
115 > } | |
116 > EOF | |
117 | |
118 $ cat > c.rb <<'EOF' | |
119 > #!ruby | |
120 > ["foo", "bar", "baz"].map do |i| | |
121 > i | |
122 > end | |
123 > ["foo", "bar", "baz"].map do |i| | |
124 > i.upcase | |
125 > end | |
126 > EOF | |
127 | |
128 $ cat > d.py <<'EOF' | |
129 > try: | |
130 > import foo | |
131 > except ImportError: | |
132 > pass | |
133 > try: | |
134 > import baz | |
135 > except ImportError: | |
136 > pass | |
137 > try: | |
138 > import bar | |
139 > except ImportError: | |
140 > pass | |
141 > EOF | |
142 | |
143 $ cat > spaces.txt <<'EOF' | |
144 > 1 | |
145 > 2 | |
146 > a | |
147 > | |
148 > b | |
149 > a | |
150 > | |
151 > b | |
152 > 3 | |
153 > 4 | |
154 > EOF | |
155 | |
156 $ cat > functions.c <<'EOF' | |
157 > 1 | |
158 > 2 | |
159 > /* function */ | |
160 > bar() { | |
161 > foo | |
162 > } | |
163 > | |
164 > /* function */ | |
165 > foo() { | |
166 > foo | |
167 > } | |
168 > | |
169 > 3 | |
170 > 4 | |
171 > EOF | |
172 | |
173 #if xdiff | |
174 $ hg diff --git | |
175 diff --git a/a.c b/a.c | |
176 --- a/a.c | |
177 +++ b/a.c | |
178 @@ -4,12 +4,6 @@ | |
179 int f() { | |
180 return 1; | |
181 } | |
182 -/* | |
183 - * This function returns 2. | |
184 - */ | |
185 -int g() { | |
186 - return 2; | |
187 -} | |
188 /* | |
189 * This function returns 3. | |
190 */ | |
191 diff --git a/b.c b/b.c | |
192 --- a/b.c | |
193 +++ b/b.c | |
194 @@ -2,6 +2,10 @@ | |
195 do_something(); | |
196 } | |
197 | |
198 +if (y) { | |
199 + do_another_thing(); | |
200 +} | |
201 + | |
202 if (y) { | |
203 do_something_else(); | |
204 } | |
205 diff --git a/c.rb b/c.rb | |
206 --- a/c.rb | |
207 +++ b/c.rb | |
208 @@ -1,4 +1,7 @@ | |
209 #!ruby | |
210 +["foo", "bar", "baz"].map do |i| | |
211 + i | |
212 +end | |
213 ["foo", "bar", "baz"].map do |i| | |
214 i.upcase | |
215 end | |
216 diff --git a/d.py b/d.py | |
217 --- a/d.py | |
218 +++ b/d.py | |
219 @@ -2,6 +2,10 @@ | |
220 import foo | |
221 except ImportError: | |
222 pass | |
223 +try: | |
224 + import baz | |
225 +except ImportError: | |
226 + pass | |
227 try: | |
228 import bar | |
229 except ImportError: | |
230 diff --git a/functions.c b/functions.c | |
231 --- a/functions.c | |
232 +++ b/functions.c | |
233 @@ -1,5 +1,10 @@ | |
234 1 | |
235 2 | |
236 +/* function */ | |
237 +bar() { | |
238 + foo | |
239 +} | |
240 + | |
241 /* function */ | |
242 foo() { | |
243 foo | |
244 diff --git a/spaces.txt b/spaces.txt | |
245 --- a/spaces.txt | |
246 +++ b/spaces.txt | |
247 @@ -2,6 +2,9 @@ | |
248 2 | |
249 a | |
250 | |
251 +b | |
252 +a | |
253 + | |
254 b | |
255 3 | |
256 4 | |
257 #else | |
258 $ hg diff --git | |
259 diff --git a/a.c b/a.c | |
260 --- a/a.c | |
261 +++ b/a.c | |
262 @@ -5,12 +5,6 @@ | |
263 return 1; | |
264 } | |
265 /* | |
266 - * This function returns 2. | |
267 - */ | |
268 -int g() { | |
269 - return 2; | |
270 -} | |
271 -/* | |
272 * This function returns 3. | |
273 */ | |
274 int h() { | |
275 diff --git a/b.c b/b.c | |
276 --- a/b.c | |
277 +++ b/b.c | |
278 @@ -3,5 +3,9 @@ | |
279 } | |
280 | |
281 if (y) { | |
282 + do_another_thing(); | |
283 +} | |
284 + | |
285 +if (y) { | |
286 do_something_else(); | |
287 } | |
288 diff --git a/c.rb b/c.rb | |
289 --- a/c.rb | |
290 +++ b/c.rb | |
291 @@ -1,4 +1,7 @@ | |
292 #!ruby | |
293 ["foo", "bar", "baz"].map do |i| | |
294 + i | |
295 +end | |
296 +["foo", "bar", "baz"].map do |i| | |
297 i.upcase | |
298 end | |
299 diff --git a/d.py b/d.py | |
300 --- a/d.py | |
301 +++ b/d.py | |
302 @@ -3,6 +3,10 @@ | |
303 except ImportError: | |
304 pass | |
305 try: | |
306 + import baz | |
307 +except ImportError: | |
308 + pass | |
309 +try: | |
310 import bar | |
311 except ImportError: | |
312 pass | |
313 diff --git a/functions.c b/functions.c | |
314 --- a/functions.c | |
315 +++ b/functions.c | |
316 @@ -1,6 +1,11 @@ | |
317 1 | |
318 2 | |
319 /* function */ | |
320 +bar() { | |
321 + foo | |
322 +} | |
323 + | |
324 +/* function */ | |
325 foo() { | |
326 foo | |
327 } | |
328 diff --git a/spaces.txt b/spaces.txt | |
329 --- a/spaces.txt | |
330 +++ b/spaces.txt | |
331 @@ -3,5 +3,8 @@ | |
332 a | |
333 | |
334 b | |
335 +a | |
336 + | |
337 +b | |
338 3 | |
339 4 | |
340 #endif |