diff options
Diffstat (limited to 't/t9001-send-email.sh')
| -rwxr-xr-x | t/t9001-send-email.sh | 72 |
1 files changed, 66 insertions, 6 deletions
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index a60b05ad3f..5a771000c9 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -61,8 +61,8 @@ test_no_confirm () { --smtp-server="$(pwd)/fake.sendmail" \ $@ \ $patches >stdout && - ! grep "Send this email" stdout && - >no_confirm_okay + ! grep "Send this email" stdout && + >no_confirm_okay } # Exit immediately to prevent hang if a no-confirm test fails @@ -371,7 +371,7 @@ test_expect_success $PREREQ,!AUTOIDENT 'broken implicit ident aborts send-email' --smtp-server="$(pwd)/fake.sendmail" \ --to=to@example.com \ $patches </dev/null 2>errors && - test_i18ngrep "tell me who you are" errors + test_grep "tell me who you are" errors ) ' @@ -633,6 +633,25 @@ test_expect_success $PREREQ "--validate respects absolute core.hooksPath path" ' test_cmp expect actual ' +test_expect_success $PREREQ "--validate hook supports multiple addresses in arguments" ' + hooks_path="$(pwd)/my-hooks" && + test_config core.hooksPath "$hooks_path" && + test_when_finished "rm my-hooks.ran" && + test_must_fail git send-email \ + --from="Example <nobody@example.com>" \ + --to=nobody@example.com,abc@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + --validate \ + longline.patch 2>actual && + test_path_is_file my-hooks.ran && + cat >expect <<-EOF && + fatal: longline.patch: rejected by sendemail-validate hook + fatal: command '"'"'git hook run --ignore-missing sendemail-validate -- <patch> <header>'"'"' died with exit code 1 + warning: no patches were sent + EOF + test_cmp expect actual +' + test_expect_success $PREREQ "--validate hook supports header argument" ' write_script my-hooks/sendemail-validate <<-\EOF && if test "$#" -ge 2 @@ -2062,7 +2081,7 @@ test_expect_success $PREREQ 'aliases and sendemail.identity' ' -c sendemail.aliasesfile=default-aliases \ -c sendemail.cloud.aliasesfile=cloud-aliases \ send-email -1 2>stderr && - test_i18ngrep "cloud-aliases" stderr + test_grep "cloud-aliases" stderr ' test_sendmail_aliases () { @@ -2427,7 +2446,7 @@ test_expect_success $PREREQ 'invoke hook' ' --to=nobody@example.com \ --smtp-server="$(pwd)/../fake.sendmail" \ ../another.patch 2>err && - test_i18ngrep "rejected by sendemail-validate hook" err + test_grep "rejected by sendemail-validate hook" err ) ' @@ -2483,7 +2502,7 @@ test_expect_success $PREREQ 'test that sendmail config is rejected' ' --to=nobody@example.com \ --smtp-server="$(pwd)/fake.sendmail" \ HEAD^ 2>err && - test_i18ngrep "found configuration options for '"'"sendmail"'"'" err + test_grep "found configuration options for '"'"sendmail"'"'" err ' test_expect_success $PREREQ 'test that sendmail config rejection is specific' ' @@ -2505,4 +2524,45 @@ test_expect_success $PREREQ 'test forbidSendmailVariables behavior override' ' HEAD^ ' +test_expect_success $PREREQ '--compose handles lowercase headers' ' + write_script fake-editor <<-\EOF && + sed "s/^From:.*/from: edited-from@example.com/i" "$1" >"$1.tmp" && + mv "$1.tmp" "$1" + EOF + clean_fake_sendmail && + git send-email \ + --compose \ + --from="Example <from@example.com>" \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + HEAD^ && + grep "From: edited-from@example.com" msgtxt1 +' + +test_expect_success $PREREQ '--compose handles to headers' ' + write_script fake-editor <<-\EOF && + sed "s/^To: .*/&, edited-to@example.com/" <"$1" >"$1.tmp" && + echo this is the body >>"$1.tmp" && + mv "$1.tmp" "$1" + EOF + clean_fake_sendmail && + GIT_SEND_EMAIL_NOTTY=1 \ + git send-email \ + --compose \ + --from="Example <from@example.com>" \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + HEAD^ && + # Check both that the cover letter used our modified "to" line, + # but also that it was picked up for the patch. + q_to_tab >expect <<-\EOF && + To: nobody@example.com, + Qedited-to@example.com + EOF + grep -A1 "^To:" msgtxt1 >msgtxt1.to && + test_cmp expect msgtxt1.to && + grep -A1 "^To:" msgtxt2 >msgtxt2.to && + test_cmp expect msgtxt2.to +' + test_done |
