]> diplodocus.org Git - nmh/blob - test/whatnow/test-attach-detach
Final fix to test-attach-detach: on some platforms, there's no
[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 set +e
172 printf '%s\n' \
173 'at' \
174 'at -v' \
175 'at -v -a' \
176 'at -v -a 0' \
177 'at -a' \
178 'at -a -v' \
179 'at -a 0 -v' \
180 'at -a 0 Mail/context' \
181 'at -v -a Mail/context' \
182 'at -v -a 3 Mail/context' \
183 'at -v Mail/context' \
184 'at -v -a 1 Mail/context' \
185 'at -v -a 0 Mail/context' \
186 'quit -delete' | whatnow 2>&1 | sed -e 's/; charset=us-ascii//' >"$actual"
187 set -e
188
189 #### Without readline, need to add trailing newline.
190 [ "$readline" = 0 ] && printf '\n' >>"$actual"
191
192 check "$expected" "$actual"
193
194 test ${failed:-0} -eq 0 && rm "$testname"
195
196 exit $failed