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

git-blame inherited "-L :funcname" support when "-L :funcname:file" was implemented for git-log. Add tests. 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 5a9830cb718ce13fcbad39384dd365bb895a1b21
1 file changed +46 -2
t/annotate-tests.sh
+46 -2
@@ -3,17 +3,19 @@
3
4 check_count () {
5 head= &&
6 + file='file' &&
7 options= &&
8 while :
9 do
10 case "$1" in
11 -h) head="$2"; shift; shift ;;
12 + -f) file="$2"; shift; shift ;;
13 -*) options="$options $1"; shift ;;
14 *) break ;;
15 esac
16 done &&
15 - echo "$PROG $options file $head" >&4 &&
16 - $PROG $options file $head >actual &&
17 + echo "$PROG $options $file $head" >&4 &&
18 + $PROG $options $file $head >actual &&
19 perl -e '
20 my %expect = (@ARGV);
21 my %count = map { $_ => 0 } keys %expect;
@@ -231,6 +233,48 @@ test_expect_success 'blame -L ,Y (Y > nlines)' '
233 test_must_fail $PROG -L,12345 file
234 '
235
236 +test_expect_success 'setup -L :regex' '
237 + tr Q "\\t" >hello.c <<-\EOF &&
238 + int main(int argc, const char *argv[])
239 + {
240 + Qputs("hello");
241 + }
242 + EOF
243 + git add hello.c &&
244 + GIT_AUTHOR_NAME="F" GIT_AUTHOR_EMAIL="F@test.git" \
245 + git commit -m "hello" &&
246 +
247 + mv hello.c hello.orig &&
248 + sed -e "/}/i\\
249 + Qputs(\"goodbye\");" <hello.orig | tr Q "\\t" >hello.c &&
250 + GIT_AUTHOR_NAME="G" GIT_AUTHOR_EMAIL="G@test.git" \
251 + git commit -a -m "goodbye" &&
252 +
253 + mv hello.c hello.orig &&
254 + echo "#include <stdio.h>" >hello.c &&
255 + cat hello.orig >>hello.c &&
256 + tr Q "\\t" >>hello.c <<-\EOF
257 + void mail()
258 + {
259 + Qputs("mail");
260 + }
261 + EOF
262 + GIT_AUTHOR_NAME="H" GIT_AUTHOR_EMAIL="H@test.git" \
263 + git commit -a -m "mail"
264 +'
265 +
266 +test_expect_success 'blame -L :literal' '
267 + check_count -f hello.c -L:main F 4 G 1
268 +'
269 +
270 +test_expect_success 'blame -L :regex' '
271 + check_count -f hello.c "-L:m[a-z][a-z]l" H 4
272 +'
273 +
274 +test_expect_success 'blame -L :nomatch' '
275 + test_must_fail $PROG -L:nomatch hello.c
276 +'
277 +
278 test_expect_success 'blame -L bogus' '
279 test_must_fail $PROG -L file &&
280 test_must_fail $PROG -L1,+ file &&