]> diplodocus.org Git - nmh/blob - test/repl/test-repl
import jsmn 86:19001fb4adb3
[nmh] / test / repl / test-repl
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 expected=$MH_TEST_DIR/$$.expected
23 actual=$MH_TEST_DIR/Mail/draft
24
25
26 # check -help
27 cat >$expected <<EOF
28 Usage: repl: [+folder] [msg] [switches]
29 switches are:
30 -[no]group
31 -[no]annotate
32 -[no]cc all|to|cc|me
33 -draftfolder +folder
34 -draftmessage msg
35 -nodraftfolder
36 -editor editor
37 -noedit
38 -fcc folder
39 -filter filterfile
40 -form formfile
41 -([no]forma)t
42 -[no]inplace
43 -[no]mime
44 -[no]query
45 -whatnowproc program
46 -nowhatnowproc
47 -width columns
48 -version
49 -help
50 -(file) file
51 -(build)
52 -[no]atfile
53 -fmtproc program
54 -nofmtproc
55 EOF
56
57 run_prog repl -help >$actual 2>&1
58 check $expected $actual
59
60 # check -version
61 case `repl -v` in
62 repl\ --*) ;;
63 * ) printf '%s: repl -v generated unexpected output\n' "$0" >&2
64 failed=`expr ${failed:-0} + 1`;;
65 esac
66
67 # check unknown switch
68 run_test "repl -nonexistent" 'repl: -nonexistent unknown'
69
70 # check with no switches
71 run_test "repl" 'repl: no cur message'
72
73
74 printf 'Local-Mailbox: mymailbox@localhost\n' >> "$MH"
75
76 # check -cc me
77 cat >$expected <<EOF
78 From: mymailbox@localhost
79 To: Test1 <test1@example.com>
80 cc: mymailbox@localhost
81 Fcc: +outbox
82 Subject: Re: Testing message 1
83 In-reply-to: 1@test.nmh
84 References: 1@test.nmh
85 Comments: In-reply-to Test1 <test1@example.com>
86 message dated "Fri, 29 Sep 2006 00:00:00."
87 --------
88 EOF
89
90 run_prog repl -cc me -editor true -nowhatnowproc 1
91 check $expected $actual
92
93 # check -nocc me
94 cat >$expected <<EOF
95 From: mymailbox@localhost
96 To: Test1 <test1@example.com>
97 cc:
98 Fcc: +outbox
99 Subject: Re: Testing message 1
100 In-reply-to: 1@test.nmh
101 References: 1@test.nmh
102 Comments: In-reply-to Test1 <test1@example.com>
103 message dated "Fri, 29 Sep 2006 00:00:00."
104 --------
105 EOF
106
107 run_prog repl -cc me -nocc me -editor true -nowhatnowproc 1
108 check $expected $actual
109
110 # check -cc me with Local- and Alternate-Mailbox addtions, Bug #36635:
111 # -nocc me doesn't account for Alternate-Mailboxes.
112 printf 'Alternate-Mailboxes: user@example.com\n' >> "$MH"
113
114 cat >$expected <<EOF
115 From: mymailbox@localhost
116 To: Test1 <test1@example.com>
117 cc: mymailbox@localhost
118 Fcc: +outbox
119 Subject: Re: Testing message 1
120 In-reply-to: 1@test.nmh
121 References: 1@test.nmh
122 Comments: In-reply-to Test1 <test1@example.com>
123 message dated "Fri, 29 Sep 2006 00:00:00."
124 --------
125 EOF
126
127 run_prog repl -cc me -editor true -nowhatnowproc 1
128 check $expected $actual
129
130
131 # check -nocc me with Local- and Alternate-Mailbox addtions, Bug #36635:
132 # -nocc me doesn't account for Alternate-Mailboxes.
133 cat >$expected <<EOF
134 From: mymailbox@localhost
135 To: Test1 <test1@example.com>
136 cc:
137 Fcc: +outbox
138 Subject: Re: Testing message 1
139 In-reply-to: 1@test.nmh
140 References: 1@test.nmh
141 Comments: In-reply-to Test1 <test1@example.com>
142 message dated "Fri, 29 Sep 2006 00:00:00."
143 --------
144 EOF
145
146 run_prog repl -cc me -nocc me -editor true -nowhatnowproc 1
147 check $expected $actual
148
149
150 # check quoting of local part of invalid address, Bug #26780
151 cat >`mhpath new` <<EOF
152 From: Test11 <test11@example.com>
153 To: before_auser@example.com, A. User <auser@example.com>,
154 after_user@example.com
155 Date: Fri, 29 Sep 2006 00:00:11
156 Message-Id: 11@test.nmh
157 Subject: Testing message 11
158
159 This is message number 11
160
161 EOF
162
163 cat >$expected <<EOF
164 From: mymailbox@localhost
165 To: Test11 <test11@example.com>
166 cc: before_auser@example.com, "A. User" <auser@example.com>,
167 after_user@example.com
168 Fcc: +outbox
169 Subject: Re: Testing message 11
170 In-reply-to: 11@test.nmh
171 References: 11@test.nmh
172 Comments: In-reply-to Test11 <test11@example.com>
173 message dated "Fri, 29 Sep 2006 00:00:11."
174 --------
175 EOF
176
177 run_prog repl -cc to -editor true -nowhatnowproc 11
178 check $expected $actual
179
180
181 exit ${failed:-0}