##// END OF EJS Templates
tests: unify test-diff-ignore-whitespace
Adrian Buehlmann -
r12138:aff0b394 default
parent child Browse files
Show More
@@ -1,121 +1,392 b''
1 #!/bin/sh
1 GNU diff is the reference for all of these results.
2
3 Prepare tests:
4
5 $ echo '[alias]' >> $HGRCPATH
6 $ echo 'ndiff = diff --nodates' >> $HGRCPATH
2 7
3 # GNU diff is the reference for all of these results.
8 $ hg init
9 $ printf 'hello world\ngoodbye world\n' >foo
10 $ hg ci -Amfoo -ufoo
11 adding foo
12
13
14 Test added blank lines:
15
16 $ printf '\nhello world\n\ngoodbye world\n\n' >foo
17
18 >>> two diffs showing three added lines <<<
4 19
5 hgdiff() {
6 echo hg diff $@
7 hg diff --nodates "$@"
8 }
20 $ hg ndiff
21 diff -r 540c40a65b78 foo
22 --- a/foo
23 +++ b/foo
24 @@ -1,2 +1,5 @@
25 +
26 hello world
27 +
28 goodbye world
29 +
30 $ hg ndiff -b
31 diff -r 540c40a65b78 foo
32 --- a/foo
33 +++ b/foo
34 @@ -1,2 +1,5 @@
35 +
36 hello world
37 +
38 goodbye world
39 +
9 40
10 test_added_blank_lines() {
11 printf '\nhello world\n\ngoodbye world\n\n' >foo
41 >>> no diffs <<<
42
43 $ hg ndiff -B
44 $ hg ndiff -Bb
45
12 46
13 echo '>>> two diffs showing three added lines <<<'
14 hgdiff
15 hgdiff -b
47 Test added horizontal space first on a line():
48
49 $ printf '\t hello world\ngoodbye world\n' >foo
50
51 >>> four diffs showing added space first on the first line <<<
52
53 $ hg ndiff
54 diff -r 540c40a65b78 foo
55 --- a/foo
56 +++ b/foo
57 @@ -1,2 +1,2 @@
58 -hello world
59 + hello world
60 goodbye world
61
62 $ hg ndiff -b
63 diff -r 540c40a65b78 foo
64 --- a/foo
65 +++ b/foo
66 @@ -1,2 +1,2 @@
67 -hello world
68 + hello world
69 goodbye world
16 70
17 echo '>>> no diffs <<<'
18 hgdiff -B
19 hgdiff -Bb
20 }
71 $ hg ndiff -B
72 diff -r 540c40a65b78 foo
73 --- a/foo
74 +++ b/foo
75 @@ -1,2 +1,2 @@
76 -hello world
77 + hello world
78 goodbye world
21 79
22 test_added_horizontal_space_first_on_a_line() {
23 printf '\t hello world\ngoodbye world\n' >foo
80 $ hg ndiff -Bb
81 diff -r 540c40a65b78 foo
82 --- a/foo
83 +++ b/foo
84 @@ -1,2 +1,2 @@
85 -hello world
86 + hello world
87 goodbye world
88
89
90 Test added horizontal space last on a line:
91
92 $ printf 'hello world\t \ngoodbye world\n' >foo
93
94 >>> two diffs showing space appended to the first line <<<
24 95
25 echo '>>> four diffs showing added space first on the first line <<<'
26 hgdiff
27 hgdiff -b
28 hgdiff -B
29 hgdiff -Bb
30 }
96 $ hg ndiff
97 diff -r 540c40a65b78 foo
98 --- a/foo
99 +++ b/foo
100 @@ -1,2 +1,2 @@
101 -hello world
102 +hello world
103 goodbye world
104
105 $ hg ndiff -B
106 diff -r 540c40a65b78 foo
107 --- a/foo
108 +++ b/foo
109 @@ -1,2 +1,2 @@
110 -hello world
111 +hello world
112 goodbye world
113
114 >>> no diffs <<<
115
116 $ hg ndiff -b
117 $ hg ndiff -Bb
118
31 119
32 test_added_horizontal_space_last_on_a_line() {
33 printf 'hello world\t \ngoodbye world\n' >foo
120 Test added horizontal space in the middle of a word:
121
122 $ printf 'hello world\ngood bye world\n' >foo
123
124 >>> four diffs showing space inserted into "goodbye" <<<
34 125
35 echo '>>> two diffs showing space appended to the first line <<<'
36 hgdiff
37 hgdiff -B
126 $ hg ndiff
127 diff -r 540c40a65b78 foo
128 --- a/foo
129 +++ b/foo
130 @@ -1,2 +1,2 @@
131 hello world
132 -goodbye world
133 +good bye world
134
135 $ hg ndiff -B
136 diff -r 540c40a65b78 foo
137 --- a/foo
138 +++ b/foo
139 @@ -1,2 +1,2 @@
140 hello world
141 -goodbye world
142 +good bye world
38 143
39 echo '>>> no diffs <<<'
40 hgdiff -b
41 hgdiff -Bb
42 }
144 $ hg ndiff -b
145 diff -r 540c40a65b78 foo
146 --- a/foo
147 +++ b/foo
148 @@ -1,2 +1,2 @@
149 hello world
150 -goodbye world
151 +good bye world
43 152
44 test_added_horizontal_space_in_the_middle_of_a_word() {
45 printf 'hello world\ngood bye world\n' >foo
153 $ hg ndiff -Bb
154 diff -r 540c40a65b78 foo
155 --- a/foo
156 +++ b/foo
157 @@ -1,2 +1,2 @@
158 hello world
159 -goodbye world
160 +good bye world
161
162
163 Test increased horizontal whitespace amount:
164
165 $ printf 'hello world\ngoodbye\t\t \tworld\n' >foo
166
167 >>> two diffs showing changed whitespace amount in the last line <<<
46 168
47 echo '>>> four diffs showing space inserted into "goodbye" <<<'
48 hgdiff
49 hgdiff -B
50 hgdiff -b
51 hgdiff -Bb
52 }
169 $ hg ndiff
170 diff -r 540c40a65b78 foo
171 --- a/foo
172 +++ b/foo
173 @@ -1,2 +1,2 @@
174 hello world
175 -goodbye world
176 +goodbye world
53 177
54 test_increased_horizontal_whitespace_amount() {
55 printf 'hello world\ngoodbye\t\t \tworld\n' >foo
178 $ hg ndiff -B
179 diff -r 540c40a65b78 foo
180 --- a/foo
181 +++ b/foo
182 @@ -1,2 +1,2 @@
183 hello world
184 -goodbye world
185 +goodbye world
56 186
57 echo '>>> two diffs showing changed whitespace amount in the last line <<<'
58 hgdiff
59 hgdiff -B
187 >>> no diffs <<<
188
189 $ hg ndiff -b
190 $ hg ndiff -Bb
191
192
193 Test added blank line with horizontal whitespace:
194
195 $ printf 'hello world\n \t\ngoodbye world\n' >foo
60 196
61 echo '>>> no diffs <<<'
62 hgdiff -b
63 hgdiff -Bb
64 }
197 >>> three diffs showing added blank line with horizontal space <<<
198
199 $ hg ndiff
200 diff -r 540c40a65b78 foo
201 --- a/foo
202 +++ b/foo
203 @@ -1,2 +1,3 @@
204 hello world
205 +
206 goodbye world
207
208 $ hg ndiff -B
209 diff -r 540c40a65b78 foo
210 --- a/foo
211 +++ b/foo
212 @@ -1,2 +1,3 @@
213 hello world
214 +
215 goodbye world
65 216
66 test_added_blank_line_with_horizontal_whitespace() {
67 printf 'hello world\n \t\ngoodbye world\n' >foo
217 $ hg ndiff -b
218 diff -r 540c40a65b78 foo
219 --- a/foo
220 +++ b/foo
221 @@ -1,2 +1,3 @@
222 hello world
223 +
224 goodbye world
225
226 >>> no diffs <<<
227
228 $ hg ndiff -Bb
229
230
231 Test added blank line with other whitespace:
232
233 $ printf 'hello world\n \t\ngoodbye world \n' >foo
234
235 >>> three diffs showing added blank line with other space <<<
68 236
69 echo '>>> four diffs showing added blank line w/horizontal space <<<'
70 hgdiff
71 hgdiff -B
72 hgdiff -b
73 hgdiff -Bb
74 }
237 $ hg ndiff
238 diff -r 540c40a65b78 foo
239 --- a/foo
240 +++ b/foo
241 @@ -1,2 +1,3 @@
242 -hello world
243 -goodbye world
244 +hello world
245 +
246 +goodbye world
75 247
76 test_added_blank_line_with_other_whitespace() {
77 printf 'hello world\n \t\ngoodbye world \n' >foo
248 $ hg ndiff -B
249 diff -r 540c40a65b78 foo
250 --- a/foo
251 +++ b/foo
252 @@ -1,2 +1,3 @@
253 -hello world
254 -goodbye world
255 +hello world
256 +
257 +goodbye world
78 258
79 echo '>>> three diffs showing added blank line w/other space <<<'
80 hgdiff
81 hgdiff -B
82 hgdiff -b
83 hgdiff -Bb
84 }
259 $ hg ndiff -b
260 diff -r 540c40a65b78 foo
261 --- a/foo
262 +++ b/foo
263 @@ -1,2 +1,3 @@
264 hello world
265 +
266 goodbye world
267
268 >>> no diffs <<<
269
270 $ hg ndiff -Bb
271
85 272
86 test_whitespace_changes() {
87 printf 'helloworld\ngoodbye\tworld \n' >foo
273 Test whitespace changes:
274
275 $ printf 'helloworld\ngoodbye\tworld \n' >foo
276
277 >>> four diffs showing changed whitespace <<<
278
279 $ hg ndiff
280 diff -r 540c40a65b78 foo
281 --- a/foo
282 +++ b/foo
283 @@ -1,2 +1,2 @@
284 -hello world
285 -goodbye world
286 +helloworld
287 +goodbye world
88 288
89 echo '>>> four diffs showing changed whitespace <<<'
90 hgdiff
91 hgdiff -B
92 hgdiff -b
93 hgdiff -Bb
94 hgdiff -w
95 }
289 $ hg ndiff -B
290 diff -r 540c40a65b78 foo
291 --- a/foo
292 +++ b/foo
293 @@ -1,2 +1,2 @@
294 -hello world
295 -goodbye world
296 +helloworld
297 +goodbye world
298
299 $ hg ndiff -b
300 diff -r 540c40a65b78 foo
301 --- a/foo
302 +++ b/foo
303 @@ -1,2 +1,2 @@
304 -hello world
305 +helloworld
306 goodbye world
96 307
97 test_whitespace_changes_and_blank_lines() {
98 printf 'helloworld\n\n\n\ngoodbye\tworld \n' >foo
308 $ hg ndiff -Bb
309 diff -r 540c40a65b78 foo
310 --- a/foo
311 +++ b/foo
312 @@ -1,2 +1,2 @@
313 -hello world
314 +helloworld
315 goodbye world
316
317 >>> no diffs <<<
318
319 $ hg ndiff -w
320
321
322 Test whitespace changes and blank lines:
323
324 $ printf 'helloworld\n\n\n\ngoodbye\tworld \n' >foo
325
326 >>> five diffs showing changed whitespace <<<
327
328 $ hg ndiff
329 diff -r 540c40a65b78 foo
330 --- a/foo
331 +++ b/foo
332 @@ -1,2 +1,5 @@
333 -hello world
334 -goodbye world
335 +helloworld
336 +
337 +
338 +
339 +goodbye world
99 340
100 echo '>>> five diffs showing changed whitespace <<<'
101 hgdiff
102 hgdiff -B
103 hgdiff -b
104 hgdiff -Bb
105 hgdiff -w
106 hgdiff -wB
107 }
341 $ hg ndiff -B
342 diff -r 540c40a65b78 foo
343 --- a/foo
344 +++ b/foo
345 @@ -1,2 +1,5 @@
346 -hello world
347 -goodbye world
348 +helloworld
349 +
350 +
351 +
352 +goodbye world
353
354 $ hg ndiff -b
355 diff -r 540c40a65b78 foo
356 --- a/foo
357 +++ b/foo
358 @@ -1,2 +1,5 @@
359 -hello world
360 +helloworld
361 +
362 +
363 +
364 goodbye world
108 365
109 hg init
110 printf 'hello world\ngoodbye world\n' >foo
111 hg ci -Amfoo -ufoo
366 $ hg ndiff -Bb
367 diff -r 540c40a65b78 foo
368 --- a/foo
369 +++ b/foo
370 @@ -1,2 +1,5 @@
371 -hello world
372 +helloworld
373 +
374 +
375 +
376 goodbye world
112 377
113 test_added_blank_lines
114 test_added_horizontal_space_first_on_a_line
115 test_added_horizontal_space_last_on_a_line
116 test_added_horizontal_space_in_the_middle_of_a_word
117 test_increased_horizontal_whitespace_amount
118 test_added_blank_line_with_horizontal_whitespace
119 test_added_blank_line_with_other_whitespace
120 test_whitespace_changes
121 test_whitespace_changes_and_blank_lines
378 $ hg ndiff -w
379 diff -r 540c40a65b78 foo
380 --- a/foo
381 +++ b/foo
382 @@ -1,2 +1,5 @@
383 hello world
384 +
385 +
386 +
387 goodbye world
388
389 >>> no diffs <<<
390
391 $ hg ndiff -wB
392
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now