Skip to content

Commit f944414

Browse files
avargitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 57cd35e commit f944414

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

t/t9001-send-email.sh

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,15 @@ test_expect_success $PREREQ 'Send patches' '
8585
git send-email --suppress-cc=sob --from="Example <[email protected]>" [email protected] --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors
8686
'
8787

88+
test_expect_success $PREREQ 'setup expect' '
8889
cat >expected <<\EOF
8990
9091
9192
9293
9394
EOF
95+
'
96+
9497
test_expect_success $PREREQ \
9598
'Verify commandline' \
9699
'test_cmp expected commandline1'
@@ -100,6 +103,7 @@ test_expect_success $PREREQ 'Send patches with --envelope-sender' '
100103
git send-email --envelope-sender="Patch Contributer <[email protected]>" --suppress-cc=sob --from="Example <[email protected]>" [email protected] --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors
101104
'
102105

106+
test_expect_success $PREREQ 'setup expect' '
103107
cat >expected <<\EOF
104108
105109
!-i!
@@ -108,6 +112,8 @@ cat >expected <<\EOF
108112
109113
110114
EOF
115+
'
116+
111117
test_expect_success $PREREQ \
112118
'Verify commandline' \
113119
'test_cmp expected commandline1'
@@ -117,6 +123,7 @@ test_expect_success $PREREQ 'Send patches with --envelope-sender=auto' '
117123
git send-email --envelope-sender=auto --suppress-cc=sob --from="Example <[email protected]>" [email protected] --smtp-server="$(pwd)/fake.sendmail" $patches 2>errors
118124
'
119125

126+
test_expect_success $PREREQ 'setup expect' '
120127
cat >expected <<\EOF
121128
122129
!-i!
@@ -125,10 +132,13 @@ cat >expected <<\EOF
125132
126133
127134
EOF
135+
'
136+
128137
test_expect_success $PREREQ \
129138
'Verify commandline' \
130139
'test_cmp expected commandline1'
131140

141+
test_expect_success $PREREQ 'setup expect' "
132142
cat >expected-show-all-headers <<\EOF
133143
0001-Second.patch
134144
(mbox) Adding cc: A <[email protected]> from line 'From: A <[email protected]>'
@@ -158,6 +168,7 @@ References: <[email protected]>
158168
159169
Result: OK
160170
EOF
171+
"
161172

162173
test_expect_success $PREREQ 'Show all headers' '
163174
git send-email \
@@ -209,10 +220,10 @@ test_expect_success $PREREQ 'cccmd works' '
209220
grep "^ [email protected]" msgtxt1
210221
'
211222

212-
z8=zzzzzzzz
213-
z64=$z8$z8$z8$z8$z8$z8$z8$z8
214-
z512=$z64$z64$z64$z64$z64$z64$z64$z64
215223
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 &&
216227
clean_fake_sendmail &&
217228
cp $patches longline.patch &&
218229
echo $z512$z512 >>longline.patch &&
@@ -312,6 +323,7 @@ test_expect_success $PREREQ 'second message is patch' '
312323
grep "Subject:.*Second" msgtxt2
313324
'
314325

326+
test_expect_success $PREREQ 'setup expect' "
315327
cat >expected-suppress-sob <<\EOF
316328
0001-Second.patch
317329
(mbox) Adding cc: A <[email protected]> from line 'From: A <[email protected]>'
@@ -338,6 +350,7 @@ X-Mailer: X-MAILER-STRING
338350
339351
Result: OK
340352
EOF
353+
"
341354

