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