diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2021-01-12 21:17:51 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-01-12 14:04:40 -0800 |
commit | 1db421ab85c44c46f6908eb03d1459d636e2b959 (patch) | |
tree | b0e0e97405a13954fe5b425f3ada24d992caec40 | |
parent | mailmap tests: modernize syntax & test idioms (diff) | |
download | tgif-1db421ab85c44c46f6908eb03d1459d636e2b959.tar.xz |
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>
-rwxr-xr-x | t/t4203-mailmap.sh | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh index 61d1b62317..dbd365681e 100755 --- a/t/t4203-mailmap.sh +++ b/t/t4203-mailmap.sh @@ -13,11 +13,6 @@ fuzz_blame () { } test_expect_success 'setup commits and contacts file' ' - cat >contacts <<-EOF && - $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> - nick1 <bugs@company.xx> - EOF - echo one >one && git add one && test_tick && @@ -48,24 +43,53 @@ test_expect_success 'check-mailmap --stdin' ' $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> nick1 <bugs@company.xx> EOF - git check-mailmap --stdin <contacts >actual && + git check-mailmap --stdin <expect >actual && test_cmp expect actual ' -test_expect_success 'check-mailmap --stdin arguments' ' +test_expect_success 'check-mailmap --stdin arguments: no mapping' ' + test_when_finished "rm contacts" && + cat >contacts <<-EOF && + $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> + nick1 <bugs@company.xx> + EOF cat >expect <<-\EOF && Internal Guy <bugs@company.xy> EOF - cat <contacts >>expect && + cat contacts >>expect && + git check-mailmap --stdin "Internal Guy <bugs@company.xy>" \ <contacts >actual && test_cmp expect actual ' +test_expect_success 'check-mailmap --stdin arguments: mapping' ' + test_when_finished "rm .mailmap" && + cat >.mailmap <<-EOF && + New Name <$GIT_AUTHOR_EMAIL> + EOF + cat >stdin <<-EOF && + Old Name <$GIT_AUTHOR_EMAIL> + EOF + + cp .mailmap expect && + git check-mailmap --stdin <stdin >actual && + test_cmp expect actual && + + cat .mailmap >>expect && + git check-mailmap --stdin "Another Old Name <$GIT_AUTHOR_EMAIL>" \ + <stdin >actual && + test_cmp expect actual +' + test_expect_success 'check-mailmap bogus contact' ' test_must_fail git check-mailmap bogus ' +test_expect_success 'check-mailmap bogus contact --stdin' ' + test_must_fail git check-mailmap --stdin bogus </dev/null +' + test_expect_success 'No mailmap' ' cat >expect <<-EOF && $GIT_AUTHOR_NAME (1): |