fix the prompter test
[mmh] / test / tests / prompter / test-prompter
1 #!/bin/sh
2 ######################################################
3 #
4 # Test prompter
5 #
6 ######################################################
7
8
9 . "$MH_TEST_COMMON"
10
11
12
13 # check -help
14 runandcheck "prompter -help" <<!
15 Usage: prompter [switches] file
16   switches are:
17   -[no]prepend
18   -[no]rapid
19   -[no]body
20   -Version
21   -help
22 !
23
24
25 # check -version
26 case `prompter -V` in
27   prompter\ --*) ;;
28   *            ) printf '%s: prompter -v generated unexpected output\n' "$0" >&2
29                  failed=`expr ${failed:-0} + 1`;;
30 esac
31
32 # check unknown switch
33 runandcheck 'prompter -nonexistent' <<!
34 prompter: -nonexistent unknown
35 !
36
37
38
39 # check with no switches
40
41 runandcheck 'prompter' <<!
42 prompter: usage: prompter [switches] file
43 !
44
45
46
47 # check with file
48
49 cat >$MH_TEST_DIR/prompter-file <<EOF
50 Resent-From: sender@example.com
51 Resent-To:
52 Resent-cc:
53 Resent-fcc:
54 EOF
55
56 printf 'recipient@example.com\ncc@example.com\n+outbox\nmessage body\n' | \
57         prompter $MH_TEST_DIR/prompter-file >/dev/null
58
59 runandcheck "cat $MH_TEST_DIR/prompter-file" <<!
60 Resent-From: sender@example.com
61 Resent-To: recipient@example.com
62 Resent-cc: cc@example.com
63 Resent-fcc: +outbox
64 --------
65 message body
66 !
67
68
69
70 # check -noprepend
71
72 cat >$MH_TEST_DIR/prompter-file <<EOF
73 Resent-From: sender@example.com
74 Resent-To:
75 Resent-cc:
76 Resent-fcc:
77 --------
78 message body
79 EOF
80
81 printf 'recipient@example.com\ncc@example.com\n+outbox\nappendage\n' | \
82         prompter -noprepend $MH_TEST_DIR/prompter-file >/dev/null
83
84 runandcheck "cat $MH_TEST_DIR/prompter-file" <<!
85 Resent-From: sender@example.com
86 Resent-To: recipient@example.com
87 Resent-cc: cc@example.com
88 Resent-fcc: +outbox
89 --------
90 message body
91 appendage
92 !
93
94
95 # check -prepend
96
97 cat >$MH_TEST_DIR/prompter-file <<EOF
98 Resent-From: sender@example.com
99 Resent-To:
100 Resent-cc:
101 Resent-fcc:
102 --------
103 message body
104 EOF
105
106 printf 'recipient@example.com\ncc@example.com\n+outbox\nprependage\n' | \
107         prompter -noprepend -prepend $MH_TEST_DIR/prompter-file >/dev/null
108
109 runandcheck "cat $MH_TEST_DIR/prompter-file" <<!
110 Resent-From: sender@example.com
111 Resent-To: recipient@example.com
112 Resent-cc: cc@example.com
113 Resent-fcc: +outbox
114 --------
115 prependage
116 message body
117 !
118
119
120 # check -rapid
121
122 runandcheck "</dev/null prompter -rapid $MH_TEST_DIR/prompter-file" <<!
123 Resent-From: sender@example.com
124 Resent-To: recipient@example.com
125 Resent-cc: cc@example.com
126 Resent-fcc: +outbox
127 --------Enter initial text
128 --------
129 !
130
131
132
133 # check -norapid
134
135 runandcheck "</dev/null prompter -rapid -norapid $MH_TEST_DIR/prompter-file" <<!
136 Resent-From: sender@example.com
137 Resent-To: recipient@example.com
138 Resent-cc: cc@example.com
139 Resent-fcc: +outbox
140 --------Enter initial text
141 prependage
142 message body
143 --------
144 !
145
146
147
148 # check -body.
149
150 runandcheck "echo 'woot woot' | prompter -nobody -body $MH_TEST_DIR/prompter-file" <<!
151 Resent-From: sender@example.com
152 Resent-To: recipient@example.com
153 Resent-cc: cc@example.com
154 Resent-fcc: +outbox
155 --------Enter initial text
156 prependage
157 message body
158 --------
159 !
160
161 runandcheck "cat $MH_TEST_DIR/prompter-file" <<!
162 Resent-From: sender@example.com
163 Resent-To: recipient@example.com
164 Resent-cc: cc@example.com
165 Resent-fcc: +outbox
166 --------
167 woot woot
168 prependage
169 message body
170 !