3 # Copyright (c) 2012 Zbigniew Jędrzejewski-Szmek
6 test_description
='test --stat output of various commands'
9 .
"$TEST_DIRECTORY"/lib-terminal.sh
13 name
=$name$name$name$name$name$name$name$name$name$name$name$name
14 test_expect_success
'preparation' '
17 git commit -m message &&
19 git commit -m message "$name"
25 ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
27 test_expect_success
"$cmd: small change with long name gives more space to the name" '
28 git $cmd $args >output &&
29 grep " | " output >actual &&
30 test_cmp expect actual
34 ...aaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
36 test_expect_success
"$cmd --stat=width: a long name is given more room when the bar is short" '
37 git $cmd $args --stat=40 >output &&
38 grep " | " output >actual &&
39 test_cmp expect actual
42 test_expect_success
"$cmd --stat-width=width with long name" '
43 git $cmd $args --stat-width=40 >output &&
44 grep " | " output >actual &&
45 test_cmp expect actual
49 ...aaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 +
51 test_expect_success
"$cmd --stat=...,name-width with long name" '
52 git $cmd $args --stat=60,30 >output &&
53 grep " | " output >actual &&
54 test_cmp expect actual
57 test_expect_success
"$cmd --stat-name-width with long name" '
58 git $cmd $args --stat-name-width=30 >output &&
59 grep " | " output >actual &&
60 test_cmp expect actual
63 format-patch
-1 --stdout
64 diff HEAD^ HEAD
--stat
70 test_expect_success
'preparation for big change tests' '
73 git commit -m message &&
75 while test $i -lt 1000
77 echo $i && i=$(($i + 1))
79 git commit -m message abcd
83 abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
86 cat >expect200
<<'EOF'
87 abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
90 while read verb expect cmd args
92 test_expect_success
"$cmd $verb COLUMNS (big change)" '
93 COLUMNS=200 git $cmd $args >output
94 grep " | " output >actual &&
95 test_cmp "$expect" actual
98 ignores expect80 format-patch
-1 --stdout
99 respects expect200
diff HEAD^ HEAD
--stat
100 respects expect200 show
--stat
101 respects expect200 log
-1 --stat
104 cat >expect40
<<'EOF'
105 abcd | 1000 ++++++++++++++++++++++++++
108 while read verb expect cmd args
110 test_expect_success
"$cmd $verb not enough COLUMNS (big change)" '
111 COLUMNS=40 git $cmd $args >output
112 grep " | " output >actual &&
113 test_cmp "$expect" actual
116 ignores expect80 format-patch
-1 --stdout
117 respects expect40
diff HEAD^ HEAD
--stat
118 respects expect40 show
--stat
119 respects expect40 log
-1 --stat
124 abcd | 1000 ++++++++++++++++++++++++++
128 test_expect_success
"$cmd --stat=width with big change" '
129 git $cmd $args --stat=40 >output
130 grep " | " output >actual &&
131 test_cmp expect actual
134 test_expect_success
"$cmd --stat-width=width with big change" '
135 git $cmd $args --stat-width=40 >output
136 grep " | " output >actual &&
137 test_cmp expect actual
140 format-patch
-1 --stdout
141 diff HEAD^ HEAD
--stat
146 test_expect_success
'preparation for long filename tests' '
147 cp abcd aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
148 git add aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
149 git commit -m message
153 ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++
157 test_expect_success
"$cmd --stat=width with big change is more balanced" '
158 git $cmd $args --stat-width=60 >output &&
159 grep " | " output >actual &&
160 test_cmp expect actual
163 format-patch
-1 --stdout
164 diff HEAD^ HEAD
--stat
169 cat >expect80
<<'EOF'
170 ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 ++++++++++++++++++++
172 cat >expect200
<<'EOF'
173 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
175 while read verb expect cmd args
177 test_expect_success
"$cmd $verb COLUMNS (long filename)" '
178 COLUMNS=200 git $cmd $args >output
179 grep " | " output >actual &&
180 test_cmp "$expect" actual
183 ignores expect80 format-patch
-1 --stdout
184 respects expect200
diff HEAD^ HEAD
--stat
185 respects expect200 show
--stat
186 respects expect200 log
-1 --stat
190 abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
192 test_expect_success
'merge --stat respects COLUMNS (big change)' '
193 git checkout -b branch HEAD^^ &&
194 COLUMNS=100 git merge --stat --no-ff master^ >output &&
195 grep " | " output >actual
196 test_cmp expect actual
200 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1000 +++++++++++++++++++++++++++++++++++++++
202 test_expect_success
'merge --stat respects COLUMNS (long filename)' '
203 COLUMNS=100 git merge --stat --no-ff master >output &&
204 grep " | " output >actual
205 test_cmp expect actual