Skip to content

Commit c1fe7fd

Browse files
avargitster
authored andcommitted
mailmap tests: get rid of overly complex blame fuzzing
Change a test that used a custom fuzzing function since bfdfa3d (t4203 (mailmap): stop hardcoding commit ids and dates, 2010-10-15) to just use the "blame --porcelain" output instead. We could use the same pattern as 0ba9c9a (t8008: rely on rev-parse'd HEAD instead of sha1 value, 2017-07-26) does to do this, but there wouldn't be any point. We're not trying to test "blame" output here in general, just that "blame" pays attention to the mailmap. So it's sufficient to get the blamed line(s) and authors from the output, which is much easier with the "--porcelain" option. It would still be possible for there to be a bug in "blame" such that it uses the mailmap for its "--porcelain" output, but not the regular output. Let's test for that simply by checking if specifying the mailmap changes the output. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 400d160 commit c1fe7fd

File tree

1 file changed

+30
-20
lines changed

1 file changed

+30
-20
lines changed

t/t4203-mailmap.sh

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@ test_description='.mailmap configurations'
44

55
. ./test-lib.sh
66

7-
fuzz_blame () {
8-
sed "
9-
s/$_x05[0-9a-f][0-9a-f][0-9a-f]/OBJID/g
10-
s/$_x05[0-9a-f][0-9a-f]/OBJI/g
11-
s/[-0-9]\{10\} [:0-9]\{8\} [-+][0-9]\{4\}/DATE/g
12-
" "$@"
13-
}
14-
157
test_expect_success 'setup commits and contacts file' '
168
echo one >one &&
179
git add one &&
@@ -630,24 +622,42 @@ test_expect_success 'Only grep replaced author with --use-mailmap' '
630622
test_must_be_empty actual
631623
'
632624

633-
test_expect_success 'Blame output (complex mapping)' '
625+
test_expect_success 'Blame --porcelain output (complex mapping)' '
634626
test_config mailmap.file complex.map &&
635627
636628
cat >expect <<-EOF &&
637-
^OBJI ($GIT_AUTHOR_NAME DATE 1) one
638-
OBJID (Some Dude DATE 2) two
639-
OBJID (Other Author DATE 3) three
640-
OBJID (Other Author DATE 4) four
641-
OBJID (Santa Claus DATE 5) five
642-
OBJID (Santa Claus DATE 6) six
643-
OBJID (CTO DATE 7) seven
644-
EOF
645-
646-
git blame one >actual &&
647-
fuzz_blame actual >actual.fuzz &&
629+
1 1 1
630+
A U Thor
631+
2 2 1
632+
Some Dude
633+
3 3 1
634+
Other Author
635+
4 4 1
636+
Other Author
637+
5 5 1
638+
Santa Claus
639+
6 6 1
640+
Santa Claus
641+
7 7 1
642+
CTO
643+
EOF
644+
645+
git blame --porcelain one >actual.blame &&
646+
grep -E \
647+
-e "[0-9]+ [0-9]+ [0-9]+$" \
648+
-e "^author .*$" \
649+
actual.blame >actual.grep &&
650+
cut -d " " -f2-4 <actual.grep >actual.fuzz &&
648651
test_cmp expect actual.fuzz
649652
'
650653

654+
test_expect_success 'Blame output (complex mapping)' '
655+
git -c mailmap.file=complex.map blame one >a &&
656+
git blame one >b &&
657+
test_file_not_empty a &&
658+
! cmp a b
659+
'
660+
651661
test_expect_success 'commit --author honors mailmap' '
652662
test_config mailmap.file complex.map &&
653663

0 commit comments

Comments
 (0)