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