mirror of
https://github.com/git/git.git
synced 2024-11-25 10:54:00 +08:00
blame tests: simplify userdiff driver test
Simplify the test added in9466e3809d
(blame: enable funcname blaming with userdiff driver, 2020-11-01) to use the --author support recently added in999cfc4f45
(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 <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
b269441be2
commit
f08b4013c3
@ -479,32 +479,26 @@ test_expect_success 'blame -L ^:RE (absolute: end-of-file)' '
|
|||||||
check_count -f hello.c -L$n -L^:ma.. F 4 G 1 H 1
|
check_count -f hello.c -L$n -L^:ma.. F 4 G 1 H 1
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'setup -L :funcname with userdiff driver' '
|
test_expect_success 'blame -L :funcname with userdiff driver' '
|
||||||
echo "fortran-* diff=fortran" >.gitattributes &&
|
cat >file.template <<-\EOF &&
|
||||||
fortran_file=fortran-external-function &&
|
DO NOT MATCH THIS LINE
|
||||||
cat >$fortran_file <<-\EOF &&
|
|
||||||
function RIGHT(a, b) result(c)
|
function RIGHT(a, b) result(c)
|
||||||
|
AS THE DEFAULT DRIVER WOULD
|
||||||
|
|
||||||
integer, intent(in) :: ChangeMe
|
integer, intent(in) :: ChangeMe
|
||||||
integer, intent(in) :: b
|
|
||||||
integer, intent(out) :: c
|
|
||||||
|
|
||||||
c = a+b
|
|
||||||
|
|
||||||
end function RIGHT
|
|
||||||
EOF
|
EOF
|
||||||
git add "$fortran_file" &&
|
|
||||||
GIT_AUTHOR_NAME="A" GIT_AUTHOR_EMAIL="A@test.git" \
|
|
||||||
git commit -m "add fortran file" &&
|
|
||||||
sed -e "s/ChangeMe/IWasChanged/" <"$fortran_file" >"$fortran_file".tmp &&
|
|
||||||
mv "$fortran_file".tmp "$fortran_file" &&
|
|
||||||
git add "$fortran_file" &&
|
|
||||||
GIT_AUTHOR_NAME="B" GIT_AUTHOR_EMAIL="B@test.git" \
|
|
||||||
git commit -m "change fortran file"
|
|
||||||
'
|
|
||||||
|
|
||||||
test_expect_success 'blame -L :funcname with userdiff driver' '
|
fortran_file=file.f03 &&
|
||||||
check_count -f fortran-external-function -L:RIGHT A 7 B 1
|
test_when_finished "rm .gitattributes" &&
|
||||||
|
echo "$fortran_file diff=fortran" >.gitattributes &&
|
||||||
|
|
||||||
|
test_commit --author "A <A@test.git>" \
|
||||||
|
"add" "$fortran_file" \
|
||||||
|
"$(cat file.template)" &&
|
||||||
|
test_commit --author "B <B@test.git>" \
|
||||||
|
"change" "$fortran_file" \
|
||||||
|
"$(cat file.template | sed -e s/ChangeMe/IWasChanged/)" &&
|
||||||
|
check_count -f "$fortran_file" -L:RIGHT A 3 B 1
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'setup incremental' '
|
test_expect_success 'setup incremental' '
|
||||||
|
Loading…
Reference in New Issue
Block a user