From: Junio C Hamano Date: Tue, 13 Feb 2018 21:39:07 +0000 (-0800) Subject: Merge branch 'cl/t9001-cleanup' X-Git-Tag: v2.17.0-rc0~129 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/f5536f1ce200e7e58642846dcf3d4f4122c3a604?ds=inline;hp=-c Merge branch 'cl/t9001-cleanup' Test clean-up. * cl/t9001-cleanup: t9001: use existing helper in send-email test --- f5536f1ce200e7e58642846dcf3d4f4122c3a604 diff --combined t/t9001-send-email.sh index a06e5d7ba5,f75698016f..19601fb546 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@@ -6,6 -6,12 +6,12 @@@ test_description='git send-email # May be altered later in the test PREREQ="PERL" + replace_variable_fields () { + sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \ + -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \ + -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" + } + test_expect_success $PREREQ 'prepare reference tree' ' echo "1A quick brown fox jumps over the" >file && echo "lazy dog" >>file && @@@ -50,7 -56,7 +56,7 @@@ test_no_confirm () --smtp-server="$(pwd)/fake.sendmail" \ $@ \ $patches >stdout && - test_must_fail grep "Send this email" stdout && + ! grep "Send this email" stdout && >no_confirm_okay } @@@ -149,7 -155,6 +155,7 @@@ cat >expected-cc <<\EO !three@example.com! !four@example.com! !five@example.com! +!six@example.com! EOF " @@@ -160,11 -165,9 +166,11 @@@ test_expect_success $PREREQ 'cc traile Test Cc: trailers. Cc: one@example.com - Cc: # this is part of the name - Cc: , # not.five@example.com - Cc: "Some # Body" [part.of.name.too] + Cc: # trailing comments are ignored + Cc: , one address per line + Cc: "Some # Body" [ ] + Cc: five@example.com # not.six@example.com + Cc: six@example.com, not.seven@example.com EOF clean_fake_sendmail && git send-email -1 --to=recipient@example.com \ @@@ -172,25 -175,6 +178,25 @@@ test_cmp expected-cc commandline1 ' +test_expect_success $PREREQ 'setup fake get_maintainer.pl script for cc trailer' " + write_script expected-cc-script.sh <<-EOF + echo 'One Person (supporter:THIS (FOO/bar))' + echo 'Two Person (maintainer:THIS THING)' + echo 'Third List (moderated list:THIS THING (FOO/bar))' + echo ' (moderated list:FOR THING)' + echo 'five@example.com (open list:FOR THING (FOO/bar))' + echo 'six@example.com (open list)' + EOF +" + +test_expect_success $PREREQ 'cc trailer with get_maintainer.pl output' ' + clean_fake_sendmail && + git send-email -1 --to=recipient@example.com \ + --cc-cmd=./expected-cc-script.sh \ + --smtp-server="$(pwd)/fake.sendmail" && + test_cmp expected-cc commandline1 +' + test_expect_success $PREREQ 'setup expect' " cat >expected-show-all-headers <<\EOF 0001-Second.patch @@@ -315,10 -299,7 +321,7 @@@ test_expect_success $PREREQ 'Show all h --bcc=bcc@example.com \ --in-reply-to="" \ --smtp-server relay.example.com \ - $patches | - sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \ - -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \ - -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \ + $patches | replace_variable_fields \ >actual-show-all-headers && test_cmp expected-show-all-headers actual-show-all-headers ' @@@ -573,12 -554,6 +576,6 @@@ Result: O EOF " - replace_variable_fields () { - sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \ - -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \ - -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" - } - test_suppression () { git send-email \ --dry-run \ @@@ -1285,7 -1260,7 +1282,7 @@@ test_expect_success $PREREQ 'asks abou grep email-using-8bit stdout && grep "Which 8bit encoding" stdout && egrep "Content|MIME" msgtxt1 >actual && - test_cmp actual content-type-decl + test_cmp content-type-decl actual ' test_expect_success $PREREQ 'sendemail.8bitEncoding works' ' @@@ -1296,7 -1271,7 +1293,7 @@@ --smtp-server="$(pwd)/fake.sendmail" \ email-using-8bit >stdout && egrep "Content|MIME" msgtxt1 >actual && - test_cmp actual content-type-decl + test_cmp content-type-decl actual ' test_expect_success $PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' ' @@@ -1308,7 -1283,7 +1305,7 @@@ --8bit-encoding=UTF-8 \ email-using-8bit >stdout && egrep "Content|MIME" msgtxt1 >actual && - test_cmp actual content-type-decl + test_cmp content-type-decl actual ' test_expect_success $PREREQ 'setup expect' ' @@@ -1936,52 -1911,4 +1933,52 @@@ test_expect_success $PREREQ 'leading an test_cmp expected-list actual-list ' +test_expect_success $PREREQ 'invoke hook' ' + mkdir -p .git/hooks && + + write_script .git/hooks/sendemail-validate <<-\EOF && + # test that we have the correct environment variable, pwd, and + # argument + case "$GIT_DIR" in + *.git) + true + ;; + *) + false + ;; + esac && + test -f 0001-add-master.patch && + grep "add master" "$1" + EOF + + mkdir subdir && + ( + # Test that it works even if we are not at the root of the + # working tree + cd subdir && + git send-email \ + --from="Example " \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/../fake.sendmail" \ + ../0001-add-master.patch && + + # Verify error message when a patch is rejected by the hook + sed -e "s/add master/x/" ../0001-add-master.patch >../another.patch && + git send-email \ + --from="Example " \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/../fake.sendmail" \ + ../another.patch 2>err + test_i18ngrep "rejected by sendemail-validate hook" err + ) +' + +test_expect_success $PREREQ 'test that send-email works outside a repo' ' + nongit git send-email \ + --from="Example " \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + "$(pwd)/0001-add-master.patch" +' + test_done