]> diplodocus.org Git - nmh/blob - test/whatnow/test-attach-detach
Here's a better fix for the whatnow tests: set and export
[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 test ${failed:-0} -eq 0 && rm "$testname"
82
83 exit $failed