]> diplodocus.org Git - nmh/blob - test/whatnow/test-attach-detach
Added -v and -a switches to whatnow attach so the user can see
[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 ;;
56 "") cat >"$expected" <<EOF
57 $testname
58 EOF
59 ;;
60 *) echo "Unknown response to whatnow readline test"
61 echo "Response is: ${whatnowtest}"
62 exit 1
63 ;;
64 esac
65
66 # whatnow's exit status is always 1 so that is not a failure
67 set +e
68 echo "attach $testname_quoted" | \
69 run_prog whatnow -attach foo -noedit -prompt '' 2>>$actualerr >>$actual
70 echo "alist" | \
71 run_prog whatnow -attach foo -noedit -prompt '' 2>>$actualerr >>$actual
72 echo "detach $testname_quoted" | \
73 run_prog whatnow -attach foo -noedit -prompt '' 2>>$actualerr >>$actual
74 echo "alist" | \
75 run_prog whatnow -attach foo -noedit -prompt '' 2>>$actualerr >>$actual
76 set -e
77
78 check "$expectederr" "$actualerr"
79 check "$expected" "$actual"
80
81 cat >"$expected" <<EOF
82
83 What now? at
84 whatnow: attach command requires file argument(s).
85
86 What now? at -v
87 whatnow: attach command requires file argument(s).
88
89 What now? at -v -a
90 whatnow: ignoring attach -a without format argument.
91 whatnow: attach command requires file argument(s).
92
93 What now? at -v -a 0
94 whatnow: attach command requires file argument(s).
95
96 What now? at -a
97 whatnow: ignoring attach -a without format argument.
98 whatnow: attach command requires file argument(s).
99
100 What now? at -a -v
101 whatnow: ignoring attach -a without format argument.
102 whatnow: attach command requires file argument(s).
103
104 What now? at -a 0 -v
105 whatnow: attach command requires file argument(s).
106
107 What now? at -a 0 Mail/context
108
109 What now? at -v -a Mail/context
110 whatnow: ignoring attach -a without format argument.
111 #text/plain; charset=us-ascii; name="context" <> [context]{attachment} ${MH_TEST_DIR}/Mail/context
112
113 What now? at -v -a 3 Mail/context
114 whatnow: ingoring invalid attachformat value of 3
115 #text/plain; charset=us-ascii; name="context" <> [context]{attachment} ${MH_TEST_DIR}/Mail/context
116
117 What now? at -v Mail/context
118 #text/plain; charset=us-ascii; name="context" <> [context]{attachment} ${MH_TEST_DIR}/Mail/context
119
120 What now? at -v -a 1 Mail/context
121 #text/plain; charset=us-ascii; name="context" <> [context]{attachment} ${MH_TEST_DIR}/Mail/context
122
123 What now? at -v -a 0 Mail/context
124 #text/plain; charset=us-ascii; name="context"; x-unix-mode=0644 [ ASCII text ] ${MH_TEST_DIR}/Mail/context
125
126 What now? quit -delete
127 EOF
128
129 set +e
130 printf '%s\n' \
131 'at' \
132 'at -v' \
133 'at -v -a' \
134 'at -v -a 0' \
135 'at -a' \
136 'at -a -v' \
137 'at -a 0 -v' \
138 'at -a 0 Mail/context' \
139 'at -v -a Mail/context' \
140 'at -v -a 3 Mail/context' \
141 'at -v Mail/context' \
142 'at -v -a 1 Mail/context' \
143 'at -v -a 0 Mail/context' \
144 'quit -delete' | whatnow >$actual 2>&1
145 set -e
146
147 check "$expected" "$actual"
148
149 test ${failed:-0} -eq 0 && rm "$testname"
150
151 exit $failed