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
32 test_must_fail stats.py
35 test_expect_success
'Test that the expected tree was created by setupRepo' '
36 test `git rev-parse HEAD` = "72224f7dd1549afc56a33851afa32d70144ced4b"
46 echo "notes.txt = 3: +3 -0"
47 echo "content.txt = 23: +23 -1"
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_failure
'There is no test for "commit -r"' '
147 echo "commit bc6d646fd15953cdb514d14458f013a1fc05153c
148 Author: A U Thor <author@example.com>
149 Date: Thu May 26 23:30:00 2005 +0000
156 test_expect_success
'Test that "commit --log" filters as expected' '
157 stats.py commit --log-contains=Initial > actual
158 test_cmp expected actual
161 test_expect_success
'Test that "commit --diff" filters as expected' '
162 stats.py commit --diff-contains=Initial > actual
163 test_cmp expected actual
172 echo "Missing the following keys:
173 ('/dev/null', 'b/notes.txt')" > expected
175 test_expect_success \
176 'Test that "diff -e" works as expected for equal diffs in different files' \
178 stats.py diff -e bd9520628910101 3c34aec51560970c > actual
179 test_cmp expected actual
182 echo "Missing the following keys:
183 ('/dev/null', 'b/test.c')" > expected
185 test_expect_success \
186 'Test that "diff -e" works as expected for equal diffs in different files' \
188 stats.py diff -e 3c34aec51560970c bd9520628910101 > actual
189 test_cmp expected actual
192 echo "Equal" > expected
194 test_expect_success
'Test that "diff -e" works as expected for equal diffs' '
195 stats.py diff -e HEAD HEAD > actual
196 test_cmp expected actual
199 test_expect_failure
'There is no test for "diff -n"' '
203 echo "Equal" > expected
205 test_expect_success
'Test that "diff -i" works as expected for reverts' '
206 stats.py diff -i -e cc2d11f96d7ec43 c2d26c33f9e8eb6 > actual
207 test_cmp expected actual
216 test_expect_success
'index test setup' '
217 echo "Some Change" >> notes.txt
221 echo "commit e76ad031836912c01da47ab93d3c21676763267e
222 Author: A U Thor <author@example.com>
223 Date: Thu May 26 23:30:00 2005 +0000
229 commit e8fa5fed0d1823c1e3e120579b03343aecf26ab6
230 Author: A U Thor <author@example.com>
231 Date: Thu May 26 23:30:00 2005 +0000
237 commit bd952062891010102e3632aecd0f738a35c1fca3
238 Author: A U Thor <author@example.com>
239 Date: Thu May 26 23:30:00 2005 +0000
246 test_expect_success \
247 'Test that "index -t" works as expected when there are staged changes' \
249 stats.py index -t > actual
250 test_cmp expected actual
253 test_expect_success
'index test teardown' '
254 git reset --hard HEAD
257 test_expect_failure
'There is no test for "index -a"' '
267 test_expect_success
'Teardown' '