Skip to content

Commit f08b401

Browse files
avargitster
authored andcommitted
blame tests: simplify userdiff driver test
Simplify the test added in 9466e38 (blame: enable funcname blaming with userdiff driver, 2020-11-01) to use the --author support recently added in 999cfc4 (test-lib functions: add --author support to test_commit, 2021-01-12). We also did not need the full fortran-external-function content. Let's cut it down to just the important parts. I'm modifying it to demonstrate that the fortran-specific userdiff function is in effect by adding "DO NOT MATCH ..." and "AS THE ..." lines surrounding the "RIGHT" one. This is to check that we're using the userdiff "fortran" driver, as opposed to the default driver which would match on those lines as part of the general heuristic of matching a line that doesn't begin with whitespace. The test had also been leaving behind a .gitattributes file for later tests to possibly trip over, let's clean it up with "test_when_finished". Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b269441 commit f08b401

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

t/annotate-tests.sh

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -479,32 +479,26 @@ test_expect_success 'blame -L ^:RE (absolute: end-of-file)' '
479479
check_count -f hello.c -L$n -L^:ma.. F 4 G 1 H 1
480480
'
481481

482-
test_expect_success 'setup -L :funcname with userdiff driver' '
483-
echo "fortran-* diff=fortran" >.gitattributes &&
484-
fortran_file=fortran-external-function &&
485-
cat >$fortran_file <<-\EOF &&
482+
test_expect_success 'blame -L :funcname with userdiff driver' '
483+
cat >file.template <<-\EOF &&
484+
DO NOT MATCH THIS LINE
486485
function RIGHT(a, b) result(c)
486+
AS THE DEFAULT DRIVER WOULD
487487
488488
integer, intent(in) :: ChangeMe
489-
integer, intent(in) :: b
490-
integer, intent(out) :: c
491-
492-
c = a+b
493-
494-
end function RIGHT
495489
EOF
496-
git add "$fortran_file" &&
497-
GIT_AUTHOR_NAME="A" GIT_AUTHOR_EMAIL="[email protected]" \
498-
git commit -m "add fortran file" &&
499-
sed -e "s/ChangeMe/IWasChanged/" <"$fortran_file" >"$fortran_file".tmp &&
500-
mv "$fortran_file".tmp "$fortran_file" &&
501-
git add "$fortran_file" &&
502-
GIT_AUTHOR_NAME="B" GIT_AUTHOR_EMAIL="[email protected]" \
503-
git commit -m "change fortran file"
504-
'
505490
506-
test_expect_success 'blame -L :funcname with userdiff driver' '
507-
check_count -f fortran-external-function -L:RIGHT A 7 B 1
491+
fortran_file=file.f03 &&
492+
test_when_finished "rm .gitattributes" &&
493+
echo "$fortran_file diff=fortran" >.gitattributes &&
494+
495+
test_commit --author "A <[email protected]>" \
496+
"add" "$fortran_file" \
497+
"$(cat file.template)" &&
498+
test_commit --author "B <[email protected]>" \
499+
"change" "$fortran_file" \
500+
"$(cat file.template | sed -e s/ChangeMe/IWasChanged/)" &&
501+
check_count -f "$fortran_file" -L:RIGHT A 3 B 1
508502
'
509503

510504
test_expect_success 'setup incremental' '

0 commit comments

Comments
 (0)