]> diplodocus.org Git - nmh/blob - test/mhpath/test-mhpath
Plugged remaining mhfixmsg(1) memory leaks.
[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 cat > $expected <<EOF
27 Usage: mhpath [+folder] [msgs] [switches]
28 switches are:
29 -version
30 -help
31 EOF
32
33 #### Skip nmh intro text.
34 run_prog mhpath -help | sed '/^$/,$d' >"$actual" 2>&1
35 check "$expected" "$actual"
36
37 # check -version
38 case `mhpath -v` in
39 mhpath\ --*) ;;
40 * ) echo "$0: mhpath -v generated unexpected output" 1>&2
41 failed=`expr ${failed:-0} + 1`;;
42 esac
43
44 # check +
45 run_test "mhpath +" "$MH_TEST_DIR/Mail"
46
47 # check with no options
48 folder -fast +inbox > /dev/null
49 run_test "mhpath" "$MH_TEST_DIR/Mail/inbox"
50
51 # check +inbox
52 run_test "mhpath +inbox" "$MH_TEST_DIR/Mail/inbox"
53
54 # check all
55 cat > $expected <<EOF
56 $MH_TEST_DIR/Mail/inbox/1
57 $MH_TEST_DIR/Mail/inbox/2
58 $MH_TEST_DIR/Mail/inbox/3
59 $MH_TEST_DIR/Mail/inbox/4
60 $MH_TEST_DIR/Mail/inbox/5
61 $MH_TEST_DIR/Mail/inbox/6
62 $MH_TEST_DIR/Mail/inbox/7
63 $MH_TEST_DIR/Mail/inbox/8
64 $MH_TEST_DIR/Mail/inbox/9
65 $MH_TEST_DIR/Mail/inbox/10
66 EOF
67 run_prog mhpath all > $actual 2>&1
68 check $expected $actual
69
70 # check message number greater than highest
71 run_test "mhpath 11" "mhpath: message 11 out of range 1-10"
72 run_test "mhpath 10 11" "mhpath: message 11 out of range 1-10"
73
74 # check range with message number greater than highest
75 cat > $expected <<EOF
76 $MH_TEST_DIR/Mail/inbox/1
77 $MH_TEST_DIR/Mail/inbox/2
78 $MH_TEST_DIR/Mail/inbox/3
79 $MH_TEST_DIR/Mail/inbox/4
80 $MH_TEST_DIR/Mail/inbox/5
81 $MH_TEST_DIR/Mail/inbox/6
82 $MH_TEST_DIR/Mail/inbox/7
83 $MH_TEST_DIR/Mail/inbox/8
84 $MH_TEST_DIR/Mail/inbox/9
85 $MH_TEST_DIR/Mail/inbox/10
86 EOF
87 run_prog mhpath 1-99999 > $actual 2>&1
88 check $expected $actual
89
90 # check new
91 run_test "mhpath new" "$MH_TEST_DIR/Mail/inbox/11"
92
93 # check multiple msgs, including new
94 cat > $expected <<EOF
95 $MH_TEST_DIR/Mail/inbox/1
96 $MH_TEST_DIR/Mail/inbox/10
97 $MH_TEST_DIR/Mail/inbox/11
98 EOF
99 run_prog mhpath first last new > $actual 2>&1
100 check $expected $actual
101
102 # check invalid message list using names
103 run_test "mhpath last-new" "mhpath: bad message list last-new"
104
105 # check cur
106 folder +inbox 5 > /dev/null
107 run_test "mhpath cur" "$MH_TEST_DIR/Mail/inbox/5"
108
109 # check prev
110 run_test "mhpath prev" "$MH_TEST_DIR/Mail/inbox/4"
111
112 # check next
113 run_test "mhpath next" "$MH_TEST_DIR/Mail/inbox/6"
114
115 # check invalid message list using numbers
116 rmm 1-2
117 run_test "mhpath 1-2" "mhpath: no messages in range 1-2"
118
119 # check ignoring of out-of-range message numbers in ranges
120 run_test "mhpath 1-3" "$MH_TEST_DIR/Mail/inbox/3"
121 run_test "mhpath first-3" "$MH_TEST_DIR/Mail/inbox/3"
122 run_test "mhpath 10-11" "$MH_TEST_DIR/Mail/inbox/10"
123 run_test "mhpath last-11" "$MH_TEST_DIR/Mail/inbox/10"
124
125 # check reference to existing messages
126 cat > $expected <<EOF
127 $MH_TEST_DIR/Mail/inbox/3
128 $MH_TEST_DIR/Mail/inbox/4
129 EOF
130 run_prog mhpath first:2 > $actual 2>&1
131 check $expected $actual
132
133 # check reference to non-existent messages
134 cat > $expected <<EOF
135 $MH_TEST_DIR/Mail/inbox/1
136 $MH_TEST_DIR/Mail/inbox/2
137 EOF
138 run_prog mhpath 1 2 > $actual 2>&1
139 check $expected $actual
140
141
142 exit $failed