t/t9001-send-email.sh: convert setup code to tests
Change the setup code in t/t9001-send-email.sh to use test_expect_success. This way it isn't needlessly run in environments where the test prerequisites aren't met. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ævar Arnfjörð Bjarmason committed
Aug 13, 2010 at 20:40 UTC
f9444147fa4f5f4c2e3eb4980c762844f4b39f87
1 file changed
+40
-3
t/t9001-send-email.sh
+40
-3
@@ -85,12 +85,15 @@ test_expect_success $PREREQ 'Send patches' '
85
git send-email --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors
86
'
87
88
+test_expect_success $PREREQ 'setup expect' '
89
cat >expected <<\EOF
90
!nobody@example.com!
91
!author@example.com!
92
!one@example.com!
93
!two@example.com!
94
EOF
95
+'
96
+
97
test_expect_success $PREREQ \
98
'Verify commandline' \
99
'test_cmp expected commandline1'
@@ -100,6 +103,7 @@ test_expect_success $PREREQ 'Send patches with --envelope-sender' '
103
git send-email --envelope-sender="Patch Contributer <patch@example.com>" --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors
104
'
105
106
+test_expect_success $PREREQ 'setup expect' '
107
cat >expected <<\EOF
108
!patch@example.com!
109
!-i!
@@ -108,6 +112,8 @@ cat >expected <<\EOF
112
!one@example.com!
113
!two@example.com!
114
EOF
115
+'
116
+
117
test_expect_success $PREREQ \
118
'Verify commandline' \
119
'test_cmp expected commandline1'
@@ -117,6 +123,7 @@ test_expect_success $PREREQ 'Send patches with --envelope-sender=auto' '
123
git send-email --envelope-sender=auto --suppress-cc=sob --from="Example <nobody@example.com>" --to=nobody@example.com --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors
124
'
125
126
+test_expect_success $PREREQ 'setup expect' '
127
cat >expected <<\EOF
128
!nobody@example.com!
129
!-i!
@@ -125,10 +132,13 @@ cat >expected <<\EOF
132
!one@example.com!
133
!two@example.com!
134
EOF
135
+'
136
+
137
test_expect_success $PREREQ \
138
'Verify commandline' \
139
'test_cmp expected commandline1'
140
141
+test_expect_success $PREREQ 'setup expect' "
142
cat >expected-show-all-headers <<\EOF
143
0001-Second.patch
144
(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
@@ -158,6 +168,7 @@ References: <unique-message-id@example.com>
168
169
Result: OK
170
EOF
171
+"
172
173
test_expect_success $PREREQ 'Show all headers' '
174
git send-email \
@@ -209,10 +220,10 @@ test_expect_success $PREREQ 'cccmd works' '
220
grep "^ cccmd@example.com" msgtxt1
221
'
222
212
-z8=zzzzzzzz
213
-z64=$z8$z8$z8$z8$z8$z8$z8$z8
214
-z512=$z64$z64$z64$z64$z64$z64$z64$z64
223
test_expect_success $PREREQ 'reject long lines' '
224
+ z8=zzzzzzzz &&
225
+ z64=$z8$z8$z8$z8$z8$z8$z8$z8 &&
226
+ z512=$z64$z64$z64$z64$z64$z64$z64$z64 &&
227
clean_fake_sendmail &&
228
cp $patches longline.patch &&
229
echo $z512$z512 >>longline.patch &&
@@ -312,6 +323,7 @@ test_expect_success $PREREQ 'second message is patch' '
323
grep "Subject:.*Second" msgtxt2
324
'
325
326
+test_expect_success $PREREQ 'setup expect' "
327
cat >expected-suppress-sob <<\EOF
328
0001-Second.patch
329
(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
@@ -338,6 +350,7 @@ X-Mailer: X-MAILER-STRING
350
351
Result: OK
352
EOF
353
+"
354
355
test_suppression () {
356
git send-email \
@@ -359,6 +372,7 @@ test_expect_success $PREREQ 'sendemail.cc set' '
372
test_suppression sob
373
'
374
375
+test_expect_success $PREREQ 'setup expect' "
376
cat >expected-suppress-sob <<\EOF
377
0001-Second.patch
378
(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
@@ -383,12 +397,14 @@ X-Mailer: X-MAILER-STRING
397
398
Result: OK
399
EOF
400
+"
401
402
test_expect_success $PREREQ 'sendemail.cc unset' '
403
git config --unset sendemail.cc &&
404
test_suppression sob
405
'
406
407
+test_expect_success $PREREQ 'setup expect' "
408
cat >expected-suppress-cccmd <<\EOF
409
0001-Second.patch
410
(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
@@ -416,6 +432,7 @@ X-Mailer: X-MAILER-STRING
432
433
Result: OK
434
EOF
435
+"
436
437
test_expect_success $PREREQ 'sendemail.cccmd' '
438
echo echo cc-cmd@example.com > cccmd &&
@@ -424,6 +441,7 @@ test_expect_success $PREREQ 'sendemail.cccmd' '
441
test_suppression cccmd
442
'
443
444
+test_expect_success $PREREQ 'setup expect' '
445
cat >expected-suppress-all <<\EOF
446
0001-Second.patch
447
Dry-OK. Log says:
@@ -439,11 +457,13 @@ X-Mailer: X-MAILER-STRING
457
458
Result: OK
459
EOF
460
+'
461
462
test_expect_success $PREREQ '--suppress-cc=all' '
463
test_suppression all
464
'
465
466
+test_expect_success $PREREQ 'setup expect' "
467
cat >expected-suppress-body <<\EOF
468
0001-Second.patch
469
(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
@@ -471,11 +491,13 @@ X-Mailer: X-MAILER-STRING
491
492
Result: OK
493
EOF
494
+"
495
496
test_expect_success $PREREQ '--suppress-cc=body' '
497
test_suppression body
498
'
499
500
+test_expect_success $PREREQ 'setup expect' "
501
cat >expected-suppress-body-cccmd <<\EOF
502
0001-Second.patch
503
(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
@@ -500,11 +522,13 @@ X-Mailer: X-MAILER-STRING
522
523
Result: OK
524
EOF
525
+"
526
527
test_expect_success $PREREQ '--suppress-cc=body --suppress-cc=cccmd' '
528
test_suppression body cccmd
529
'
530
531
+test_expect_success $PREREQ 'setup expect' "
532
cat >expected-suppress-sob <<\EOF
533
0001-Second.patch
534
(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
@@ -529,12 +553,14 @@ X-Mailer: X-MAILER-STRING
553
554
Result: OK
555
EOF
556
+"
557
558
test_expect_success $PREREQ '--suppress-cc=sob' '
559
git config --unset sendemail.cccmd
560
test_suppression sob
561
'
562
563
+test_expect_success $PREREQ 'setup expect' "
564
cat >expected-suppress-bodycc <<\EOF
565
0001-Second.patch
566
(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
@@ -562,11 +588,13 @@ X-Mailer: X-MAILER-STRING
588
589
Result: OK
590
EOF
591
+"
592
593
test_expect_success $PREREQ '--suppress-cc=bodycc' '
594
test_suppression bodycc
595
'
596
597
+test_expect_success $PREREQ 'setup expect' "
598
cat >expected-suppress-cc <<\EOF
599
0001-Second.patch
600
(mbox) Adding cc: A <author@example.com> from line 'From: A <author@example.com>'
@@ -588,6 +616,7 @@ X-Mailer: X-MAILER-STRING
616
617
Result: OK
618
EOF
619
+"
620
621
test_expect_success $PREREQ '--suppress-cc=cc' '
622
test_suppression cc
@@ -918,6 +947,7 @@ test_expect_success $PREREQ '--no-bcc overrides sendemail.bcc' '
947
! grep "RCPT TO:<other@ex.com>" stdout
948
'
949
950
+test_expect_success $PREREQ 'setup expect' '
951
cat >email-using-8bit <<EOF
952
From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
953
Message-Id: <bogus-message-id@example.com>
@@ -927,12 +957,15 @@ Subject: subject goes here
957
958
Dieser deutsche Text enthält einen Umlaut!
959
EOF
960
+'
961
962
+test_expect_success $PREREQ 'setup expect' '
963
cat >content-type-decl <<EOF
964
MIME-Version: 1.0
965
Content-Type: text/plain; charset=UTF-8
966
Content-Transfer-Encoding: 8bit
967
EOF
968
+'
969
970
test_expect_success $PREREQ 'asks about and fixes 8bit encodings' '
971
clean_fake_sendmail &&
@@ -970,6 +1003,7 @@ test_expect_success $PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' '
1003
test_cmp actual content-type-decl
1004
'
1005
1006
+test_expect_success $PREREQ 'setup expect' '
1007
cat >email-using-8bit <<EOF
1008
From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
1009
Message-Id: <bogus-message-id@example.com>
@@ -979,10 +1013,13 @@ Subject: Dieser Betreff enthält auch einen Umlaut!
1013
1014
Nothing to see here.
1015
EOF
1016
+'
1017
1018
+test_expect_success $PREREQ 'setup expect' '
1019
cat >expected <<EOF
1020
Subject: =?UTF-8?q?Dieser=20Betreff=20enth=C3=A4lt=20auch=20einen=20Umlaut!?=
1021
EOF
1022
+'
1023
1024
test_expect_success $PREREQ '--8bit-encoding also treats subject' '
1025
clean_fake_sendmail &&