]> diplodocus.org Git - nmh/blob - test/whatnow/test-attach-detach
Better fix for test-attach-detach on platforms without readline.
[nmh] / test / whatnow / test-attach-detach
1 #!/bin/sh
2 ######################################################
3 #
4 # Test that whatnow's "ls" copes with directory names
5 # which have spaces in them (see bug #23319)
6 #
7 ######################################################
8
9 set -e
10
11 if test -z "${MH_OBJ_DIR}"; then
12 srcdir=`dirname "$0"`/../..
13 MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
14 fi
15
16 . "$MH_OBJ_DIR/test/common.sh"
17
18 setup_test
19
20 # Set TERM to get consistent output.
21 TERM=dumb; export TERM
22
23 cd "$MH_TEST_DIR"
24 testname="baz's boz"
25 testname_quoted="baz\'s\ boz"
26 touch "$testname"
27 # whatnow's attach stuff needs a draft to work on
28 cp "$MH_TEST_DIR/Mail/inbox/1" "$MH_TEST_DIR/Mail/draft"
29
30 expectederr=$MH_TEST_DIR/$$.expectederr
31 actualerr=$MH_TEST_DIR/$$.actualerr
32 expected=$MH_TEST_DIR/$$.expected
33 actual=$MH_TEST_DIR/$$.actual
34
35 rm -f $expected $expectederr $actual $actualerr
36 touch $expected $expectederr $actual $actualerr
37
38 #
39 # Sigh. Different readline versions change echoing behavior, so we need
40 # to deal.
41 #
42
43 set +e
44 whatnowtest=`echo cd | whatnow -prompt ''`
45 set -e
46
47 case ${whatnowtest} in
48 cd) cat >"$expected" <<EOF
49 attach $testname_quoted
50 alist
51 $testname
52 detach $testname_quoted
53 alist
54 EOF
55 readline=1
56 ;;
57 "") cat >"$expected" <<EOF
58 $testname
59 EOF
60 readline=0
61 ;;
62 *) echo "Unknown response to whatnow readline test"
63 echo "Response is: ${whatnowtest}"
64 exit 1
65 ;;
66 esac
67
68 # whatnow's exit status is always 1 so that is not a failure
69 set +e
70 echo "attach $testname_quoted" | \
71 run_prog whatnow -attach foo -noedit -prompt '' 2>>$actualerr >>$actual
72 echo "alist" | \
73 run_prog whatnow -attach foo -noedit -prompt '' 2>>$actualerr >>$actual
74 echo "detach $testname_quoted" | \
75 run_prog whatnow -attach foo -noedit -prompt '' 2>>$actualerr >>$actual
76 echo "alist" | \
77 run_prog whatnow -attach foo -noedit -prompt '' 2>>$actualerr >>$actual
78 set -e
79
80 check "$expectederr" "$actualerr"
81 check "$expected" "$actual"
82
83 if [ "$readline" = 0 ]; then
84 cat >"$expected" <<EOF
85
86 What now? whatnow: attach command requires file argument(s).
87
88 What now? whatnow: attach command requires file argument(s).
89
90 What now? whatnow: ignoring attach -a without format argument.
91 whatnow: attach command requires file argument(s).
92
93 What now? whatnow: attach command requires file argument(s).
94
95 What now? whatnow: ignoring attach -a without format argument.
96 whatnow: attach command requires file argument(s).
97
98 What now? whatnow: ignoring attach -a without format argument.
99 whatnow: attach command requires file argument(s).
100
101 What now? whatnow: attach command requires file argument(s).
102
103 What now?
104 What now? whatnow: ignoring attach -a without format argument.
105 #text/plain; name="context" <> [context]{attachment} ${MH_TEST_DIR}/Mail/context
106
107 What now? whatnow: ingoring invalid attachformat value of 3
108 #text/plain; name="context" <> [context]{attachment} ${MH_TEST_DIR}/Mail/context
109
110 What now? #text/plain; name="context" <> [context]{attachment} ${MH_TEST_DIR}/Mail/context
111
112 What now? #text/plain; name="context" <> [context]{attachment} ${MH_TEST_DIR}/Mail/context
113
114 What now? #text/plain; name="context"; x-unix-mode=0600 [ ASCII text ] ${MH_TEST_DIR}/Mail/context
115
116 What now?
117 EOF
118 else
119 cat >"$expected" <<EOF
120
121 What now? at
122 whatnow: attach command requires file argument(s).
123
124 What now? at -v
125 whatnow: attach command requires file argument(s).
126
127 What now? at -v -a
128 whatnow: ignoring attach -a without format argument.
129 whatnow: attach command requires file argument(s).
130
131 What now? at -v -a 0
132 whatnow: attach command requires file argument(s).
133
134 What now? at -a
135 whatnow: ignoring attach -a without format argument.
136 whatnow: attach command requires file argument(s).
137
138 What now? at -a -v
139 whatnow: ignoring attach -a without format argument.
140 whatnow: attach command requires file argument(s).
141
142 What now? at -a 0 -v
143 whatnow: attach command requires file argument(s).
144
145 What now? at -a 0 Mail/context
146
147 What now? at -v -a Mail/context
148 whatnow: ignoring attach -a without format argument.
149 #text/plain; name="context" <> [context]{attachment} ${MH_TEST_DIR}/Mail/context
150
151 What now? at -v -a 3 Mail/context
152 whatnow: ingoring invalid attachformat value of 3
153 #text/plain; name="context" <> [context]{attachment} ${MH_TEST_DIR}/Mail/context
154
155 What now? at -v Mail/context
156 #text/plain; name="context" <> [context]{attachment} ${MH_TEST_DIR}/Mail/context
157
158 What now? at -v -a 1 Mail/context
159 #text/plain; name="context" <> [context]{attachment} ${MH_TEST_DIR}/Mail/context
160
161 What now? at -v -a 0 Mail/context
162 #text/plain; name="context"; x-unix-mode=0600 [ ASCII text ] ${MH_TEST_DIR}/Mail/context
163
164 What now? quit -delete
165 EOF
166 fi
167
168 # Don't depend on the mode of Mail/context:
169 chmod 0600 ${MH_TEST_DIR}/Mail/context
170
171 if [ "$readline" = 0 ]; then
172 #### Ensure that there will be a newline at the end whatnow's output.
173 whatnowtest () {
174 whatnow; echo
175 }
176 else
177 whatnowtest () {
178 whatnow
179 }
180 fi
181
182 set +e
183 printf '%s\n' \
184 'at' \
185 'at -v' \
186 'at -v -a' \
187 'at -v -a 0' \
188 'at -a' \
189 'at -a -v' \
190 'at -a 0 -v' \
191 'at -a 0 Mail/context' \
192 'at -v -a Mail/context' \
193 'at -v -a 3 Mail/context' \
194 'at -v Mail/context' \
195 'at -v -a 1 Mail/context' \
196 'at -v -a 0 Mail/context' \
197 'quit -delete' | whatnowtest 2>&1 | \
198 sed -e 's/; charset=us-ascii//' -e 's/ *ASCII text/ ASCII text/' \
199 -e 's/ *ascii text/ ASCII text/' >"$actual"
200 set -e
201
202 check "$expected" "$actual"
203
204 test ${failed:-0} -eq 0 && rm "$testname"
205
206 exit $failed