[PATCH resend] Test cccmd in t9001-send-email.sh and fix two bugs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



For another patch series I'm working on I needed some tests
for the cc-cmd feature of git-send-email.

This patch adds 3 tests for the feature, and fixes two bugs.
The first bug is that the --suppress-cc option for `cccmd' was
misspelled as `ccmd' in the code.  The second bug, which is
actually found only with my other series, is that the argument
to the cccmd is never quoted, so the cccmd would fail with
patch file names containing a space.

I also test the possibility to specify --suppress-cc
multiple times.

Signed-Off-By: Paolo Bonzini  <bonzini@xxxxxxx>
---
 git-send-email.perl   |    4 +-
 t/t9001-send-email.sh |   80 +++++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 77 insertions(+), 7 deletions(-)

	The patch was sent first a week ago with no remarks.

diff --git a/git-send-email.perl b/git-send-email.perl
index 303e03a..7ae1f29 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -334,7 +334,7 @@ if (@suppress_cc) {
 }
 
 if ($suppress_cc{'all'}) {
-	foreach my $entry (qw (ccmd cc author self sob body bodycc)) {
+	foreach my $entry (qw (cccmd cc author self sob body bodyccc)) {
 		$suppress_cc{$entry} = 1;
 	}
 	delete $suppress_cc{'all'};
@@ -1104,7 +1104,7 @@ foreach my $t (@files) {
 	close F;
 
 	if (defined $cc_cmd && !$suppress_cc{'cccmd'}) {
-		open(F, "$cc_cmd $t |")
+		open(F, "$cc_cmd \Q$t\E |")
 			or die "(cc-cmd) Could not execute '$cc_cmd'";
 		while(<F>) {
 			my $c = $_;
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index 9ce04fd..fb7d9f3 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -148,6 +148,22 @@ test_expect_success 'Prompting works' '
 		grep "^To: to@xxxxxxxxxxx$" msgtxt1
 '
 
+test_expect_success 'cccmd works' '
+	clean_fake_sendmail &&
+	cp $patches cccmd.patch &&
+	echo cccmd--cccmd@xxxxxxxxxxx >>cccmd.patch &&
+	echo sed -n s/^cccmd--//p \"\$1\" > cccmd-sed &&
+	chmod +x cccmd-sed &&
+	git send-email \
+		--from="Example <nobody@xxxxxxxxxxx>" \
+		--to=nobody@xxxxxxxxxxx \
+		--cc-cmd=./cccmd-sed \
+		--smtp-server="$(pwd)/fake.sendmail" \
+		cccmd.patch \
+		&&
+	grep ^Cc:.*cccmd@xxxxxxxxxxx msgtxt1
+'
+
 z8=zzzzzzzz
 z64=$z8$z8$z8$z8$z8$z8$z8$z8
 z512=$z64$z64$z64$z64$z64$z64$z64$z64
@@ -274,7 +290,7 @@ EOF
 test_suppression () {
 	git send-email \
 		--dry-run \
-		--suppress-cc=$1 \
+		--suppress-cc=$1 ${2+"--suppress-cc=$2"} \
 		--from="Example <from@xxxxxxxxxxx>" \
 		--to=to@xxxxxxxxxxx \
 		--smtp-server relay.example.com \
@@ -282,8 +298,8 @@ test_suppression () {
 	sed	-e "s/^\(Date:\).*/\1 DATE-STRING/" \
 		-e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \
 		-e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \
-		>actual-suppress-$1 &&
-	test_cmp expected-suppress-$1 actual-suppress-$1
+		>actual-suppress-$1${2+"-$2"} &&
+	test_cmp expected-suppress-$1${2+"-$2"} actual-suppress-$1${2+"-$2"}
 }
 
 test_expect_success 'sendemail.cc set' '
@@ -316,6 +332,34 @@ test_expect_success 'sendemail.cc unset' '
 	test_suppression sob
 '
 
+cat >expected-suppress-cccmd <<\EOF
+0001-Second.patch
+(mbox) Adding cc: A <author@xxxxxxxxxxx> from line 'From: A <author@xxxxxxxxxxx>'
+(mbox) Adding cc: One <one@xxxxxxxxxxx> from line 'Cc: One <one@xxxxxxxxxxx>, two@xxxxxxxxxxx'
+(mbox) Adding cc: two@xxxxxxxxxxx from line 'Cc: One <one@xxxxxxxxxxx>, two@xxxxxxxxxxx'
+(body) Adding cc: C O Mitter <committer@xxxxxxxxxxx> from line 'Signed-off-by: C O Mitter <committer@xxxxxxxxxxx>'
+Dry-OK. Log says:
+Server: relay.example.com
+MAIL FROM:<from@xxxxxxxxxxx>
+RCPT TO:<to@xxxxxxxxxxx>,<author@xxxxxxxxxxx>,<one@xxxxxxxxxxx>,<two@xxxxxxxxxxx>,<committer@xxxxxxxxxxx>
+From: Example <from@xxxxxxxxxxx>
+To: to@xxxxxxxxxxx
+Cc: A <author@xxxxxxxxxxx>, One <one@xxxxxxxxxxx>, two@xxxxxxxxxxx, C O Mitter <committer@xxxxxxxxxxx>
+Subject: [PATCH 1/1] Second.
+Date: DATE-STRING
+Message-Id: MESSAGE-ID-STRING
+X-Mailer: X-MAILER-STRING
+
+Result: OK
+EOF
+
+test_expect_success 'sendemail.cccmd' '
+	echo echo cc-cmd@xxxxxxxxxxx > cccmd &&
+	chmod +x cccmd &&
+	git config sendemail.cccmd ./cccmd &&
+	test_suppression cccmd
+'
+
 cat >expected-suppress-all <<\EOF
 0001-Second.patch
 Dry-OK. Log says:
@@ -341,13 +385,14 @@ cat >expected-suppress-body <<\EOF
 (mbox) Adding cc: A <author@xxxxxxxxxxx> from line 'From: A <author@xxxxxxxxxxx>'
 (mbox) Adding cc: One <one@xxxxxxxxxxx> from line 'Cc: One <one@xxxxxxxxxxx>, two@xxxxxxxxxxx'
 (mbox) Adding cc: two@xxxxxxxxxxx from line 'Cc: One <one@xxxxxxxxxxx>, two@xxxxxxxxxxx'
+(cc-cmd) Adding cc: cc-cmd@xxxxxxxxxxx from: './cccmd'
 Dry-OK. Log says:
 Server: relay.example.com
 MAIL FROM:<from@xxxxxxxxxxx>
-RCPT TO:<to@xxxxxxxxxxx>,<author@xxxxxxxxxxx>,<one@xxxxxxxxxxx>,<two@xxxxxxxxxxx>
+RCPT TO:<to@xxxxxxxxxxx>,<author@xxxxxxxxxxx>,<one@xxxxxxxxxxx>,<two@xxxxxxxxxxx>,<cc-cmd@xxxxxxxxxxx>
 From: Example <from@xxxxxxxxxxx>
 To: to@xxxxxxxxxxx
-Cc: A <author@xxxxxxxxxxx>, One <one@xxxxxxxxxxx>, two@xxxxxxxxxxx
+Cc: A <author@xxxxxxxxxxx>, One <one@xxxxxxxxxxx>, two@xxxxxxxxxxx, cc-cmd@xxxxxxxxxxx
 Subject: [PATCH 1/1] Second.
 Date: DATE-STRING
 Message-Id: MESSAGE-ID-STRING
@@ -360,6 +405,30 @@ test_expect_success '--suppress-cc=body' '
 	test_suppression body
 '
 
+cat >expected-suppress-body-cccmd <<\EOF
+0001-Second.patch
+(mbox) Adding cc: A <author@xxxxxxxxxxx> from line 'From: A <author@xxxxxxxxxxx>'
+(mbox) Adding cc: One <one@xxxxxxxxxxx> from line 'Cc: One <one@xxxxxxxxxxx>, two@xxxxxxxxxxx'
+(mbox) Adding cc: two@xxxxxxxxxxx from line 'Cc: One <one@xxxxxxxxxxx>, two@xxxxxxxxxxx'
+Dry-OK. Log says:
+Server: relay.example.com
+MAIL FROM:<from@xxxxxxxxxxx>
+RCPT TO:<to@xxxxxxxxxxx>,<author@xxxxxxxxxxx>,<one@xxxxxxxxxxx>,<two@xxxxxxxxxxx>
+From: Example <from@xxxxxxxxxxx>
+To: to@xxxxxxxxxxx
+Cc: A <author@xxxxxxxxxxx>, One <one@xxxxxxxxxxx>, two@xxxxxxxxxxx
+Subject: [PATCH 1/1] Second.
+Date: DATE-STRING
+Message-Id: MESSAGE-ID-STRING
+X-Mailer: X-MAILER-STRING
+
+Result: OK
+EOF
+
+test_expect_success '--suppress-cc=body --suppress-cc=cccmd' '
+	test_suppression body cccmd
+'
+
 cat >expected-suppress-sob <<\EOF
 0001-Second.patch
 (mbox) Adding cc: A <author@xxxxxxxxxxx> from line 'From: A <author@xxxxxxxxxxx>'
@@ -381,6 +450,7 @@ Result: OK
 EOF
 
 test_expect_success '--suppress-cc=sob' '
+	git config --unset sendemail.cccmd
 	test_suppression sob
 '
 
-- 
1.6.0.3

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]