t4052: test --stat output with --graph

Add tests which show that the width of the --prefix added by --graph is not taken into consideration when the diff stat output width is calculated. Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> Signed-off-by: Lucian Poston <lucian.poston@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Zbigniew Jędrzejewski-Szmek committed Apr 16, 2012 at 03:44 UTC 8c188c74e3f04ab75a42d43375a011f286cb1b66
1 file changed +74 -4
t/t4052-stat-output.sh
+74 -4
@@ -82,11 +82,15 @@ test_expect_success 'preparation for big change tests' '
82 cat >expect80 <<'EOF'
83 abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
84 EOF
85 -
85 +cat >expect80-graph <<'EOF'
86 +| abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
87 +EOF
88 cat >expect200 <<'EOF'
89 abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
90 EOF
89 -
91 +cat >expect200-graph <<'EOF'
92 +| abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
93 +EOF
94 while read verb expect cmd args
95 do
96 test_expect_success "$cmd $verb COLUMNS (big change)" '
@@ -94,6 +98,14 @@ do
98 grep " | " output >actual &&
99 test_cmp "$expect" actual
100 '
101 +
102 + test "$cmd" != diff || continue
103 +
104 + test_expect_success "$cmd --graph $verb COLUMNS (big change)" '
105 + COLUMNS=200 git $cmd $args --graph >output
106 + grep " | " output >actual &&
107 + test_cmp "$expect-graph" actual
108 + '
109 done <<\EOF
110 ignores expect80 format-patch -1 --stdout
111 respects expect200 diff HEAD^ HEAD --stat
@@ -104,7 +116,9 @@ EOF
116 cat >expect40 <<'EOF'
117 abcd | 1000 ++++++++++++++++++++++++++
118 EOF
107 -
119 +cat >expect40-graph <<'EOF'
120 +| abcd | 1000 ++++++++++++++++++++++++++
121 +EOF
122 while read verb expect cmd args
123 do
124 test_expect_success "$cmd $verb not enough COLUMNS (big change)" '
@@ -118,6 +132,20 @@ do
132 grep " | " output >actual &&
133 test_cmp "$expect" actual
134 '
135 +
136 + test "$cmd" != diff || continue
137 +
138 + test_expect_success "$cmd --graph $verb not enough COLUMNS (big change)" '
139 + COLUMNS=40 git $cmd $args --graph >output
140 + grep " | " output >actual &&
141 + test_cmp "$expect-graph" actual
142 + '
143 +
144 + test_expect_success "$cmd --graph $verb statGraphWidth config" '
145 + git -c diff.statGraphWidth=26 $cmd $args --graph >output
146 + grep " | " output >actual &&
147 + test_cmp "$expect-graph" actual
148 + '
149 done <<\EOF
150 ignores expect80 format-patch -1 --stdout
151 respects expect40 diff HEAD^ HEAD --stat
@@ -129,6 +157,9 @@ EOF
157 cat >expect <<'EOF'
158 abcd | 1000 ++++++++++++++++++++++++++
159 EOF
160 +cat >expect-graph <<'EOF'
161 +| abcd | 1000 ++++++++++++++++++++++++++
162 +EOF
163 while read cmd args
164 do
165 test_expect_success "$cmd --stat=width with big change" '
@@ -143,11 +174,25 @@ do
174 test_cmp expect actual
175 '
176
146 - test_expect_success "$cmd --stat-graph--width with big change" '
177 + test_expect_success "$cmd --stat-graph-width with big change" '
178 git $cmd $args --stat-graph-width=26 >output
179 grep " | " output >actual &&
180 test_cmp expect actual
181 '
182 +
183 + test "$cmd" != diff || continue
184 +
185 + test_expect_success "$cmd --stat-width=width --graph with big change" '
186 + git $cmd $args --stat-width=40 --graph >output
187 + grep " | " output >actual &&
188 + test_cmp expect-graph actual
189 + '
190 +
191 + test_expect_success "$cmd --stat-graph-width --graph with big change" '
192 + git $cmd $args --stat-graph-width=26 --graph >output
193 + grep " | " output >actual &&
194 + test_cmp expect-graph actual
195 + '
196 done <<\EOF
197 format-patch -1 --stdout
198 diff HEAD^ HEAD --stat
@@ -164,6 +209,9 @@ test_expect_success 'preparation for long filename tests' '
209 cat >expect <<'EOF'
210 ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++
211 EOF
212 +cat >expect-graph <<'EOF'
213 +| ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++
214 +EOF
215 while read cmd args
216 do
217 test_expect_success "$cmd --stat=width with big change is more balanced" '
@@ -171,6 +219,14 @@ do
219 grep " | " output >actual &&
220 test_cmp expect actual
221 '
222 +
223 + test "$cmd" != diff || continue
224 +
225 + test_expect_success "$cmd --stat=width --graph with big change is balanced" '
226 + git $cmd $args --stat-width=60 --graph >output &&
227 + grep " | " output >actual &&
228 + test_cmp expect-graph actual
229 + '
230 done <<\EOF
231 format-patch -1 --stdout
232 diff HEAD^ HEAD --stat
@@ -181,9 +237,15 @@ EOF
237 cat >expect80 <<'EOF'
238 ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++++++++++
239 EOF
240 +cat >expect80-graph <<'EOF'
241 +| ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++++++++++
242 +EOF
243 cat >expect200 <<'EOF'
244 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
245 EOF
246 +cat >expect200-graph <<'EOF'
247 +| aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
248 +EOF
249 while read verb expect cmd args
250 do
251 test_expect_success "$cmd $verb COLUMNS (long filename)" '
@@ -191,6 +253,14 @@ do
253 grep " | " output >actual &&
254 test_cmp "$expect" actual
255 '
256 +
257 + test "$cmd" != diff || continue
258 +
259 + test_expect_success "$cmd --graph $verb COLUMNS (long filename)" '
260 + COLUMNS=200 git $cmd $args --graph >output
261 + grep " | " output >actual &&
262 + test_cmp "$expect-graph" actual
263 + '
264 done <<\EOF
265 ignores expect80 format-patch -1 --stdout
266 respects expect200 diff HEAD^ HEAD --stat