3 # Copyright (c) 2008 Sverre Rabbelier
6 test_description
='stats tests (basics)
8 This test verifies that the basic stats commands work as expected.'
20 test_expect_success
'pre-clean' '
21 rm -fr "/tmp/testrepo" || {
23 echo >&5 "FATAL: Cannot clean the fresh repo"
28 test_expect_success
'setup' '
29 ../scripts/setupRepo.py test && \
30 cd "/tmp/testrepo" || {
32 echo >&5 "FATAL: Cannot cd into fresh repo"
37 test_expect_success
'Test that stats.py is reachable' '
40 echo >&5 "FATAL: stats.py not reachable"
45 echo "f1fdf284733011b1172b4517b4526879059bb414" > expected
47 test_expect_success
'Test that the expected tree was created by setupRepo' '
48 git rev-parse HEAD > actual
49 test_cmp expected actual || {
51 echo >&5 "FATAL: Head revision does not match"
63 echo "notes.txt = 3: +3 -0"
64 echo "content.txt = 23: +23 -1"
65 echo "docs/README.txt = 10: +8 -2"
69 'Test that "author -d" filters as expected for the primary author' \
71 stats.py author -d "author@example.com" > actual
72 test_cmp expected actual
76 echo "content.txt = 2: +2 -0"
80 'Test that "author -d" filters as expected for the secondary author' \
82 stats.py author -d "roh.tua@example.com" > actual
83 test_cmp expected actual
89 test_expect_failure
'Test that "author -a" aggregates as expected' '
90 `stats.py author -a` > actual
91 test_must_fail test_cmp expected actual
99 echo "Matching branches:"
103 test_expect_success
'Test that "branch -c" filters as expected' '
104 stats.py branch -c 6f01ab2afb8471d6eee83162ddeabe179e443d59 > actual
105 test_cmp expected actual
109 echo "Matching branches:"
115 test_expect_success \
116 'Test that "branch -c" filters as expected when multiple branches match' \
118 stats.py branch -c c0e49264fd921d2a62f90556340e371e719b45cc > actual
119 test_cmp expected actual
122 echo "junio" >> expected
124 test_expect_success
'Test that "branch -r" works as expected' '
125 stats.py branch -r -c c0e49264fd921d2a62f90556340e371e719b45cc > actual
126 test_cmp expected actual
135 echo "commit e76ad031836912c01da47ab93d3c21676763267e
136 Author: A U Thor <author@example.com>
137 Date: Thu May 26 23:30:00 2005 +0000
143 commit e8fa5fed0d1823c1e3e120579b03343aecf26ab6
144 Author: A U Thor <author@example.com>
145 Date: Thu May 26 23:30:00 2005 +0000
151 commit bd952062891010102e3632aecd0f738a35c1fca3
152 Author: A U Thor <author@example.com>
153 Date: Thu May 26 23:30:00 2005 +0000
160 test_expect_success
'Test that "commit -t" filters as expected' '
161 stats.py commit -t notes.txt > actual
162 test_cmp expected actual
165 test_expect_success
'commit tests setup' '
169 test_expect_success
'Test that "commit -r" works as expected' '
170 stats.py commit -r -t README.txt
173 test_expect_success \
174 'Test that "commit -r" works as expected when the file was not found' \
176 test_must_fail stats.py commit -t README.txt
179 test_expect_success
'commit tests teardown' '
183 echo "commit bc6d646fd15953cdb514d14458f013a1fc05153c
184 Author: A U Thor <author@example.com>
185 Date: Thu May 26 23:30:00 2005 +0000
192 test_expect_success
'Test that "commit --log" filters as expected' '
193 stats.py commit --log-contains=Initial > actual
194 test_cmp expected actual
197 test_expect_success
'Test that "commit --diff" filters as expected' '
198 stats.py commit --diff-contains=Initial > actual
199 test_cmp expected actual
208 echo "Missing the following keys:
209 ('/dev/null', 'b/notes.txt')" > expected
211 test_expect_success \
212 'Test that "diff -e" works as expected for equal diffs in different files' \
214 stats.py diff -e bd9520628910101 3c34aec51560970c > actual
215 test_cmp expected actual
218 echo "Missing the following keys:
219 ('/dev/null', 'b/test.c')" > expected
221 test_expect_success \
222 'Test that "diff -e" works as expected for equal diffs in different files' \
224 stats.py diff -e 3c34aec51560970c bd9520628910101 > actual
225 test_cmp expected actual
228 echo "Equal" > expected
230 test_expect_success
'Test that "diff -e" works as expected for equal diffs' '
231 stats.py diff -e HEAD HEAD > actual
232 test_cmp expected actual
235 test_expect_success
'Test that "diff -n -e" works as expected' '
236 stats.py diff -n -e 90511e146e24b29 38aa44905fb99a6 > actual
237 test_cmp expected actual
240 echo "Equal" > expected
242 test_expect_success
'Test that "diff -i" works as expected for reverts' '
243 stats.py diff -i -e cc2d11f96d7ec43 c2d26c33f9e8eb6 > actual
244 test_cmp expected actual
253 test_expect_success
'index test setup' '
254 echo "Some Change" >> notes.txt
258 echo "commit e76ad031836912c01da47ab93d3c21676763267e
259 Author: A U Thor <author@example.com>
260 Date: Thu May 26 23:30:00 2005 +0000
266 commit e8fa5fed0d1823c1e3e120579b03343aecf26ab6
267 Author: A U Thor <author@example.com>
268 Date: Thu May 26 23:30:00 2005 +0000
274 commit bd952062891010102e3632aecd0f738a35c1fca3
275 Author: A U Thor <author@example.com>
276 Date: Thu May 26 23:30:00 2005 +0000
283 test_expect_success \
284 'Test that "index -t" works as expected when there are staged changes' \
286 stats.py index -t > actual
287 test_cmp expected actual
290 test_expect_success
'index test teardown' '
291 git reset --hard HEAD
294 test_expect_success
'index -a test setup' '
300 echo "No changes staged, no matching commits, or only new files added"
303 test_expect_success
'Test that "index -t" without -a works as expected' '
304 stats.py index -t > actual
305 test_cmp expected actual
308 test_expect_success
'Test that "index -a" works as expected' '
312 test_expect_success
'index -a test teardown' '
323 test_expect_success
'Teardown' '