gitstats: Don't asume setupRepo.py is executable
[git-stats.git] / src / t / t8101-metrics.sh
blobbd7f5c0a7643d93b4de88a8a9816784adeeaf06a
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 ###########
19 test_expect_success 'extract test repo path' '
20 METRICS_REPO_PATH=$(python ../scripts/setupRepo.py metrics path) || {
21 trap - exit
22 echo >&5 "FATAL: Cannot extract test repo path"
23 exit 1
27 test_expect_success 'pre-clean' '
28 rm -fr "$METRICS_REPO_PATH" || {
29 trap - exit
30 echo >&5 "FATAL: Cannot clean the fresh repo"
31 exit 1
35 test_expect_success 'setup' '
36 python ../scripts/setupRepo.py metrics path "$METRICS_REPO_PATH" && \
37 cd "$METRICS_REPO_PATH" || {
38 trap - exit
39 echo >&5 "FATAL: Cannot cd into fresh repo"
40 exit 1
44 test_expect_success 'Test that stats.py is reachable' '
45 stats.py -v || {
46 trap - exit
47 echo >&5 "FATAL: stats.py not reachable"
48 exit 1
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 || {
57 trap - exit
58 echo >&5 "FATAL: Head revision does not match"
59 exit 1
64 ###########
65 # Belongs to
66 ###########
68 echo "Matching branches:
69 master
70 maint
71 side" > expected
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:
79 master" > expected
81 test_expect_success \
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
88 test_expect_success \
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:
96 maint
97 side" > expected
99 # It should belong to both maint and side since side was
100 # branched off from maint after the tested commit was made.
101 # Tested are:
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:
117 maint" > expected
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:
127 side" > expected
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
151 ###########
152 # Teardown
153 ###########
156 test_expect_success 'Teardown' '
157 cd $ORIG_PATH
160 test_done