@matheusbsbs / matheus-bagliano / commits / 6d34a2bad1
Fork 0

t9001: enhance fake sendmail test harness

Previously, the fake.sendmail test harness would write its output to a hardcoded file, allowing only a single message to be tested. Instead, let's have it save the messages for all of its invocations so that we can see which messages were sent, and in which order. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Feb 24, 2008 at 16:03 UTC 6d34a2bad11f241e56423511d4a0d62a1f378668
1 file changed +15 -7
t/t9001-send-email.sh
+15 -7
@@ -15,16 +15,22 @@ test_expect_success \
15 'Setup helper tool' \
16 '(echo "#!/bin/sh"
17 echo shift
18 + echo output=1
19 + echo "while test -f commandline\$output; do output=\$((\$output+1)); done"
20 echo for a
21 echo do
22 echo " echo \"!\$a!\""
21 - echo "done >commandline"
22 - echo "cat > msgtxt"
23 + echo "done >commandline\$output"
24 + echo "cat > msgtxt\$output"
25 ) >fake.sendmail &&
26 chmod +x ./fake.sendmail &&
27 git add fake.sendmail &&
28 GIT_AUTHOR_NAME="A" git commit -a -m "Second."'
29
30 +clean_fake_sendmail() {
31 + rm -f commandline* msgtxt*
32 +}
33 +
34 test_expect_success 'Extract patches' '
35 patches=`git format-patch -n HEAD^1`
36 '
@@ -39,7 +45,7 @@ cat >expected <<\EOF
45 EOF
46 test_expect_success \
47 'Verify commandline' \
42 - 'diff commandline expected'
48 + 'diff commandline1 expected'
49
50 cat >expected-show-all-headers <<\EOF
51 0001-Second.patch
@@ -82,7 +88,7 @@ z8=zzzzzzzz
88 z64=$z8$z8$z8$z8$z8$z8$z8$z8
89 z512=$z64$z64$z64$z64$z64$z64$z64$z64
90 test_expect_success 'reject long lines' '
85 - rm -f commandline &&
91 + clean_fake_sendmail &&
92 cp $patches longline.patch &&
93 echo $z512$z512 >>longline.patch &&
94 ! git send-email \
@@ -95,7 +101,7 @@ test_expect_success 'reject long lines' '
101 '
102
103 test_expect_success 'no patch was sent' '
98 - ! test -e commandline
104 + ! test -e commandline1
105 '
106
107 test_expect_success 'allow long lines with --no-validate' '
@@ -109,6 +115,7 @@ test_expect_success 'allow long lines with --no-validate' '
115 '
116
117 test_expect_success 'Invalid In-Reply-To' '
118 + clean_fake_sendmail &&
119 git send-email \
120 --from="Example <nobody@example.com>" \
121 --to=nobody@example.com \
@@ -116,17 +123,18 @@ test_expect_success 'Invalid In-Reply-To' '
123 --smtp-server="$(pwd)/fake.sendmail" \
124 $patches
125 2>errors
119 - ! grep "^In-Reply-To: < *>" msgtxt
126 + ! grep "^In-Reply-To: < *>" msgtxt1
127 '
128
129 test_expect_success 'Valid In-Reply-To when prompting' '
130 + clean_fake_sendmail &&
131 (echo "From Example <from@example.com>"
132 echo "To Example <to@example.com>"
133 echo ""
134 ) | env GIT_SEND_EMAIL_NOTTY=1 git send-email \
135 --smtp-server="$(pwd)/fake.sendmail" \
136 $patches 2>errors &&
129 - ! grep "^In-Reply-To: < *>" msgtxt
137 + ! grep "^In-Reply-To: < *>" msgtxt1
138 '
139
140 test_done