3 # Copyright (c) 2008 Sverre Rabbelier
6 test_description
='stats tests (basics)
8 This test verifies that the basic stats commands work as expected.'
14 export GIT_STATS_PRETTY_PRINT
="oneline"
21 test_expect_success
'pre-clean' '
22 rm -fr "/tmp/testrepo" || {
24 echo >&5 "FATAL: Cannot clean the fresh repo"
29 test_expect_success
'setup' '
30 ../scripts/setupRepo.py test && \
31 cd "/tmp/testrepo" || {
33 echo >&5 "FATAL: Cannot cd into fresh repo"
38 test_expect_success
'Test that stats.py is reachable' '
41 echo >&5 "FATAL: stats.py not reachable"
46 echo "f1fdf284733011b1172b4517b4526879059bb414" > expected
48 test_expect_success
'Test that the expected tree was created by setupRepo' '
49 git rev-parse HEAD > actual
50 test_cmp expected actual || {
52 echo >&5 "FATAL: Head revision does not match"
64 echo "notes.txt = 3: +3 -0"
65 echo "content.txt = 23: +23 -1"
66 echo "docs/README.txt = 10: +8 -2"
70 'Test that "author -d" filters as expected for the primary author' \
72 stats.py author -d "author@example.com" > actual
73 test_cmp expected actual
77 echo "content.txt = 2: +2 -0"
81 'Test that "author -d" filters as expected for the secondary author' \
83 stats.py author -d "roh.tua@example.com" > actual
84 test_cmp expected actual
90 test_expect_failure
'Test that "author -a" aggregates as expected' '
91 `stats.py author -a` > actual
92 test_must_fail test_cmp expected actual
100 echo "Matching branches:"
104 test_expect_success
'Test that "branch -c" filters as expected' '
105 stats.py branch -c v0 > actual
106 test_cmp expected actual
110 echo "Matching branches:"
116 test_expect_success \
117 'Test that "branch -c" filters as expected when multiple branches match' \
119 stats.py branch -c v1 > actual
120 test_cmp expected actual
123 echo "junio" >> expected
125 test_expect_success
'Test that "branch -r" works as expected' '
126 stats.py branch -r -c v1 > actual
127 test_cmp expected actual
136 echo "3b0e7ae64f1b39f7b23d789a9d472443dd00c6fb Commit 3
137 9ae22dc6a76c6ac715cc9fe6a011156ca042f480 Commit 2
138 ae9fd667fe1611e0648a2ebec65788b63bb3ce16 Commit 1" > expected
140 test_expect_success
'Test that "commit -t" filters as expected' '
141 stats.py commit -t notes.txt > actual
142 test_cmp expected actual
145 test_expect_success
'commit tests setup' '
149 echo 'f1fdf284733011b1172b4517b4526879059bb414 Last commit
150 4de759680bf8bd7b51e3a0481d027ee441998542 Revert "Commit 6"
151 255ef82de488015b727e0202f0dfe8ed82443ebb Commit 6
152 4838591dcda04acd0e8882397c5c681af09c9076 Revert "Last commit"
153 4b650481338f95cd8afbc113bd15cd85d94c0c3a Last commit
154 37837a72217f8da3f056d5aa8b159412b93efd69 Commit 5
155 a03fc7e69239cc3e29c96ebf74e7d22e2d72bbef Commit 4
156 39f4923417895119ac26524c572dbd198570f054 Commit 3
157 3302051a5e010ede6cdb6d8fa66cff7e89f63b28 Commit 2
158 7bd493f55b8b0b0c59c08ca5be7c8f98fb159885 Commit 1' > expected
160 test_expect_success
'Test that "commit -r" works as expected' '
161 stats.py commit -r -t README.txt > actual
162 test_cmp expected actual
165 test_expect_success \
166 'Test that "commit -r" works as expected when the file was not found' \
168 test_must_fail stats.py commit -t README.txt
171 test_expect_success
'commit tests teardown' '
175 echo "9ebfa8e247b99c0ba0198244d574734899dac987 Initial commit" > expected
177 test_expect_success
'Test that "commit --log" filters as expected' '
178 stats.py commit --log-contains=Initial > actual
179 test_cmp expected actual
182 test_expect_success
'Test that "commit --diff" filters as expected' '
183 stats.py commit --diff-contains=Initial > actual
184 test_cmp expected actual
193 echo "Missing the following keys:
194 ('a/test.c', 'b/test.c')" > expected
196 test_expect_success \
197 'Test that "diff -e" works as expected for equal diffs in different files' \
199 stats.py diff -e v0 v4 > actual
200 test_cmp expected actual
203 echo "Missing the following keys:
204 ('a/docs/README.txt', 'b/docs/README.txt')" > expected
206 test_expect_success \
207 'Test that "diff -e" works as expected for equal diffs in different files' \
209 stats.py diff -e v4 v0 > actual
210 test_cmp expected actual
213 echo "Equal" > expected
215 test_expect_success
'Test that "diff -e" works as expected for equal diffs' '
216 stats.py diff -e HEAD HEAD > actual
217 test_cmp expected actual
220 test_expect_success
'Test that "diff -n -e" works as expected' '
221 stats.py diff -n -e v2 v3 > actual
222 test_cmp expected actual
225 echo "Equal" > expected
227 test_expect_success
'Test that "diff -i" works as expected for reverts' '
228 stats.py diff -i -e v2 v3^ > actual
229 test_cmp expected actual
238 test_expect_success
'index test setup' '
239 echo "Some Change" >> notes.txt
243 echo "3b0e7ae64f1b39f7b23d789a9d472443dd00c6fb Commit 3
244 9ae22dc6a76c6ac715cc9fe6a011156ca042f480 Commit 2
245 ae9fd667fe1611e0648a2ebec65788b63bb3ce16 Commit 1" > expected
247 test_expect_success \
248 'Test that "index -t" works as expected when there are staged changes' \
250 stats.py index -t > actual
251 test_cmp expected actual
254 test_expect_success
'index test teardown' '
255 git reset --hard HEAD
258 test_expect_success
'index -a test setup' '
264 echo "No changes staged, no matching commits, or only new files added"
267 test_expect_success
'Test that "index -t" without -a works as expected' '
268 stats.py index -t > actual
269 test_cmp expected actual
272 echo '28b2600cf58d478b4b937262218e363c88756b89 Deleted file docs/README.txt
273 f1fdf284733011b1172b4517b4526879059bb414 Last commit
274 4de759680bf8bd7b51e3a0481d027ee441998542 Revert "Commit 6"
275 255ef82de488015b727e0202f0dfe8ed82443ebb Commit 6
276 4838591dcda04acd0e8882397c5c681af09c9076 Revert "Last commit"
277 4b650481338f95cd8afbc113bd15cd85d94c0c3a Last commit
278 37837a72217f8da3f056d5aa8b159412b93efd69 Commit 5
279 a03fc7e69239cc3e29c96ebf74e7d22e2d72bbef Commit 4
280 39f4923417895119ac26524c572dbd198570f054 Commit 3
281 3302051a5e010ede6cdb6d8fa66cff7e89f63b28 Commit 2
282 7bd493f55b8b0b0c59c08ca5be7c8f98fb159885 Commit 1' > expected
284 test_expect_success
'Test that "index -a" works as expected' '
285 stats.py index -a -t > actual
286 test_cmp expected actual
289 test_expect_success
'index -a test teardown' '
300 test_expect_success
'Teardown' '