From: Junio C Hamano Date: Thu, 22 Mar 2018 21:24:13 +0000 (-0700) Subject: Merge branch 'cl/t9001-cleanup' into maint X-Git-Tag: v2.16.3~22 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/b1bdf46bb886417e13c067bc1f263f2755accd29?ds=inline;hp=-c Merge branch 'cl/t9001-cleanup' into maint Test clean-up. * cl/t9001-cleanup: t9001: use existing helper in send-email test --- b1bdf46bb886417e13c067bc1f263f2755accd29 diff --combined t/t9001-send-email.sh index 4d261c2a9c,f75698016f..81869d8913 --- 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 \ @@@ -296,10 -299,7 +302,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 ' @@@ -554,12 -554,6 +557,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 \ @@@ -1266,7 -1260,7 +1263,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' ' @@@ -1277,7 -1271,7 +1274,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' ' @@@ -1289,7 -1283,7 +1286,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' ' @@@ -1917,52 -1911,4 +1914,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