summaryrefslogtreecommitdiff
path: root/t/t9001-send-email.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/t9001-send-email.sh')
-rwxr-xr-xt/t9001-send-email.sh84
1 files changed, 77 insertions, 7 deletions
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index f756980..19601fb 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -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
}
@@ -155,6 +155,7 @@ cat >expected-cc <<\EOF
!three@example.com!
!four@example.com!
!five@example.com!
+!six@example.com!
EOF
"
@@ -165,9 +166,11 @@ test_expect_success $PREREQ 'cc trailer with various syntax' '
Test Cc: trailers.
Cc: one@example.com
- Cc: <two@example.com> # this is part of the name
- Cc: <three@example.com>, <four@example.com> # not.five@example.com
- Cc: "Some # Body" <five@example.com> [part.of.name.too]
+ Cc: <two@example.com> # trailing comments are ignored
+ Cc: <three@example.com>, <not.four@example.com> one address per line
+ Cc: "Some # Body" <four@example.com> [ <also.a.comment> ]
+ 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 \
@@ -175,6 +178,25 @@ test_expect_success $PREREQ 'cc trailer with various syntax' '
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 <one@example.com> (supporter:THIS (FOO/bar))'
+ echo 'Two Person <two@example.com> (maintainer:THIS THING)'
+ echo 'Third List <three@example.com> (moderated list:THIS THING (FOO/bar))'
+ echo '<four@example.com> (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
@@ -1260,7 +1282,7 @@ test_expect_success $PREREQ 'asks about and fixes 8bit encodings' '
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' '
@@ -1271,7 +1293,7 @@ test_expect_success $PREREQ 'sendemail.8bitEncoding works' '
--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' '
@@ -1283,7 +1305,7 @@ test_expect_success $PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' '
--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' '
@@ -1911,4 +1933,52 @@ test_expect_success $PREREQ 'leading and trailing whitespaces are removed' '
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 <nobody@example.com>" \
+ --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 <nobody@example.com>" \
+ --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 <nobody@example.com>" \
+ --to=nobody@example.com \
+ --smtp-server="$(pwd)/fake.sendmail" \
+ "$(pwd)/0001-add-master.patch"
+'
+
test_done