t8001/t8002 (blame): modernize style

In particular, - indent with tabs - cuddle test description and opening body quote with test_expect_foo - normalize test descriptions and case - remove whitepsace following redirection operator - use standardized filenames (such as "actual", "expected") Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Eric Sunshine committed Jul 17, 2013 at 17:25 UTC e37f39c134c3621f26fdcdbc22a6b2e4e00de2e5
3 files changed +127 -112
t/annotate-tests.sh
+114 -107
@@ -2,11 +2,11 @@
2 # sourced from t8001-annotate.sh and t8002-blame.sh.
3
4 check_count () {
5 - head=
6 - case "$1" in -h) head="$2"; shift; shift ;; esac
7 - echo "$PROG file $head" >&4
8 - $PROG file $head >.result || return 1
9 - cat .result | perl -e '
5 + head= &&
6 + case "$1" in -h) head="$2"; shift; shift ;; esac &&
7 + echo "$PROG file $head" >&4 &&
8 + $PROG file $head >actual &&
9 + perl -e '
10 my %expect = (@ARGV);
11 my %count = map { $_ => 0 } keys %expect;
12 while (<STDIN>) {
@@ -31,107 +31,114 @@ check_count () {
31 print STDERR "Author $author (expected $value, attributed $count) $ok\n";
32 }
33 exit($bad);
34 - ' "$@"
34 + ' "$@" <actual
35 }
36
37 -test_expect_success \
38 - 'prepare reference tree' \
39 - 'echo "1A quick brown fox jumps over the" >file &&
40 - echo "lazy dog" >>file &&
41 - git add file &&
42 - GIT_AUTHOR_NAME="A" GIT_AUTHOR_EMAIL="A@test.git" git commit -a -m "Initial."'
43 -
44 -test_expect_success \
45 - 'check all lines blamed on A' \
46 - 'check_count A 2'
47 -
48 -test_expect_success \
49 - 'Setup new lines blamed on B' \
50 - 'echo "2A quick brown fox jumps over the" >>file &&
51 - echo "lazy dog" >> file &&
52 - GIT_AUTHOR_NAME="B" GIT_AUTHOR_EMAIL="B@test.git" git commit -a -m "Second."'
53 -
54 -test_expect_success \
55 - 'Two lines blamed on A, two on B' \
56 - 'check_count A 2 B 2'
57 -
58 -test_expect_success \
59 - 'merge-setup part 1' \
60 - 'git checkout -b branch1 master &&
61 - echo "3A slow green fox jumps into the" >> file &&
62 - echo "well." >> file &&
63 - GIT_AUTHOR_NAME="B1" GIT_AUTHOR_EMAIL="B1@test.git" git commit -a -m "Branch1-1"'
64 -
65 -test_expect_success \
66 - 'Two lines blamed on A, two on B, two on B1' \
67 - 'check_count A 2 B 2 B1 2'
68 -
69 -test_expect_success \
70 - 'merge-setup part 2' \
71 - 'git checkout -b branch2 master &&
72 - sed -e "s/2A quick brown/4A quick brown lazy dog/" < file > file.new &&
73 - mv file.new file &&
74 - GIT_AUTHOR_NAME="B2" GIT_AUTHOR_EMAIL="B2@test.git" git commit -a -m "Branch2-1"'
75 -
76 -test_expect_success \
77 - 'Two lines blamed on A, one on B, one on B2' \
78 - 'check_count A 2 B 1 B2 1'
79 -
80 -test_expect_success \
81 - 'merge-setup part 3' \
82 - 'git pull . branch1'
83 -
84 -test_expect_success \
85 - 'Two lines blamed on A, one on B, two on B1, one on B2' \
86 - 'check_count A 2 B 1 B1 2 B2 1'
87 -
88 -test_expect_success \
89 - 'Annotating an old revision works' \
90 - 'check_count -h master A 2 B 2'
91 -
92 -test_expect_success \
93 - 'Annotating an old revision works' \
94 - 'check_count -h master^ A 2'
95 -
96 -test_expect_success \
97 - 'merge-setup part 4' \
98 - 'echo "evil merge." >>file &&
99 - git commit -a --amend'
100 -
101 -test_expect_success \
102 - 'Two lines blamed on A, one on B, two on B1, one on B2, one on A U Thor' \
103 - 'check_count A 2 B 1 B1 2 B2 1 "A U Thor" 1'
104 -
105 -test_expect_success \
106 - 'an incomplete line added' \
107 - 'echo "incomplete" | tr -d "\\012" >>file &&
108 - GIT_AUTHOR_NAME="C" GIT_AUTHOR_EMAIL="C@test.git" git commit -a -m "Incomplete"'
109 -
110 -test_expect_success \
111 - 'With incomplete lines.' \
112 - 'check_count A 2 B 1 B1 2 B2 1 "A U Thor" 1 C 1'
113 -
114 -test_expect_success \
115 - 'some edit' \
116 - 'mv file file.orig &&
117 - {
118 - cat file.orig &&
119 - echo
120 - } | sed -e "s/^3A/99/" -e "/^1A/d" -e "/^incomplete/d" > file &&
121 - echo "incomplete" | tr -d "\\012" >>file &&
122 - GIT_AUTHOR_NAME="D" GIT_AUTHOR_EMAIL="D@test.git" git commit -a -m "edit"'
123 -
124 -test_expect_success \
125 - 'some edit' \
126 - 'check_count A 1 B 1 B1 1 B2 1 "A U Thor" 1 C 1 D 1'
127 -
128 -test_expect_success \
129 - 'an obfuscated email added' \
130 - 'echo "No robots allowed" > file.new &&
131 - cat file >> file.new &&
132 - mv file.new file &&
133 - GIT_AUTHOR_NAME="E" GIT_AUTHOR_EMAIL="E at test dot git" git commit -a -m "norobots"'
134 -
135 -test_expect_success \
136 - 'obfuscated email parsed' \
137 - 'check_count A 1 B 1 B1 1 B2 1 "A U Thor" 1 C 1 D 1 E 1'
37 +test_expect_success 'setup A lines' '
38 + echo "1A quick brown fox jumps over the" >file &&
39 + echo "lazy dog" >>file &&
40 + git add file &&
41 + GIT_AUTHOR_NAME="A" GIT_AUTHOR_EMAIL="A@test.git" \
42 + git commit -a -m "Initial."
43 +'
44 +
45 +test_expect_success 'blame 1 author' '
46 + check_count A 2
47 +'
48 +
49 +test_expect_success 'setup B lines' '
50 + echo "2A quick brown fox jumps over the" >>file &&
51 + echo "lazy dog" >>file &&
52 + GIT_AUTHOR_NAME="B" GIT_AUTHOR_EMAIL="B@test.git" \
53 + git commit -a -m "Second."
54 +'
55 +
56 +test_expect_success 'blame 2 authors' '
57 + check_count A 2 B 2
58 +'
59 +
60 +test_expect_success 'setup B1 lines (branch1)' '
61 + git checkout -b branch1 master &&
62 + echo "3A slow green fox jumps into the" >>file &&
63 + echo "well." >>file &&
64 + GIT_AUTHOR_NAME="B1" GIT_AUTHOR_EMAIL="B1@test.git" \
65 + git commit -a -m "Branch1-1"
66 +'
67 +
68 +test_expect_success 'blame 2 authors + 1 branch1 author' '
69 + check_count A 2 B 2 B1 2
70 +'
71 +
72 +test_expect_success 'setup B2 lines (branch2)' '
73 + git checkout -b branch2 master &&
74 + sed -e "s/2A quick brown/4A quick brown lazy dog/" <file >file.new &&
75 + mv file.new file &&
76 + GIT_AUTHOR_NAME="B2" GIT_AUTHOR_EMAIL="B2@test.git" \
77 + git commit -a -m "Branch2-1"
78 +'
79 +
80 +test_expect_success 'blame 2 authors + 1 branch2 author' '
81 + check_count A 2 B 1 B2 1
82 +'
83 +
84 +test_expect_success 'merge branch1 & branch2' '
85 + git pull . branch1
86 +'
87 +
88 +test_expect_success 'blame 2 authors + 2 merged-in authors' '
89 + check_count A 2 B 1 B1 2 B2 1
90 +'
91 +
92 +test_expect_success 'blame ancestor' '
93 + check_count -h master A 2 B 2
94 +'
95 +
96 +test_expect_success 'blame great-ancestor' '
97 + check_count -h master^ A 2
98 +'
99 +
100 +test_expect_success 'setup evil merge' '
101 + echo "evil merge." >>file &&
102 + git commit -a --amend
103 +'
104 +
105 +test_expect_success 'blame evil merge' '
106 + check_count A 2 B 1 B1 2 B2 1 "A U Thor" 1
107 +'
108 +
109 +test_expect_success 'setup incomplete line' '
110 + echo "incomplete" | tr -d "\\012" >>file &&
111 + GIT_AUTHOR_NAME="C" GIT_AUTHOR_EMAIL="C@test.git" \
112 + git commit -a -m "Incomplete"
113 +'
114 +
115 +test_expect_success 'blame incomplete line' '
116 + check_count A 2 B 1 B1 2 B2 1 "A U Thor" 1 C 1
117 +'
118 +
119 +test_expect_success 'setup edits' '
120 + mv file file.orig &&
121 + {
122 + cat file.orig &&
123 + echo
124 + } | sed -e "s/^3A/99/" -e "/^1A/d" -e "/^incomplete/d" >file &&
125 + echo "incomplete" | tr -d "\\012" >>file &&
126 + GIT_AUTHOR_NAME="D" GIT_AUTHOR_EMAIL="D@test.git" \
127 + git commit -a -m "edit"
128 +'
129 +
130 +test_expect_success 'blame edits' '
131 + check_count A 1 B 1 B1 1 B2 1 "A U Thor" 1 C 1 D 1
132 +'
133 +
134 +test_expect_success 'setup obfuscated email' '
135 + echo "No robots allowed" >file.new &&
136 + cat file >>file.new &&
137 + mv file.new file &&
138 + GIT_AUTHOR_NAME="E" GIT_AUTHOR_EMAIL="E at test dot git" \
139 + git commit -a -m "norobots"
140 +'
141 +
142 +test_expect_success 'blame obfuscated email' '
143 + check_count A 1 B 1 B1 1 B2 1 "A U Thor" 1 C 1 D 1 E 1
144 +'
t/t8001-annotate.sh
+3 -3
@@ -6,9 +6,9 @@ test_description='git annotate'
6 PROG='git annotate'
7 . "$TEST_DIRECTORY"/annotate-tests.sh
8
9 -test_expect_success 'Annotating an old revision works' '
10 - git annotate file master >result &&
11 - awk "{ print \$3; }" <result >authors &&
9 +test_expect_success 'annotate old revision' '
10 + git annotate file master >actual &&
11 + awk "{ print \$3; }" <actual >authors &&
12 test 2 = $(grep A <authors | wc -l) &&
13 test 2 = $(grep B <authors | wc -l)
14 '
t/t8002-blame.sh
+10 -2
@@ -7,8 +7,16 @@ PROG='git blame -c'
7 . "$TEST_DIRECTORY"/annotate-tests.sh
8
9 PROG='git blame -c -e'
10 -test_expect_success 'Blame --show-email works' '
11 - check_count "<A@test.git>" 1 "<B@test.git>" 1 "<B1@test.git>" 1 "<B2@test.git>" 1 "<author@example.com>" 1 "<C@test.git>" 1 "<D@test.git>" 1 "<E at test dot git>" 1
10 +test_expect_success 'blame --show-email' '
11 + check_count \
12 + "<A@test.git>" 1 \
13 + "<B@test.git>" 1 \
14 + "<B1@test.git>" 1 \
15 + "<B2@test.git>" 1 \
16 + "<author@example.com>" 1 \
17 + "<C@test.git>" 1 \
18 + "<D@test.git>" 1 \
19 + "<E at test dot git>" 1
20 '
21
22 test_done