]> diplodocus.org Git - nmh/blob - test/whatnow/test-attach-detach
Added const to arg of m_backup().
[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 -noedit -prompt '' 2>>$actualerr >>$actual
72 echo "alist" | \
73 run_prog whatnow -noedit -prompt '' 2>>$actualerr >>$actual
74 echo "detach $testname_quoted" | \
75 run_prog whatnow -noedit -prompt '' 2>>$actualerr >>$actual
76 echo "alist" | \
77 run_prog whatnow -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 whatnow: attach command requires file argument(s).
86 whatnow: attach command requires file argument(s).
87 Attaching ${MH_TEST_DIR}/Mail/context as a text/plain
88 EOF
89 else
90 cat >"$expected" <<EOF
91 at
92 whatnow: attach command requires file argument(s).
93 at -v
94 whatnow: attach command requires file argument(s).
95 at -v Mail/context
96 Attaching ${MH_TEST_DIR}/Mail/context as a text/plain
97 quit -delete
98 EOF
99 fi
100
101 printf '%s\n' \
102 'at' \
103 'at -v' \
104 'at -v Mail/context' \
105 'quit -delete' | whatnow -prompt '' 2>&1 | \
106 sed -e 's/; charset=us-ascii//' >"$actual"
107
108 check "$expected" "$actual"
109
110 test ${failed:-0} -eq 0 && rm "$testname"
111
112 exit $failed