@matheusbsbs / matheus-bagliano / commits / 8752d11d60
Fork 0

git-blame: Use the same tests for git-blame as for git-annotate

Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se> Signed-off-by: Junio C Hamano <junkio@cox.net>

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