| 1 |
#!/bin/sh |
| 2 |
###################################################### |
| 3 |
# |
| 4 |
# Test repl |
| 5 |
# |
| 6 |
###################################################### |
| 7 |
|
| 8 |
# This is not a comprehensive test of repl, but some day it will be :-) |
| 9 |
# Please add to it. |
| 10 |
|
| 11 |
set -e |
| 12 |
|
| 13 |
if test -z "${MH_OBJ_DIR}"; then |
| 14 |
srcdir=`dirname $0`/../.. |
| 15 |
MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR |
| 16 |
fi |
| 17 |
|
| 18 |
. "$MH_OBJ_DIR/test/common.sh" |
| 19 |
|
| 20 |
setup_test |
| 21 |
|
| 22 |
check_exit '-eq 1' repl - |
| 23 |
|
| 24 |
expected=$MH_TEST_DIR/$$.expected |
| 25 |
actual=$MH_TEST_DIR/Mail/draft |
| 26 |
|
| 27 |
|
| 28 |
# check -help |
| 29 |
start_test -help |
| 30 |
cat >$expected <<EOF |
| 31 |
Usage: repl: [+folder] [msg] [switches] |
| 32 |
switches are: |
| 33 |
-[no]group |
| 34 |
-[no]annotate |
| 35 |
-[no]cc all|to|cc|me |
| 36 |
-draftfolder +folder |
| 37 |
-draftmessage msg |
| 38 |
-nodraftfolder |
| 39 |
-editor editor |
| 40 |
-noedit |
| 41 |
-convertargs type argstring |
| 42 |
-fcc folder |
| 43 |
-filter filterfile |
| 44 |
-form formfile |
| 45 |
-([no]forma)t |
| 46 |
-[no]inplace |
| 47 |
-[no]mime |
| 48 |
-[no]query |
| 49 |
-whatnowproc program |
| 50 |
-nowhatnowproc |
| 51 |
-width columns |
| 52 |
-version |
| 53 |
-help |
| 54 |
-(file) file |
| 55 |
-(build) |
| 56 |
-[no]atfile |
| 57 |
-fmtproc program |
| 58 |
-nofmtproc |
| 59 |
EOF |
| 60 |
|
| 61 |
#### Skip nmh intro text. |
| 62 |
run_prog repl -help 2>&1 | sed '/^$/,$d' >"$actual" |
| 63 |
check "$expected" "$actual" |
| 64 |
|
| 65 |
# check -version |
| 66 |
start_test -version |
| 67 |
case `repl -v` in |
| 68 |
repl\ --*) ;; |
| 69 |
* ) printf '%s: repl -v generated unexpected output\n' "$0" >&2 |
| 70 |
failed=`expr ${failed:-0} + 1`;; |
| 71 |
esac |
| 72 |
|
| 73 |
# check unknown switch |
| 74 |
start_test 'unknown switch' |
| 75 |
run_test "repl -nonexistent" 'repl: -nonexistent unknown' |
| 76 |
|
| 77 |
# check with no switches |
| 78 |
start_test 'with no switches' |
| 79 |
run_test "repl" 'repl: no cur message' |
| 80 |
|
| 81 |
|
| 82 |
printf 'Local-Mailbox: mymailbox@localhost\n' >> "$MH" |
| 83 |
|
| 84 |
# check -cc me |
| 85 |
start_test '-cc me' |
| 86 |
cat >$expected <<EOF |
| 87 |
From: mymailbox@localhost |
| 88 |
To: Test1 <[email protected]> |
| 89 |
cc: mymailbox@localhost |
| 90 |
Fcc: +outbox |
| 91 |
Subject: Re: Testing message 1 |
| 92 |
In-reply-to: [email protected] |
| 93 |
References: [email protected] |
| 94 |
Comments: In-reply-to Test1 <[email protected]> |
| 95 |
message dated "Fri, 29 Sep 2006 00:00:00." |
| 96 |
-------- |
| 97 |
EOF |
| 98 |
|
| 99 |
run_prog repl -cc me -editor true -nowhatnowproc 1 |
| 100 |
check $expected $actual |
| 101 |
|
| 102 |
# check -nocc me |
| 103 |
start_test '-nocc me' |
| 104 |
cat >$expected <<EOF |
| 105 |
From: mymailbox@localhost |
| 106 |
To: Test1 <[email protected]> |
| 107 |
cc: |
| 108 |
Fcc: +outbox |
| 109 |
Subject: Re: Testing message 1 |
| 110 |
In-reply-to: [email protected] |
| 111 |
References: [email protected] |
| 112 |
Comments: In-reply-to Test1 <[email protected]> |
| 113 |
message dated "Fri, 29 Sep 2006 00:00:00." |
| 114 |
-------- |
| 115 |
EOF |
| 116 |
|
| 117 |
run_prog repl -cc me -nocc me -editor true -nowhatnowproc 1 |
| 118 |
check $expected $actual |
| 119 |
|
| 120 |
# check -cc me with Local- and Alternate-Mailbox addtions, Bug #36635 |
| 121 |
start_test '-cc me with Local- and Alternate-Mailbox addtions, Bug #36635' |
| 122 |
# -nocc me doesn't account for Alternate-Mailboxes. |
| 123 |
printf 'Alternate-Mailboxes: [email protected]\n' >> "$MH" |
| 124 |
|
| 125 |
cat >$expected <<EOF |
| 126 |
From: mymailbox@localhost |
| 127 |
To: Test1 <[email protected]> |
| 128 |
cc: mymailbox@localhost |
| 129 |
Fcc: +outbox |
| 130 |
Subject: Re: Testing message 1 |
| 131 |
In-reply-to: [email protected] |
| 132 |
References: [email protected] |
| 133 |
Comments: In-reply-to Test1 <[email protected]> |
| 134 |
message dated "Fri, 29 Sep 2006 00:00:00." |
| 135 |
-------- |
| 136 |
EOF |
| 137 |
|
| 138 |
run_prog repl -cc me -editor true -nowhatnowproc 1 |
| 139 |
check $expected $actual |
| 140 |
|
| 141 |
|
| 142 |
# check -nocc me with Local- and Alternate-Mailbox addtions, Bug #36635 |
| 143 |
start_test '-nocc me with Local- and Alternate-Mailbox addtions, Bug #36635' |
| 144 |
# -nocc me doesn't account for Alternate-Mailboxes. |
| 145 |
cat >$expected <<EOF |
| 146 |
From: mymailbox@localhost |
| 147 |
To: Test1 <[email protected]> |
| 148 |
cc: |
| 149 |
Fcc: +outbox |
| 150 |
Subject: Re: Testing message 1 |
| 151 |
In-reply-to: [email protected] |
| 152 |
References: [email protected] |
| 153 |
Comments: In-reply-to Test1 <[email protected]> |
| 154 |
message dated "Fri, 29 Sep 2006 00:00:00." |
| 155 |
-------- |
| 156 |
EOF |
| 157 |
|
| 158 |
run_prog repl -cc me -nocc me -editor true -nowhatnowproc 1 |
| 159 |
check $expected $actual |
| 160 |
|
| 161 |
|
| 162 |
# check quoting of local part of invalid address, Bug #26780 |
| 163 |
start_test 'quoting of local part of invalid address, Bug #26780' |
| 164 |
cat >`mhpath new` <<EOF |
| 165 |
From: Test11 <[email protected]> |
| 166 |
To: [email protected], A. User <[email protected]>, |
| 167 |
[email protected] |
| 168 |
Date: Fri, 29 Sep 2006 00:00:11 |
| 169 |
Message-Id: [email protected] |
| 170 |
Subject: Testing message 11 |
| 171 |
|
| 172 |
This is message number 11 |
| 173 |
|
| 174 |
EOF |
| 175 |
|
| 176 |
cat >$expected <<EOF |
| 177 |
From: mymailbox@localhost |
| 178 |
To: Test11 <[email protected]> |
| 179 |
cc: [email protected], "A. User" <[email protected]>, |
| 180 |
[email protected] |
| 181 |
Fcc: +outbox |
| 182 |
Subject: Re: Testing message 11 |
| 183 |
In-reply-to: [email protected] |
| 184 |
References: [email protected] |
| 185 |
Comments: In-reply-to Test11 <[email protected]> |
| 186 |
message dated "Fri, 29 Sep 2006 00:00:11." |
| 187 |
-------- |
| 188 |
EOF |
| 189 |
|
| 190 |
run_prog repl -cc to -editor true -nowhatnowproc 11 |
| 191 |
check $expected $actual |
| 192 |
|
| 193 |
|
| 194 |
# check that Fcc: header isn't propagated |
| 195 |
start_test "Fcc: header isn't propagated" |
| 196 |
form="${MH_TEST_DIR}/$$.components" |
| 197 |
cat > $form <<'EOF' |
| 198 |
From: [email protected] |
| 199 |
%<{from}%(void(width))%(putaddr To: )%> |
| 200 |
Fcc:%<{fcc} %{fcc}%> |
| 201 |
Subject: %<{subject}Re: %(void{subject})%(trim)%(putstr)%> |
| 202 |
-------- |
| 203 |
EOF |
| 204 |
cat > $expected <<EOF |
| 205 |
From: [email protected] |
| 206 |
To: [email protected] |
| 207 |
Fcc: |
| 208 |
Subject: Re: suppress Fcc: |
| 209 |
-------- |
| 210 |
EOF |
| 211 |
cat > `mhpath new`<<EOF |
| 212 |
From: [email protected] |
| 213 |
To: [email protected] |
| 214 |
Fcc: +mischievous |
| 215 |
Subject: suppress Fcc: |
| 216 |
-------- |
| 217 |
EOF |
| 218 |
|
| 219 |
run_prog repl -form "${form}" -nowhatnowproc last |
| 220 |
check "${expected}" "${actual}" |
| 221 |
|
| 222 |
|
| 223 |
# check -fcc with Fcc: in replied-to message |
| 224 |
start_test '-fcc with Fcc: in replied-to message' |
| 225 |
form="${MH_TEST_DIR}/$$.components" |
| 226 |
cat > $expected <<EOF |
| 227 |
From: [email protected] |
| 228 |
To: [email protected] |
| 229 |
Fcc: +myoutbox |
| 230 |
Subject: Re: suppress Fcc: |
| 231 |
-------- |
| 232 |
EOF |
| 233 |
|
| 234 |
run_prog repl -fcc +myoutbox -form "${form}" -nowhatnowproc last |
| 235 |
check "${expected}" "${actual}" |
| 236 |
|
| 237 |
|
| 238 |
# check repl to RFC 2047-encoded header with Re: |
| 239 |
cat >`mhpath new` <<EOF |
| 240 |
From: Mr Foo Bar <[email protected]> |
| 241 |
To: Somebody <[email protected]> |
| 242 |
Subject: =?ascii?Q?Re:_This_is_a_test?= |
| 243 |
MIME-Version: 1.0 |
| 244 |
Content-Type: text/plain; charset="us-ascii" |
| 245 |
|
| 246 |
This is a test |
| 247 |
EOF |
| 248 |
|
| 249 |
cat >$expected <<EOF |
| 250 |
From: [email protected] |
| 251 |
To: Mr Foo Bar <[email protected]> |
| 252 |
Fcc: |
| 253 |
Subject: Re: This is a test |
| 254 |
-------- |
| 255 |
EOF |
| 256 |
|
| 257 |
run_prog repl -form "${form}" -nowhatnowproc last |
| 258 |
check $expected $actual |
| 259 |
|
| 260 |
test "${failed:-0}" -eq 0 && rm "${form}" |
| 261 |
|
| 262 |
|
| 263 |
finish_test |
| 264 |
exit ${failed:-0} |