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