3 # Copyright (c) 2008 Sverre Rabbelier
6 test_description
='stats tests (basics)
8 This test verifies that the basic stats commands work as expected.'
11 PATH
=$ORIG_PATH/..
:$PATH
21 test_expect_success
'extract test repo path' '
22 METRICS_REPO_PATH=$(python ../scripts/setupRepo.py metrics path) || {
24 echo >&5 "FATAL: Cannot extract test repo path"
29 test_expect_success
'pre-clean' '
30 rm -fr "$METRICS_REPO_PATH" || {
32 echo >&5 "FATAL: Cannot clean the fresh repo"
37 test_expect_success
'setup' '
38 python ../scripts/setupRepo.py metrics path "$METRICS_REPO_PATH" && \
39 cd "$METRICS_REPO_PATH" || {
41 echo >&5 "FATAL: Cannot cd into fresh repo"
46 test_expect_success
'Test that stats.py is reachable' '
49 echo >&5 "FATAL: stats.py not reachable"
54 echo "e5aa8fcf1233ea51764bad0d929ed15dc5c90dc1" > expected
56 test_expect_success
'Test that the expected tree was created by setupRepo' '
57 git rev-parse HEAD > actual
58 test_cmp expected actual || {
60 echo >&5 "FATAL: Head revision does not match"
70 echo "Matching branches:
75 test_expect_success
'Test that the initial revision is owned by all' '
76 stats.py branch -b a23d994 > actual
77 test_cmp expected actual
80 echo "Matching branches:
84 'Test that a commit made on the master branch belongs only to master' \
86 stats.py branch -b 2e560d2 > actual
87 test_cmp expected actual
91 'Test that the dilution is correct when another branch is merged in later on' \
93 stats.py branch -b 866d9d7 > actual
94 test_cmp expected actual
97 echo "Matching branches:
101 # It should belong to both maint and side since side was
102 # branched off from maint after the tested commit was made.
104 # * The point where side branched off from maint
105 # * A point before the branch off point
106 # * A commit on a side branch that was merged in
107 test_expect_success \
108 'Test that a commit made on maint belongs to both maint and side' \
110 stats.py branch -b 38c3784 > actual1
111 stats.py branch -b 9a0b6cc > actual2
112 stats.py branch -b 442be4c > actual3
113 test_cmp expected actual1 &&
114 test_cmp expected actual2 &&
115 test_cmp expected actual3
118 echo "Matching branches:
121 test_expect_success \
122 'Test that a merge commit belongs to the branch the merge was done on' \
124 stats.py branch -b 4ff12b2 > actual
125 test_cmp expected actual
128 echo "Matching branches:
131 test_expect_success \
132 'Test that the base of a merge belongs to the branch the merge was based on' \
134 stats.py branch -b 40843d5 > actual
135 test_cmp expected actual
138 test_expect_success \
139 'Test that the dilution is correct when other branches merge with its branch' \
141 stats.py branch -b bb33bd1 > actual
142 test_cmp expected actual
145 test_expect_success \
146 'Test that a branch made on side, and not merged later, belongs to side' \
148 stats.py branch -b 698a02f > actual
149 test_cmp expected actual
158 test_expect_success
'Teardown' '