Improved the test descriptions
[git-stats.git] / src / t / t8100-stats.sh
blobe7b4f7d52a8d871e7c99e034559ad065a1979453
1 #!/bin/sh
3 # Copyright (c) 2008 Sverre Rabbelier
6 test_description='stats tests (basics)
8 This test verifies that the basic stats commands work as expected.'
10 ORIG_PATH=$PWD
12 . ./test-lib.sh
15 ###########
16 # Setup
17 ###########
20 test_expect_success pre-clean '
21 rm -fr "/tmp/freshrepo" || {
22 trap - exit
23 echo >&5 "FATAL: Cannot clean the fresh repo"
24 exit 1
28 test_expect_success setup '
29 ../../scripts/setupRepo.py
30 cd /tmp/freshrepo
31 PATH=../:$PATH
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"
40 ###########
41 # Author tests
42 ###########
46 echo "notes.txt = 3: +3 -0"
47 echo "content.txt = 23: +23 -1"
48 } > expected
50 test_expect_success \
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"
59 } > expected
61 test_expect_success \
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
68 rm expected
69 touch expected
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
76 ###########
77 # Branch tests
78 ###########
81 echo "Matching branches:"
82 echo "pu"
83 } > expected
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:"
92 echo "maint"
93 echo "master"
94 } > expected
96 test_expect_success \
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"' '
104 `false`
108 ###########
109 # Commit tests
110 ###########
113 echo "commit e76ad031836912c01da47ab93d3c21676763267e
114 Author: A U Thor <author@example.com>
115 Date: Thu May 26 23:30:00 2005 +0000
117 Commit 3
119 notes.txt
121 commit e8fa5fed0d1823c1e3e120579b03343aecf26ab6
122 Author: A U Thor <author@example.com>
123 Date: Thu May 26 23:30:00 2005 +0000
125 Commit 2
127 notes.txt
129 commit bd952062891010102e3632aecd0f738a35c1fca3
130 Author: A U Thor <author@example.com>
131 Date: Thu May 26 23:30:00 2005 +0000
133 Commit 1
135 notes.txt
136 " > expected
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"' '
144 `false`
147 echo "commit bc6d646fd15953cdb514d14458f013a1fc05153c
148 Author: A U Thor <author@example.com>
149 Date: Thu May 26 23:30:00 2005 +0000
151 Initial commit
153 content.txt
154 " > expected
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
167 ###########
168 # Diff tests
169 ###########
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"' '
200 `false`
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
211 ###########
212 # Index tests
213 ###########
216 test_expect_success 'index test setup' '
217 echo "Some Change" >> notes.txt
218 git add notes.txt
221 echo "commit e76ad031836912c01da47ab93d3c21676763267e
222 Author: A U Thor <author@example.com>
223 Date: Thu May 26 23:30:00 2005 +0000
225 Commit 3
227 notes.txt
229 commit e8fa5fed0d1823c1e3e120579b03343aecf26ab6
230 Author: A U Thor <author@example.com>
231 Date: Thu May 26 23:30:00 2005 +0000
233 Commit 2
235 notes.txt
237 commit bd952062891010102e3632aecd0f738a35c1fca3
238 Author: A U Thor <author@example.com>
239 Date: Thu May 26 23:30:00 2005 +0000
241 Commit 1
243 notes.txt
244 " > expected
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"' '
258 `false`
262 ###########
263 # Teardown
264 ###########
267 test_expect_success 'Teardown' '
268 cd $ORIG_PATH
271 test_done