git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/3] send-email: test compose functionality

From
Jeff King <peff@peff.net>
Date
Jan 22, 2008, 03:29 UTC
Message-ID
<20080122032905.GD24758@coredump.intra.peff.net>
In-Reply-To
<20080122032544.GC24758@coredump.intra.peff.net>

This is just a basic sanity check that --compose works at all. Unfortunately, we have to add a --no-confirm-send option to git-send-email to make this work, since it otherwise unconditionally tries to talk to the terminal.

Signed-off-by: Jeff King <peff@peff.net>
---
Note that the change to git-send-email depends textually on Gustaf's
fix (actually, on my suggested version). I am not happy with adding the
--no-confirm-send option, but there just isn't any way to avoid the
readline call with the existing code short of providing a dummy perl
module in the test harness.
 git-send-email.perl   |   16 ++++++++++------
 t/t9001-send-email.sh |   27 +++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 6 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index df1c833..f265a82 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -180,6 +180,7 @@ my ($thread, $chain_reply_to, $suppress_from, $signed_off_cc, $cc_cmd);
 my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_authpass, $smtp_ssl);
 my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts);
 my ($no_validate);
+my ($no_confirm_send);
 
 my %config_bool_settings = (
     "thread" => [\$thread, 1],
@@ -226,6 +227,7 @@ my $rc = GetOptions("sender|from=s" => \$sender,
 		    "envelope-sender=s" => \$envelope_sender,
 		    "thread!" => \$thread,
 		    "no-validate" => \$no_validate,
+		    "no-confirm-send" => \$no_confirm_send,
 	 );
 
 unless ($rc) {
@@ -453,13 +455,15 @@ EOT
 	close(C);
 	close(C2);
 
-	do {
-		$_ = $term->readline("Send this email? (y|n) ");
-	} while (!defined $_);
+	if (!$no_confirm_send) {
+		do {
+			$_ = $term->readline("Send this email? (y|n) ");
+		} while (!defined $_);
 
-	if (uc substr($_,0,1) ne 'Y') {
-		cleanup_compose_files();
-		exit(0);
+		if (uc substr($_,0,1) ne 'Y') {
+			cleanup_compose_files();
+			exit(0);
+		}
 	}
 
 	unshift @files, "$compose_filename.final";
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index dd0c395..b1e9de5 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -114,4 +114,31 @@ test_expect_success 'allow long lines with --no-validate' '
 		2>errors
 '
 
+test_expect_success 'setup fake editor' '
+	(echo "#!/bin/sh" &&
+	 echo "echo fake edit >>\$1"
+	) >fake-editor &&
+	chmod +x fake-editor
+'
+
+test_expect_success '--compose works' '
+	clean_fake_sendmail &&
+	GIT_EDITOR=$(pwd)/fake-editor \
+	git send-email \
+		--compose --subject foo --no-confirm-send \
+		--from="Example <nobody@example.com>" \
+		--to=nobody@example.com \
+		--smtp-server="$(pwd)/fake.sendmail" \
+		$patches \
+		2>errors
+'
+
+test_expect_success 'first message is compose text' '
+	grep "^fake edit" msgtxt1
+'
+
+test_expect_success 'second message is patch' '
+	grep "Subject:.*Second" msgtxt2
+'
+
 test_done
-- 
1.5.4.rc3.1130.gd9718-dirty
Previous: Jeff King
Message 8 of 8 in “git-send-email not sending?”
  1. Seth FalconJan 21, 2008
  2. Test of send-email patchGustaf Hendeby, Jan 21, 2008
  3. send-email, fix breakage in combination with --composeGustaf Hendeby, Jan 21, 2008
  4. Seth FalconJan 22, 2008
  5. Jeff KingJan 22, 2008
  6. 1/3 t9001: add missing && operatorsJeff King, Jan 22, 2008
  7. 2/3 t9001: enhance fake sendmail test harnessJeff King, Jan 22, 2008
  8. 3/3 send-email: test compose functionalityJeff King, Jan 22, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.