Skip to content

Commit 7c3ecb6

Browse files
pugmajereJunio C Hamano
authored andcommitted
annotate: Add a basic set of test cases.
Signed-off-by: Ryan Anderson <ryan@michonline.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent e5971d7 commit 7c3ecb6

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

t/t8001-annotate.sh

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/bin/sh
2+
3+
test_description='git-annotate'
4+
. ./test-lib.sh
5+
6+
test_expect_success \
7+
'prepare reference tree' \
8+
'echo "1A quick brown fox jumps over the" >file &&
9+
echo "lazy dog" >>file &&
10+
git add file
11+
GIT_AUTHOR_NAME="A" git commit -a -m "Initial."'
12+
13+
test_expect_success \
14+
'check all lines blamed on A' \
15+
'[ $(git annotate file | awk "{print \$3}" | grep -c "A") == 2 ]'
16+
17+
test_expect_success \
18+
'Setup new lines blamed on B' \
19+
'echo "2A quick brown fox jumps over the" >>file &&
20+
echo "lazy dog" >> file &&
21+
GIT_AUTHOR_NAME="B" git commit -a -m "Second."'
22+
23+
test_expect_success \
24+
'Two lines blamed on A' \
25+
'[ $(git annotate file | awk "{print \$3}" | grep -c "A") == 2 ]'
26+
27+
test_expect_success \
28+
'Two lines blamed on B' \
29+
'[ $(git annotate file | awk "{print \$3}" | grep -c "B") == 2 ]'
30+
31+
test_expect_success \
32+
'merge-setup part 1' \
33+
'git checkout -b branch1 master &&
34+
echo "3A slow green fox jumps into the" >> file &&
35+
echo "well." >> file &&
36+
GIT_AUTHOR_NAME="B1" git commit -a -m "Branch1-1"'
37+
38+
test_expect_success \
39+
'Two lines blamed on A' \
40+
'[ $(git annotate file | awk "{print \$3}" | grep -c "^A$") == 2 ]'
41+
42+
test_expect_success \
43+
'Two lines blamed on B' \
44+
'[ $(git annotate file | awk "{print \$3}" | grep -c "^B$") == 2 ]'
45+
46+
test_expect_success \
47+
'Two lines blamed on B1' \
48+
'[ $(git annotate file | awk "{print \$3}" | grep -c "^B1$") == 2 ]'
49+
50+
test_expect_success \
51+
'merge-setup part 2' \
52+
'git checkout -b branch2 master &&
53+
sed -i -e "s/2A quick brown/4A quick brown lazy dog/" file &&
54+
GIT_AUTHOR_NAME="B2" git commit -a -m "Branch2-1"'
55+
56+
test_expect_success \
57+
'Two lines blamed on A' \
58+
'[ $(git annotate file | awk "{print \$3}" | grep -c "^A$") == 2 ]'
59+
60+
test_expect_success \
61+
'One line blamed on B' \
62+
'[ $(git annotate file | awk "{print \$3}" | grep -c "^B$") == 1 ]'
63+
64+
test_expect_success \
65+
'One line blamed on B2' \
66+
'[ $(git annotate file | awk "{print \$3}" | grep -c "^B2$") == 1 ]'
67+
68+
69+
test_expect_success \
70+
'merge-setup part 3' \
71+
'git pull . branch1'
72+
73+
test_expect_success \
74+
'Two lines blamed on A' \
75+
'[ $(git annotate file | awk "{print \$3}" | grep -c "^A$") == 2 ]'
76+
77+
test_expect_success \
78+
'One line blamed on B' \
79+
'[ $(git annotate file | awk "{print \$3}" | grep -c "^B$") == 1 ]'
80+
81+
test_expect_success \
82+
'Two lines blamed on B1' \
83+
'[ $(git annotate file | awk "{print \$3}" | grep -c "^B1$") == 2 ]'
84+
85+
test_expect_success \
86+
'One line blamed on B2' \
87+
'[ $(git annotate file | awk "{print \$3}" | grep -c "^B2$") == 1 ]'
88+
89+
test_done

0 commit comments

Comments
 (0)