t9001: refactor sendmail aliases test infrastructure
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Eric Sunshine committed
May 31, 2015 at 18:29 UTC
514554cf53757298f948e3b53ddb55f7c922bfa1
1 file changed
+29
-18
t/t9001-send-email.sh
+29
-18
@@ -1549,10 +1549,35 @@ test_expect_success $PREREQ 'sendemail.aliasfile=~/.mailrc' '
1549
grep "^!someone@example\.org!$" commandline1
1550
'
1551
1552
-test_expect_success $PREREQ 'sendemail.aliasfiletype=sendmail' '
1553
- clean_fake_sendmail && rm -fr outdir &&
1554
- git format-patch -1 -o outdir &&
1555
- cat >>.tmp-email-aliases <<-\EOF &&
1552
+test_sendmail_aliases () {
1553
+ msg="$1" && shift &&
1554
+ expect="$@" &&
1555
+ cat >.tmp-email-aliases &&
1556
+
1557
+ test_expect_success $PREREQ "$msg" '
1558
+ clean_fake_sendmail && rm -fr outdir &&
1559
+ git format-patch -1 -o outdir &&
1560
+ git config --replace-all sendemail.aliasesfile \
1561
+ "$(pwd)/.tmp-email-aliases" &&
1562
+ git config sendemail.aliasfiletype sendmail &&
1563
+ git send-email \
1564
+ --from="Example <nobody@example.com>" \
1565
+ --to=alice --to=bcgrp \
1566
+ --smtp-server="$(pwd)/fake.sendmail" \
1567
+ outdir/0001-*.patch \
1568
+ 2>errors >out &&
1569
+ for i in $expect
1570
+ do
1571
+ grep "^!$i!$" commandline1 || return 1
1572
+ done
1573
+ '
1574
+}
1575
+
1576
+test_sendmail_aliases 'sendemail.aliasfiletype=sendmail' \
1577
+ 'awol@example\.com' \
1578
+ 'bob@example\.com' \
1579
+ 'chloe@example\.com' \
1580
+ 'o@example\.com' <<-\EOF
1581
alice: Alice W Land <awol@example.com>
1582
bob: Robert Bobbyton <bob@example.com>
1583
# this is a comment
@@ -1561,20 +1586,6 @@ test_expect_success $PREREQ 'sendemail.aliasfiletype=sendmail' '
1586
abgroup: alice, bob
1587
bcgrp: bob, chloe, Other <o@example.com>
1588
EOF
1564
- git config --replace-all sendemail.aliasesfile \
1565
- "$(pwd)/.tmp-email-aliases" &&
1566
- git config sendemail.aliasfiletype sendmail &&
1567
- git send-email \
1568
- --from="Example <nobody@example.com>" \
1569
- --to=alice --to=bcgrp \
1570
- --smtp-server="$(pwd)/fake.sendmail" \
1571
- outdir/0001-*.patch \
1572
- 2>errors >out &&
1573
- grep "^!awol@example\.com!$" commandline1 &&
1574
- grep "^!bob@example\.com!$" commandline1 &&
1575
- grep "^!chloe@example\.com!$" commandline1 &&
1576
- grep "^!o@example\.com!$" commandline1
1577
-'
1589
1590
do_xmailer_test () {
1591
expected=$1 params=$2 &&