342355
test_suppression () {
343356
git send-email \
@@ -359,6 +372,7 @@ test_expect_success $PREREQ 'sendemail.cc set' '
359372
test_suppression sob
360373
'
361374

375+
test_expect_success $PREREQ 'setup expect' "
362376
cat >expected-suppress-sob <<\EOF
363377
0001-Second.patch
364378
(mbox) Adding cc: A <[email protected]> from line 'From: A <[email protected]>'
@@ -383,12 +397,14 @@ X-Mailer: X-MAILER-STRING
383397
384398
Result: OK
385399
EOF
400+
"
386401

387402
test_expect_success $PREREQ 'sendemail.cc unset' '
388403
git config --unset sendemail.cc &&
389404
test_suppression sob
390405
'
391406

407+
test_expect_success $PREREQ 'setup expect' "
392408
cat >expected-suppress-cccmd <<\EOF
393409
0001-Second.patch
394410
(mbox) Adding cc: A <[email protected]> from line 'From: A <[email protected]>'
@@ -416,6 +432,7 @@ X-Mailer: X-MAILER-STRING
416432
417433
Result: OK
418434
EOF
435+
"
419436

420437
test_expect_success $PREREQ 'sendemail.cccmd' '
421438
echo echo [email protected] > cccmd &&
@@ -424,6 +441,7 @@ test_expect_success $PREREQ 'sendemail.cccmd' '
424441
test_suppression cccmd
425442
'
426443

444+
test_expect_success $PREREQ 'setup expect' '
427445
cat >expected-suppress-all <<\EOF
428446
0001-Second.patch
429447
Dry-OK. Log says:
@@ -439,11 +457,13 @@ X-Mailer: X-MAILER-STRING
439457
440458
Result: OK
441459
EOF
460+
'
442461

443462
test_expect_success $PREREQ '--suppress-cc=all' '
444463
test_suppression all
445464
'
446465

466+
test_expect_success $PREREQ 'setup expect' "
447467
cat >expected-suppress-body <<\EOF
448468
0001-Second.patch
449469
(mbox) Adding cc: A <[email protected]> from line 'From: A <[email protected]>'
@@ -471,11 +491,13 @@ X-Mailer: X-MAILER-STRING
471491
472492
Result: OK
473493
EOF
494+
"
474495

475496
test_expect_success $PREREQ '--suppress-cc=body' '
476497
test_suppression body
477498
'
478499

500+
test_expect_success $PREREQ 'setup expect' "
479501
cat >expected-suppress-body-cccmd <<\EOF
480502
0001-Second.patch
481503
(mbox) Adding cc: A <[email protected]> from line 'From: A <[email protected]>'
@@ -500,11 +522,13 @@ X-Mailer: X-MAILER-STRING
500522
501523
Result: OK
502524
EOF
525+
"
503526

504527
test_expect_success $PREREQ '--suppress-cc=body --suppress-cc=cccmd' '
505528
test_suppression body cccmd
506529
'
507530

531+
test_expect_success $PREREQ 'setup expect' "
508532
cat >expected-suppress-sob <<\EOF
509533
0001-Second.patch
510534
(mbox) Adding cc: A <[email protected]> from line 'From: A <[email protected]>'
@@ -529,12 +553,14 @@ X-Mailer: X-MAILER-STRING
529553
530554
Result: OK
531555
EOF
556+
"
532557

533558
test_expect_success $PREREQ '--suppress-cc=sob' '
534559
git config --unset sendemail.cccmd
535560
test_suppression sob
536561
'
537562

563+
test_expect_success $PREREQ 'setup expect' "
538564
cat >expected-suppress-bodycc <<\EOF
539565
0001-Second.patch
540566
(mbox) Adding cc: A <[email protected]> from line 'From: A <[email protected]>'
@@ -562,11 +588,13 @@ X-Mailer: X-MAILER-STRING
562588
563589
Result: OK
564590
EOF
591+
"
565592

566593
test_expect_success $PREREQ '--suppress-cc=bodycc' '
567594
test_suppression bodycc
568595
'
569596

597+
test_expect_success $PREREQ 'setup expect' "
570598
cat >expected-suppress-cc <<\EOF
571599
0001-Second.patch
572600
(mbox) Adding cc: A <[email protected]> from line 'From: A <[email protected]>'
@@ -588,6 +616,7 @@ X-Mailer: X-MAILER-STRING
588616
589617
Result: OK
590618
EOF
619+
"
591620

592621
test_expect_success $PREREQ '--suppress-cc=cc' '
593622
test_suppression cc
@@ -918,6 +947,7 @@ test_expect_success $PREREQ '--no-bcc overrides sendemail.bcc' '
918947
! grep "RCPT TO:<[email protected]>" stdout
919948
'
920949

950+
test_expect_success $PREREQ 'setup expect' '
921951
cat >email-using-8bit <<EOF
922952
From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
923953
Message-Id: <[email protected]>
@@ -927,12 +957,15 @@ Subject: subject goes here
927957
928958
Dieser deutsche Text enthält einen Umlaut!
929959
EOF
960+
'
930961

962+
test_expect_success $PREREQ 'setup expect' '
931963
cat >content-type-decl <<EOF
932964
MIME-Version: 1.0
933965
Content-Type: text/plain; charset=UTF-8
934966
Content-Transfer-Encoding: 8bit
935967
EOF
968+
'
936969

937970
test_expect_success $PREREQ 'asks about and fixes 8bit encodings' '
938971
clean_fake_sendmail &&
@@ -970,6 +1003,7 @@ test_expect_success $PREREQ '--8bit-encoding overrides sendemail.8bitEncoding' '
9701003
test_cmp actual content-type-decl
9711004
'
9721005

1006+
test_expect_success $PREREQ 'setup expect' '
9731007
cat >email-using-8bit <<EOF
9741008
From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
9751009
Message-Id: <[email protected]>
@@ -979,10 +1013,13 @@ Subject: Dieser Betreff enthält auch einen Umlaut!
9791013
9801014
Nothing to see here.
9811015
EOF
1016+
'
9821017

1018+
test_expect_success $PREREQ 'setup expect' '
9831019
cat >expected <<EOF
9841020
Subject: =?UTF-8?q?Dieser=20Betreff=20enth=C3=A4lt=20auch=20einen=20Umlaut!?=
9851021
EOF
1022+
'
9861023

9871024
test_expect_success $PREREQ '--8bit-encoding also treats subject' '
9881025
clean_fake_sendmail &&

0 commit comments

Comments
 (0)