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/freshrepo" || {
23 echo >&5 "FATAL: Cannot clean the fresh repo"
28 test_expect_success setup
'
29 ../scripts/setupRepo.py
31 test_must_fail stats.py
34 test_expect_success
'Test that the expected tree was created by setupRepo' '
35 test `git rev-parse HEAD` = "38aa44905fb99a661bfb0b675557f5aaf4934454"
45 echo "notes.txt = 3: +3 -0"
46 echo "content.txt = 23: +23 -1"
47 echo "docs/README.txt = 10: +8 -2"
51 'Test that "author -d" filters as expected for the primary author' \
53 stats.py author -d "author@example.com" > actual
54 test_cmp expected actual
58 echo "content.txt = 2: +2 -0"
62 'Test that "author -d" filters as expected for the secondary author' \
64 stats.py author -d "roh.tua@example.com" > actual
65 test_cmp expected actual
71 test_expect_failure
'Test that "author -a" aggregates as expected' '
72 `stats.py author -a` > actual
73 test_must_fail test_cmp expected actual
81 echo "Matching branches:"
85 test_expect_success
'Test that "branch -c" filters as expected' '
86 stats.py branch -c 6f01ab2afb8471d6eee83162ddeabe179e443d59 > actual
87 test_cmp expected actual
91 echo "Matching branches:"
97 'Test that "branch -c" filters as expected when multiple branches match' \
99 stats.py branch -c c0e49264fd921d2a62f90556340e371e719b45cc > actual
100 test_cmp expected actual
103 test_expect_failure
'There is no test for "branch -r"' '
113 echo "commit e76ad031836912c01da47ab93d3c21676763267e
114 Author: A U Thor <author@example.com>
115 Date: Thu May 26 23:30:00 2005 +0000
121 commit e8fa5fed0d1823c1e3e120579b03343aecf26ab6
122 Author: A U Thor <author@example.com>
123 Date: Thu May 26 23:30:00 2005 +0000
129 commit bd952062891010102e3632aecd0f738a35c1fca3
130 Author: A U Thor <author@example.com>
131 Date: Thu May 26 23:30:00 2005 +0000
138 test_expect_success
'Test that "commit -t" filters as expected' '
139 stats.py commit -t notes.txt > actual
140 test_cmp expected actual
143 test_expect_success
'commit tests setup' '
147 test_expect_success
'Test that "commit -r" works as expected' '
148 stats.py commit -r -t README.txt
151 test_expect_success \
152 'Test that "commit -r" works as expected when the file was not found' \
154 test_must_fail stats.py commit -t README.txt
157 test_expect_success
'commit tests teardown' '
161 echo "commit bc6d646fd15953cdb514d14458f013a1fc05153c
162 Author: A U Thor <author@example.com>
163 Date: Thu May 26 23:30:00 2005 +0000
170 test_expect_success
'Test that "commit --log" filters as expected' '
171 stats.py commit --log-contains=Initial > actual
172 test_cmp expected actual
175 test_expect_success
'Test that "commit --diff" filters as expected' '
176 stats.py commit --diff-contains=Initial > actual
177 test_cmp expected actual
186 echo "Missing the following keys:
187 ('/dev/null', 'b/notes.txt')" > expected
189 test_expect_success \
190 'Test that "diff -e" works as expected for equal diffs in different files' \
192 stats.py diff -e bd9520628910101 3c34aec51560970c > actual
193 test_cmp expected actual
196 echo "Missing the following keys:
197 ('/dev/null', 'b/test.c')" > expected
199 test_expect_success \
200 'Test that "diff -e" works as expected for equal diffs in different files' \
202 stats.py diff -e 3c34aec51560970c bd9520628910101 > actual
203 test_cmp expected actual
206 echo "Equal" > expected
208 test_expect_success
'Test that "diff -e" works as expected for equal diffs' '
209 stats.py diff -e HEAD HEAD > actual
210 test_cmp expected actual
213 test_expect_success
'Test that "diff -n -e" works as expected' '
214 stats.py diff -n -e 90511e146e24b29 38aa44905fb99a6 > actual
215 test_cmp expected actual
218 echo "Equal" > expected
220 test_expect_success
'Test that "diff -i" works as expected for reverts' '
221 stats.py diff -i -e cc2d11f96d7ec43 c2d26c33f9e8eb6 > actual
222 test_cmp expected actual
231 test_expect_success
'index test setup' '
232 echo "Some Change" >> notes.txt
236 echo "commit e76ad031836912c01da47ab93d3c21676763267e
237 Author: A U Thor <author@example.com>
238 Date: Thu May 26 23:30:00 2005 +0000
244 commit e8fa5fed0d1823c1e3e120579b03343aecf26ab6
245 Author: A U Thor <author@example.com>
246 Date: Thu May 26 23:30:00 2005 +0000
252 commit bd952062891010102e3632aecd0f738a35c1fca3
253 Author: A U Thor <author@example.com>
254 Date: Thu May 26 23:30:00 2005 +0000
261 test_expect_success \
262 'Test that "index -t" works as expected when there are staged changes' \
264 stats.py index -t > actual
265 test_cmp expected actual
268 test_expect_success
'index test teardown' '
269 git reset --hard HEAD
272 test_expect_failure
'There is no test for "index -a"' '
282 test_expect_success
'Teardown' '