##// END OF EJS Templates
add missed tests for diff -b/-B
Vadim Gelfer -
r2594:bdf9d809 default
parent child Browse files
Show More
@@ -0,0 +1,84 b''
1 #!/bin/sh
2
3 # GNU diff is the reference for all of these results.
4
5 hgdiff() {
6 hg diff "$@" | sed "s/\(\(---\|+++\) [a-zA-Z0-9_/.-]*\).*/\1/"
7 }
8
9 test_added_blank_lines() {
10 printf '\nhello world\n\ngoodbye world\n\n' >foo
11
12 echo '>>> two diffs showing three added lines <<<'
13 hgdiff
14 hgdiff -b
15
16 echo '>>> no diffs <<<'
17 hgdiff -B
18 hgdiff -Bb
19 }
20
21 test_added_horizontal_space_first_on_a_line() {
22 printf '\t hello world\ngoodbye world\n' >foo
23
24 echo '>>> four diffs showing added space first on the first line <<<'
25 hgdiff
26 hgdiff -b
27 hgdiff -B
28 hgdiff -Bb
29 }
30
31 test_added_horizontal_space_last_on_a_line() {
32 printf 'hello world\t \ngoodbye world\n' >foo
33
34 echo '>>> two diffs showing space appended to the first line <<<'
35 hgdiff
36 hgdiff -B
37
38 echo '>>> no diffs <<<'
39 hgdiff -b
40 hgdiff -Bb
41 }
42
43 test_added_horizontal_space_in_the_middle_of_a_word() {
44 printf 'hello world\ngood bye world\n' >foo
45
46 echo '>>> four diffs showing space inserted into "goodbye" <<<'
47 hgdiff
48 hgdiff -B
49 hgdiff -b
50 hgdiff -Bb
51 }
52
53 test_increased_horizontal_whitespace_amount() {
54 printf 'hello world\ngoodbye\t\t \tworld\n' >foo
55
56 echo '>>> two diffs showing changed whitespace amount in the last line <<<'
57 hgdiff
58 hgdiff -B
59
60 echo '>>> no diffs <<<'
61 hgdiff -b
62 hgdiff -Bb
63 }
64
65 test_added_blank_line_with_horizontal_whitespace() {
66 printf 'hello world\n \t\ngoodbye world\n' >foo
67
68 echo '>>> four diffs showing added blank line w/horizontal space <<<'
69 hgdiff
70 hgdiff -B
71 hgdiff -b
72 hgdiff -Bb
73 }
74
75 hg init
76 printf 'hello world\ngoodbye world\n' >foo
77 hg ci -Amfoo -ufoo -d '0 0'
78
79 test_added_blank_lines
80 test_added_horizontal_space_first_on_a_line
81 test_added_horizontal_space_last_on_a_line
82 test_added_horizontal_space_in_the_middle_of_a_word
83 test_increased_horizontal_whitespace_amount
84 test_added_blank_line_with_horizontal_whitespace
@@ -0,0 +1,140 b''
1 adding foo
2 >>> two diffs showing three added lines <<<
3 diff -r 540c40a65b78 foo
4 --- a/foo
5 +++ b/foo
6 @@ -1,2 +1,5 @@ hello world
7 +
8 hello world
9 +
10 goodbye world
11 +
12 diff -r 540c40a65b78 foo
13 --- a/foo
14 +++ b/foo
15 @@ -1,2 +1,5 @@ hello world
16 +
17 hello world
18 +
19 goodbye world
20 +
21 >>> no diffs <<<
22 >>> four diffs showing added space first on the first line <<<
23 diff -r 540c40a65b78 foo
24 --- a/foo
25 +++ b/foo
26 @@ -1,2 +1,2 @@ hello world
27 -hello world
28 + hello world
29 goodbye world
30 diff -r 540c40a65b78 foo
31 --- a/foo
32 +++ b/foo
33 @@ -1,2 +1,2 @@ hello world
34 -hello world
35 + hello world
36 goodbye world
37 diff -r 540c40a65b78 foo
38 --- a/foo
39 +++ b/foo
40 @@ -1,2 +1,2 @@ hello world
41 -hello world
42 + hello world
43 goodbye world
44 diff -r 540c40a65b78 foo
45 --- a/foo
46 +++ b/foo
47 @@ -1,2 +1,2 @@ hello world
48 -hello world
49 + hello world
50 goodbye world
51 >>> two diffs showing space appended to the first line <<<
52 diff -r 540c40a65b78 foo
53 --- a/foo
54 +++ b/foo
55 @@ -1,2 +1,2 @@ hello world
56 -hello world
57 +hello world
58 goodbye world
59 diff -r 540c40a65b78 foo
60 --- a/foo
61 +++ b/foo
62 @@ -1,2 +1,2 @@ hello world
63 -hello world
64 +hello world
65 goodbye world
66 >>> no diffs <<<
67 >>> four diffs showing space inserted into "goodbye" <<<
68 diff -r 540c40a65b78 foo
69 --- a/foo
70 +++ b/foo
71 @@ -1,2 +1,2 @@ hello world
72 hello world
73 -goodbye world
74 +good bye world
75 diff -r 540c40a65b78 foo
76 --- a/foo
77 +++ b/foo
78 @@ -1,2 +1,2 @@ hello world
79 hello world
80 -goodbye world
81 +good bye world
82 diff -r 540c40a65b78 foo
83 --- a/foo
84 +++ b/foo
85 @@ -1,2 +1,2 @@ hello world
86 hello world
87 -goodbye world
88 +good bye world
89 diff -r 540c40a65b78 foo
90 --- a/foo
91 +++ b/foo
92 @@ -1,2 +1,2 @@ hello world
93 hello world
94 -goodbye world
95 +good bye world
96 >>> two diffs showing changed whitespace amount in the last line <<<
97 diff -r 540c40a65b78 foo
98 --- a/foo
99 +++ b/foo
100 @@ -1,2 +1,2 @@ hello world
101 hello world
102 -goodbye world
103 +goodbye world
104 diff -r 540c40a65b78 foo
105 --- a/foo
106 +++ b/foo
107 @@ -1,2 +1,2 @@ hello world
108 hello world
109 -goodbye world
110 +goodbye world
111 >>> no diffs <<<
112 >>> four diffs showing added blank line w/horizontal space <<<
113 diff -r 540c40a65b78 foo
114 --- a/foo
115 +++ b/foo
116 @@ -1,2 +1,3 @@ hello world
117 hello world
118 +
119 goodbye world
120 diff -r 540c40a65b78 foo
121 --- a/foo
122 +++ b/foo
123 @@ -1,2 +1,3 @@ hello world
124 hello world
125 +
126 goodbye world
127 diff -r 540c40a65b78 foo
128 --- a/foo
129 +++ b/foo
130 @@ -1,2 +1,3 @@ hello world
131 hello world
132 +
133 goodbye world
134 diff -r 540c40a65b78 foo
135 --- a/foo
136 +++ b/foo
137 @@ -1,2 +1,3 @@ hello world
138 hello world
139 +
140 goodbye world
General Comments 0
You need to be logged in to leave comments. Login now