d9c39a13501277c17a6760a2364cb2d2ec44e00f
[mmh] / 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   -cc all|to|cc|me
33   -nocc type
34   -draftfolder +folder
35   -draftmessage msg
36   -nodraftfolder
37   -editor editor
38   -noedit
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 repl -help >$actual 2>&1
59 check $expected $actual
60
61 # check -version
62 case `repl -v` in
63   repl\ --*) ;;
64   *           ) printf "$0: repl -v generated unexpected output\n" >&2
65                 failed=`expr ${failed:-0} + 1`;;
66 esac
67
68 # check unknown switch
69 run_test "repl -nonexistent" 'repl: -nonexistent unknown'
70
71 # check with no switches
72 run_test "repl" 'repl: no cur message'
73
74
75 printf "Local-Mailbox: mymailbox@localhost%s\n" >> $MH
76
77 # check -cc me
78 cat >$expected <<EOF
79 From: mymailbox@localhost
80 To: Test1 <test1@example.com>
81 cc: mymailbox@localhost
82 Fcc: +outbox
83 Subject: Re: Testing message 1
84 Comments: In-reply-to Test1 <test1@example.com>
85    message dated "Fri, 29 Sep 2006 00:00:00."
86 --------
87 EOF
88
89 repl -cc me -editor true -nowhatnowproc 1
90 check $expected $actual
91
92 # check -nocc me
93 cat >$expected <<EOF
94 From: mymailbox@localhost
95 To: Test1 <test1@example.com>
96 cc: 
97 Fcc: +outbox
98 Subject: Re: Testing message 1
99 Comments: In-reply-to Test1 <test1@example.com>
100    message dated "Fri, 29 Sep 2006 00:00:00."
101 --------
102 EOF
103
104 repl -cc me -nocc me -editor true -nowhatnowproc 1
105 check $expected $actual
106
107 # check -cc me with Local- and Alternate-Mailbox addtions, Bug #36635:
108 # -nocc me doesn't account for Alternate-Mailboxes.
109 printf "Alternate-Mailboxes: user@example.com\n" >> $MH
110
111 cat >$expected <<EOF
112 From: mymailbox@localhost
113 To: Test1 <test1@example.com>
114 cc: mymailbox@localhost
115 Fcc: +outbox
116 Subject: Re: Testing message 1
117 Comments: In-reply-to Test1 <test1@example.com>
118    message dated "Fri, 29 Sep 2006 00:00:00."
119 --------
120 EOF
121
122 repl -cc me -editor true -nowhatnowproc 1
123 check $expected $actual
124
125
126 # check -nocc me with Local- and Alternate-Mailbox addtions, Bug #36635:
127 # -nocc me doesn't account for Alternate-Mailboxes.
128 cat >$expected <<EOF
129 From: mymailbox@localhost
130 To: Test1 <test1@example.com>
131 cc: 
132 Fcc: +outbox
133 Subject: Re: Testing message 1
134 Comments: In-reply-to Test1 <test1@example.com>
135    message dated "Fri, 29 Sep 2006 00:00:00."
136 --------
137 EOF
138
139 repl -cc me -nocc me -editor true -nowhatnowproc 1
140 check $expected $actual
141
142
143 exit ${failed:-0}