gitstats: Bugfix for diff -i, also removed debug output
[git-stats.git] / src / t / t8100-stats.sh
blob2018ac035aa8d07fba0eb1900e30fa079864a321
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 'Verify that the expected tree was created' '
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 'Verify that author filters the result properly' '
51 stats.py author -d "author@example.com" > actual
52 test_cmp expected actual
56 echo "content.txt = 2: +2 -0"
57 } > expected
59 test_expect_success 'Verify that the secondary authors result is filtered properly' '
60 stats.py author -d "roh.tua@example.com" > actual
61 test_cmp expected actual
64 rm expected
65 touch expected
67 test_expect_failure 'Verify that the output for authors is aggregated properly' '
68 `stats.py author -a` > actual
69 test_must_fail test_cmp expected actual
72 ###########
73 # Branch tests
74 ###########
77 echo "Matching branches:"
78 echo "pu"
79 } > expected
81 test_expect_success 'Test that the branch filter works as expected' '
82 stats.py branch -c 6f01ab2afb8471d6eee83162ddeabe179e443d59 > actual
83 test_cmp expected actual
87 echo "Matching branches:"
88 echo "maint"
89 echo "master"
90 } > expected
92 test_expect_success \
93 'Test that the branch filter works when multiple branches match' \
95 stats.py branch -c c0e49264fd921d2a62f90556340e371e719b45cc > actual
96 test_cmp expected actual
99 test_expect_failure 'Test that there is a test for the branch -r switch' '
100 `false`
104 ###########
105 # Commit tests
106 ###########
109 echo "commit e76ad031836912c01da47ab93d3c21676763267e
110 Author: A U Thor <author@example.com>
111 Date: Thu May 26 23:30:00 2005 +0000
113 Commit 3
115 notes.txt
117 commit e8fa5fed0d1823c1e3e120579b03343aecf26ab6
118 Author: A U Thor <author@example.com>
119 Date: Thu May 26 23:30:00 2005 +0000
121 Commit 2
123 notes.txt
125 commit bd952062891010102e3632aecd0f738a35c1fca3
126 Author: A U Thor <author@example.com>
127 Date: Thu May 26 23:30:00 2005 +0000
129 Commit 1
131 notes.txt
132 " > expected
134 test_expect_success 'Test that commit --contains option filters properly' '
135 stats.py commit -t notes.txt > actual
136 test_cmp expected actual
139 test_expect_failure 'Test that there is a test for the commit -r switch' '
140 `false`
143 echo "commit bc6d646fd15953cdb514d14458f013a1fc05153c
144 Author: A U Thor <author@example.com>
145 Date: Thu May 26 23:30:00 2005 +0000
147 Initial commit
149 content.txt
150 " > expected
152 test_expect_success 'Test that the --log option filters properly' '
153 stats.py commit --log-contains=Initial > actual
154 test_cmp expected actual
157 test_expect_success 'Test that the --diff option filters properly' '
158 stats.py commit --diff-contains=Initial > actual
159 test_cmp expected actual
163 ###########
164 # Diff tests
165 ###########
168 echo "Missing the following keys:
169 ('/dev/null', 'b/notes.txt')" > expected
171 test_expect_success 'Test that two equal diffs in different files are not equal' '
172 stats.py diff -e bd9520628910101 3c34aec51560970c > actual
173 test_cmp expected actual
176 echo "Missing the following keys:
177 ('/dev/null', 'b/test.c')" > expected
179 test_expect_success 'Test that two equal diffs in different files are not equal' '
180 stats.py diff -e 3c34aec51560970c bd9520628910101 > actual
181 test_cmp expected actual
184 echo "Equal" > expected
186 test_expect_success 'Test that two equal diffs are equal' '
187 stats.py diff -e HEAD HEAD > actual
188 test_cmp expected actual
191 test_expect_failure 'Test that there are tests to test the -n option' '
192 `false`
195 echo "Equal" > expected
197 test_expect_success 'Test that the -i option detects reverts as equal' '
198 stats.py diff -i -e cc2d11f96d7ec43 c2d26c33f9e8eb6 > actual
199 test_cmp expected actual
203 ###########
204 # Teardown
205 ###########
208 test_expect_success 'Teardown' '
209 cd $ORIG_PATH
212 test_done