]> diplodocus.org Git - nmh/blob - test/mhpath/test-mhpath
Update XOAUTH2 documentation.
[nmh] / test / mhpath / test-mhpath
1 #!/bin/sh
2 ######################################################
3 #
4 # Test mhpath
5 #
6 ######################################################
7
8 set -e
9
10 if test -z "${MH_OBJ_DIR}"; then
11 srcdir=`dirname $0`/../..
12 MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
13 fi
14
15 . "$MH_OBJ_DIR/test/common.sh"
16
17 setup_test
18
19 check_exit '-eq 1' mhpath -
20
21 expected=$MH_TEST_DIR/$$.expected
22 actual=$MH_TEST_DIR/$$.actual
23
24
25 # check -help
26 start_test "-help"
27 cat > $expected <<EOF
28 Usage: mhpath [+folder] [msgs] [switches]
29 switches are:
30 -version
31 -help
32 EOF
33
34 #### Skip nmh intro text.
35 run_prog mhpath -help 2>&1 | sed '/^$/,$d' >"$actual"
36 check "$expected" "$actual"
37
38 # check -version
39 start_test "-version"
40 case `mhpath -v` in
41 mhpath\ --*) ;;
42 * ) echo "$0: mhpath -v generated unexpected output" 1>&2
43 failed=`expr ${failed:-0} + 1`;;
44 esac
45
46 # check +
47 start_test "+"
48 run_test "mhpath +" "$MH_TEST_DIR/Mail"
49
50 # check with no options
51 start_test "with no options"
52 folder -fast +inbox > /dev/null
53 run_test "mhpath" "$MH_TEST_DIR/Mail/inbox"
54
55 # check +inbox
56 start_test "+inbox"
57 run_test "mhpath +inbox" "$MH_TEST_DIR/Mail/inbox"
58
59 # check all
60 start_test "all"
61 cat > $expected <<EOF
62 $MH_TEST_DIR/Mail/inbox/1
63 $MH_TEST_DIR/Mail/inbox/2
64 $MH_TEST_DIR/Mail/inbox/3
65 $MH_TEST_DIR/Mail/inbox/4
66 $MH_TEST_DIR/Mail/inbox/5
67 $MH_TEST_DIR/Mail/inbox/6
68 $MH_TEST_DIR/Mail/inbox/7
69 $MH_TEST_DIR/Mail/inbox/8
70 $MH_TEST_DIR/Mail/inbox/9
71 $MH_TEST_DIR/Mail/inbox/10
72 EOF
73 run_prog mhpath all > $actual 2>&1
74 check $expected $actual
75
76 # check message number greater than highest
77 start_test "message number greater than highest"
78 run_test "mhpath 11" "mhpath: message 11 out of range 1-10"
79 run_test "mhpath 10 11" "mhpath: message 11 out of range 1-10"
80
81 # check range with message number greater than highest
82 start_test "range with message number greater than highest"
83 cat > $expected <<EOF
84 $MH_TEST_DIR/Mail/inbox/1
85 $MH_TEST_DIR/Mail/inbox/2
86 $MH_TEST_DIR/Mail/inbox/3
87 $MH_TEST_DIR/Mail/inbox/4
88 $MH_TEST_DIR/Mail/inbox/5
89 $MH_TEST_DIR/Mail/inbox/6
90 $MH_TEST_DIR/Mail/inbox/7
91 $MH_TEST_DIR/Mail/inbox/8
92 $MH_TEST_DIR/Mail/inbox/9
93 $MH_TEST_DIR/Mail/inbox/10
94 EOF
95 run_prog mhpath 1-99999 > $actual 2>&1
96 check $expected $actual
97
98 # check new
99 start_test "new"
100 run_test "mhpath new" "$MH_TEST_DIR/Mail/inbox/11"
101
102 # check multiple msgs, including new
103 start_test "multiple msgs, including new"
104 cat > $expected <<EOF
105 $MH_TEST_DIR/Mail/inbox/1
106 $MH_TEST_DIR/Mail/inbox/10
107 $MH_TEST_DIR/Mail/inbox/11
108 EOF
109 run_prog mhpath first last new > $actual 2>&1
110 check $expected $actual
111
112 # check invalid message list using names
113 start_test "invalid message list using names"
114 run_test "mhpath last-new" "mhpath: bad message list last-new"
115
116 # check cur
117 start_test "cur"
118 folder +inbox 5 > /dev/null
119 run_test "mhpath cur" "$MH_TEST_DIR/Mail/inbox/5"
120
121 # check prev
122 start_test "prev"
123 run_test "mhpath prev" "$MH_TEST_DIR/Mail/inbox/4"
124
125 # check next
126 start_test "next"
127 run_test "mhpath next" "$MH_TEST_DIR/Mail/inbox/6"
128
129 # check invalid message list using numbers
130 start_test "invalid message list using numbers"
131 rmm 1-2
132 run_test "mhpath 1-2" "mhpath: no messages in range 1-2"
133
134 # check ignoring of out-of-range message numbers in ranges
135 start_test "ignoring of out-of-range message numbers in ranges"
136 run_test "mhpath 1-3" "$MH_TEST_DIR/Mail/inbox/3"
137 run_test "mhpath first-3" "$MH_TEST_DIR/Mail/inbox/3"
138 run_test "mhpath 10-11" "$MH_TEST_DIR/Mail/inbox/10"
139 run_test "mhpath last-11" "$MH_TEST_DIR/Mail/inbox/10"
140
141 # check reference to existing messages
142 start_test "reference to existing messages"
143 cat > $expected <<EOF
144 $MH_TEST_DIR/Mail/inbox/3
145 $MH_TEST_DIR/Mail/inbox/4
146 EOF
147 run_prog mhpath first:2 > $actual 2>&1
148 check $expected $actual
149
150 # check reference to non-existent messages
151 start_test "reference to non-existent messages"
152 cat > $expected <<EOF
153 $MH_TEST_DIR/Mail/inbox/1
154 $MH_TEST_DIR/Mail/inbox/2
155 EOF
156 run_prog mhpath 1 2 > $actual 2>&1
157 check $expected $actual
158
159
160 finish_test
161 exit $failed