Skip to content

Commit 1db421a

Browse files
avargitster
authored andcommitted
mailmap tests: improve --stdin tests
The --stdin tests setup the "contact" file in the main setup, let's instead set it up in the test that uses it. Also refactor the first test so it's obvious that the point of it is that "check-mailmap" will spew its input as-is when given no argument. For that one we can just use the "expect" file as-is. Also add tests for how other "--stdin" cases are handled, e.g. one where we actually do a mapping. For the rest of --stdin testing we just assume we're going to get the same output. We could follow-up and make sure everything's round-tripped through both --stdin and the file/blob backends, but I don't think there's much point in that. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e9931ac commit 1db421a

File tree

1 file changed

+32
-8
lines changed

1 file changed

+32
-8
lines changed

t/t4203-mailmap.sh

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ fuzz_blame () {
1313
}
1414

1515
test_expect_success 'setup commits and contacts file' '
16-
cat >contacts <<-EOF &&
17-
$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
18-
19-
EOF
20-
2116
echo one >one &&
2217
git add one &&
2318
test_tick &&
@@ -48,24 +43,53 @@ test_expect_success 'check-mailmap --stdin' '
4843
$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
4944
5045
EOF
51-
git check-mailmap --stdin <contacts >actual &&
46+
git check-mailmap --stdin <expect >actual &&
5247
test_cmp expect actual
5348
'
5449

55-
test_expect_success 'check-mailmap --stdin arguments' '
50+
test_expect_success 'check-mailmap --stdin arguments: no mapping' '
51+
test_when_finished "rm contacts" &&
52+
cat >contacts <<-EOF &&
53+
$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
54+
55+
EOF
5656
cat >expect <<-\EOF &&
5757
Internal Guy <[email protected]>
5858
EOF
59-
cat <contacts >>expect &&
59+
cat contacts >>expect &&
60+
6061
git check-mailmap --stdin "Internal Guy <[email protected]>" \
6162
<contacts >actual &&
6263
test_cmp expect actual
6364
'
6465

66+
test_expect_success 'check-mailmap --stdin arguments: mapping' '
67+
test_when_finished "rm .mailmap" &&
68+
cat >.mailmap <<-EOF &&
69+
New Name <$GIT_AUTHOR_EMAIL>
70+
EOF
71+
cat >stdin <<-EOF &&
72+
Old Name <$GIT_AUTHOR_EMAIL>
73+
EOF
74+
75+
cp .mailmap expect &&
76+
git check-mailmap --stdin <stdin >actual &&
77+
test_cmp expect actual &&
78+
79+
cat .mailmap >>expect &&
80+
git check-mailmap --stdin "Another Old Name <$GIT_AUTHOR_EMAIL>" \
81+
<stdin >actual &&
82+
test_cmp expect actual
83+
'
84+
6585
test_expect_success 'check-mailmap bogus contact' '
6686
test_must_fail git check-mailmap bogus
6787
'
6888

89+
test_expect_success 'check-mailmap bogus contact --stdin' '
90+
test_must_fail git check-mailmap --stdin bogus </dev/null
91+
'
92+
6993
test_expect_success 'No mailmap' '
7094
cat >expect <<-EOF &&
7195
$GIT_AUTHOR_NAME (1):

0 commit comments

Comments
 (0)