t8001/t8002 (blame): add blame -L tests

With the exception of a couple "corner case" checks in t8003 (and some indirect tests in t4211 of -L parsing code shared by log -L), there is no systematic checking of blame -L. Add tests to check blame -L directly. 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 03e15fc0b61450d6d7388e7514a67e1a9e7b72bd
1 file changed +101 -3
t/annotate-tests.sh
+101 -3
@@ -3,9 +3,17 @@
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 >actual &&
6 + options= &&
7 + while :
8 + do
9 + case "$1" in
10 + -h) head="$2"; shift; shift ;;
11 + -*) options="$options $1"; shift ;;
12 + *) break ;;
13 + esac
14 + done &&
15 + echo "$PROG $options file $head" >&4 &&
16 + $PROG $options file $head >actual &&
17 perl -e '
18 my %expect = (@ARGV);
19 my %count = map { $_ => 0 } keys %expect;
@@ -142,3 +150,93 @@ test_expect_success 'setup obfuscated email' '
150 test_expect_success 'blame obfuscated email' '
151 check_count A 1 B 1 B1 1 B2 1 "A U Thor" 1 C 1 D 1 E 1
152 '
153 +
154 +test_expect_success 'blame -L 1 (all)' '
155 + check_count -L1 A 1 B 1 B1 1 B2 1 "A U Thor" 1 C 1 D 1 E 1
156 +'
157 +
158 +test_expect_success 'blame -L , (all)' '
159 + check_count -L, A 1 B 1 B1 1 B2 1 "A U Thor" 1 C 1 D 1 E 1
160 +'
161 +
162 +test_expect_success 'blame -L X (X to end)' '
163 + check_count -L5 B1 1 C 1 D 1 "A U Thor" 1
164 +'
165 +
166 +test_expect_success 'blame -L X, (X to end)' '
167 + check_count -L5, B1 1 C 1 D 1 "A U Thor" 1
168 +'
169 +
170 +test_expect_success 'blame -L ,Y (up to Y)' '
171 + check_count -L,3 A 1 B2 1 E 1
172 +'
173 +
174 +test_expect_success 'blame -L X,X' '
175 + check_count -L3,3 B2 1
176 +'
177 +
178 +test_expect_success 'blame -L X,Y' '
179 + check_count -L3,6 B 1 B1 1 B2 1 D 1
180 +'
181 +
182 +test_expect_success 'blame -L Y,X (undocumented)' '
183 + check_count -L6,3 B 1 B1 1 B2 1 D 1
184 +'
185 +
186 +test_expect_success 'blame -L X,+1' '
187 + check_count -L3,+1 B2 1
188 +'
189 +
190 +test_expect_success 'blame -L X,+N' '
191 + check_count -L3,+4 B 1 B1 1 B2 1 D 1
192 +'
193 +
194 +test_expect_success 'blame -L X,-1' '
195 + check_count -L3,-1 B2 1
196 +'
197 +
198 +test_expect_success 'blame -L X,-N' '
199 + check_count -L6,-4 B 1 B1 1 B2 1 D 1
200 +'
201 +
202 +test_expect_success 'blame -L /RE/ (RE to end)' '
203 + check_count -L/evil/ C 1 "A U Thor" 1
204 +'
205 +
206 +test_expect_success 'blame -L /RE/,/RE2/' '
207 + check_count -L/robot/,/green/ A 1 B 1 B2 1 D 1 E 1
208 +'
209 +
210 +test_expect_success 'blame -L X,/RE/' '
211 + check_count -L5,/evil/ B1 1 D 1 "A U Thor" 1
212 +'
213 +
214 +test_expect_success 'blame -L /RE/,Y' '
215 + check_count -L/99/,7 B1 1 D 1 "A U Thor" 1
216 +'
217 +
218 +test_expect_success 'blame -L /RE/,+N' '
219 + check_count -L/99/,+3 B1 1 D 1 "A U Thor" 1
220 +'
221 +
222 +test_expect_success 'blame -L /RE/,-N' '
223 + check_count -L/99/,-3 B 1 B2 1 D 1
224 +'
225 +
226 +test_expect_success 'blame -L X (X > nlines)' '
227 + test_must_fail $PROG -L12345 file
228 +'
229 +
230 +test_expect_success 'blame -L ,Y (Y > nlines)' '
231 + test_must_fail $PROG -L,12345 file
232 +'
233 +
234 +test_expect_success 'blame -L bogus' '
235 + test_must_fail $PROG -L file &&
236 + test_must_fail $PROG -L1,+ file &&
237 + test_must_fail $PROG -L1,- file &&
238 + test_must_fail $PROG -LX file &&
239 + test_must_fail $PROG -L1,X file &&
240 + test_must_fail $PROG -L1,+N file &&
241 + test_must_fail $PROG -L1,-N file
242 +'