3 # Copyright (c) 2008 Sverre Rabbelier
6 test_description
='stats tests (basics)
8 This test verifies that the basic stats commands work as expected.'
19 test_expect_success
'extract test repo path' '
20 METRICS_REPO_PATH=$(python ../scripts/setupRepo.py metrics path) || {
22 echo >&5 "FATAL: Cannot extract test repo path"
27 test_expect_success
'pre-clean' '
28 rm -fr "$METRICS_REPO_PATH" || {
30 echo >&5 "FATAL: Cannot clean the fresh repo"
35 test_expect_success
'setup' '
36 python ../scripts/setupRepo.py metrics path "$METRICS_REPO_PATH" && \
37 cd "$METRICS_REPO_PATH" || {
39 echo >&5 "FATAL: Cannot cd into fresh repo"
44 test_expect_success
'Test that stats.py is reachable' '
47 echo >&5 "FATAL: stats.py not reachable"
52 echo "e5aa8fcf1233ea51764bad0d929ed15dc5c90dc1" > expected
54 test_expect_success
'Test that the expected tree was created by setupRepo' '
55 git rev-parse HEAD > actual
56 test_cmp expected actual || {
58 echo >&5 "FATAL: Head revision does not match"
68 echo "Matching branches:
73 test_expect_success
'Test that the initial revision is owned by all' '
74 stats.py branch -b a23d994 > actual
75 test_cmp expected actual
78 echo "Matching branches:
82 'Test that a commit made on the master branch belongs only to master' \
84 stats.py branch -b 2e560d2 > actual
85 test_cmp expected actual
89 'Test that the dilution is correct when another branch is merged in later on' \
91 stats.py branch -b 866d9d7 > actual
92 test_cmp expected actual
95 echo "Matching branches:
99 # It should belong to both maint and side since side was
100 # branched off from maint after the tested commit was made.
102 # * The point where side branched off from maint
103 # * A point before the branch off point
104 # * A commit on a side branch that was merged in
105 test_expect_success \
106 'Test that a commit made on maint belongs to both maint and side' \
108 stats.py branch -b 38c3784 > actual1
109 stats.py branch -b 9a0b6cc > actual2
110 stats.py branch -b 442be4c > actual3
111 test_cmp expected actual1 &&
112 test_cmp expected actual2 &&
113 test_cmp expected actual3
116 echo "Matching branches:
119 test_expect_success \
120 'Test that a merge commit belongs to the branch the merge was done on' \
122 stats.py branch -b 4ff12b2 > actual
123 test_cmp expected actual
126 echo "Matching branches:
129 test_expect_success \
130 'Test that the base of a merge belongs to the branch the merge was based on' \
132 stats.py branch -b 40843d5 > actual
133 test_cmp expected actual
136 test_expect_success \
137 'Test that the dilution is correct when other branches merge with its branch' \
139 stats.py branch -b bb33bd1 > actual
140 test_cmp expected actual
143 test_expect_success \
144 'Test that a branch made on side, and not merged later, belongs to side' \
146 stats.py branch -b 698a02f > actual
147 test_cmp expected actual
156 test_expect_success
'Teardown' '