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 <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Jan 12, 2021 at 21:17 UTC 1db421ab85c44c46f6908eb03d1459d636e2b959
1 file changed +32 -8
t/t4203-mailmap.sh
+32 -8
@@ -13,11 +13,6 @@ fuzz_blame () {
13 }
14
15 test_expect_success 'setup commits and contacts file' '
16 - cat >contacts <<-EOF &&
17 - $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
18 - nick1 <bugs@company.xx>
19 - EOF
20 -
16 echo one >one &&
17 git add one &&
18 test_tick &&
@@ -48,24 +43,53 @@ test_expect_success 'check-mailmap --stdin' '
43 $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
44 nick1 <bugs@company.xx>
45 EOF
51 - git check-mailmap --stdin <contacts >actual &&
46 + git check-mailmap --stdin <expect >actual &&
47 test_cmp expect actual
48 '
49
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 + nick1 <bugs@company.xx>
55 + EOF
56 cat >expect <<-\EOF &&
57 Internal Guy <bugs@company.xy>
58 EOF
59 - cat <contacts >>expect &&
59 + cat contacts >>expect &&
60 +
61 git check-mailmap --stdin "Internal Guy <bugs@company.xy>" \
62 <contacts >actual &&
63 test_cmp expect actual
64 '
65
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 +
85 test_expect_success 'check-mailmap bogus contact' '
86 test_must_fail git check-mailmap bogus
87 '
88
89 +test_expect_success 'check-mailmap bogus contact --stdin' '
90 + test_must_fail git check-mailmap --stdin bogus </dev/null
91 +'
92 +
93 test_expect_success 'No mailmap' '
94 cat >expect <<-EOF &&
95 $GIT_AUTHOR_NAME (1):