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

[PATCH 8/9] t9001: refactor sendmail aliases test infrastructure

From
Eric Sunshine <sunshine@sunshineco.com>
Date
May 31, 2015, 22:29 UTC
Message-ID
<1433111371-19573-9-git-send-email-sunshine@sunshineco.com>
In-Reply-To
<1433111371-19573-1-git-send-email-sunshine@sunshineco.com>

Several new tests of sendmail aliases parsing will be added in a subsequent patch, so factor out functionality common to all of them into a new helper function.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---
 t/t9001-send-email.sh | 47 +++++++++++++++++++++++++++++------------------
 1 file changed, 29 insertions(+), 18 deletions(-)
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index a3663da..1012fa3 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -1549,10 +1549,35 @@ test_expect_success $PREREQ 'sendemail.aliasfile=~/.mailrc' '
 	grep "^!someone@example\.org!$" commandline1
 '
 
-test_expect_success $PREREQ 'sendemail.aliasfiletype=sendmail' '
-	clean_fake_sendmail && rm -fr outdir &&
-	git format-patch -1 -o outdir &&
-	cat >>.tmp-email-aliases <<-\EOF &&
+test_sendmail_aliases () {
+	msg="$1" && shift &&
+	expect="$@" &&
+	cat >.tmp-email-aliases &&
+
+	test_expect_success $PREREQ "$msg" '
+		clean_fake_sendmail && rm -fr outdir &&
+		git format-patch -1 -o outdir &&
+		git config --replace-all sendemail.aliasesfile \
+			"$(pwd)/.tmp-email-aliases" &&
+		git config sendemail.aliasfiletype sendmail &&
+		git send-email \
+			--from="Example <nobody@example.com>" \
+			--to=alice --to=bcgrp \
+			--smtp-server="$(pwd)/fake.sendmail" \
+			outdir/0001-*.patch \
+			2>errors >out &&
+		for i in $expect
+		do
+			grep "^!$i!$" commandline1 || return 1
+		done
+	'
+}
+
+test_sendmail_aliases 'sendemail.aliasfiletype=sendmail' \
+	'awol@example\.com' \
+	'bob@example\.com' \
+	'chloe@example\.com' \
+	'o@example\.com' <<-\EOF
 	alice: Alice W Land <awol@example.com>
 	bob: Robert Bobbyton <bob@example.com>
 	# this is a comment
@@ -1561,20 +1586,6 @@ test_expect_success $PREREQ 'sendemail.aliasfiletype=sendmail' '
 	abgroup: alice, bob
 	bcgrp: bob, chloe, Other <o@example.com>
 	EOF
-	git config --replace-all sendemail.aliasesfile \
-		"$(pwd)/.tmp-email-aliases" &&
-	git config sendemail.aliasfiletype sendmail &&
-	git send-email \
-		--from="Example <nobody@example.com>" \
-		--to=alice --to=bcgrp \
-		--smtp-server="$(pwd)/fake.sendmail" \
-		outdir/0001-*.patch \
-		2>errors >out &&
-	grep "^!awol@example\.com!$" commandline1 &&
-	grep "^!bob@example\.com!$" commandline1 &&
-	grep "^!chloe@example\.com!$" commandline1 &&
-	grep "^!o@example\.com!$" commandline1
-'
 
 do_xmailer_test () {
 	expected=$1 params=$2 &&
-- 
2.4.2.538.g5f4350e
Previous: Eric SunshineNext: Eric Sunshine
Message 13 of 15 in “send-email: add sendmail aliases line continuation support”
  1. 0/9 send-email: add sendmail aliases line continuation supportEric Sunshine, May 31, 2015
  2. 1/9 send-email: further document missing sendmail aliases functionalityEric Sunshine, May 31, 2015
  3. Allen HubbeJun 1, 2015
  4. Eric SunshineJun 1, 2015
  5. Allen HubbeJun 1, 2015
  6. 2/9 send-email: visually distinguish sendmail aliases parser warningsEric Sunshine, May 31, 2015
  7. 3/9 send-email: drop noise comments which merely repeat what code saysEric Sunshine, May 31, 2015
  8. 4/9 send-email: fix style: cuddle 'elsif' and 'else' with closing braceEric Sunshine, May 31, 2015
  9. 5/9 send-email: refactor sendmail aliases parserEric Sunshine, May 31, 2015
  10. 6/9 send-email: simplify sendmail aliases comment and blank line recognizerEric Sunshine, May 31, 2015
  11. Eric SunshineJun 1, 2015
  12. 7/9 send-email: implement sendmail aliases line continuation supportEric Sunshine, May 31, 2015
  13. 8/9 t9001: refactor sendmail aliases test infrastructureEric Sunshine, May 31, 2015
  14. 9/9 t9001: add sendmail aliases line continuation testsEric Sunshine, May 31, 2015
  15. Allen HubbeJun 1, 2015

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.