File: test-mhpath

package info (click to toggle)
nmh 1.6-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 6,204 kB
  • ctags: 3,851
  • sloc: ansic: 48,922; sh: 16,422; makefile: 559; perl: 509; lex: 402; awk: 74
file content (139 lines) | stat: -rwxr-xr-x 3,249 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/sh
######################################################
#
# Test mhpath
#
######################################################

set -e

if test -z "${MH_OBJ_DIR}"; then
    srcdir=`dirname $0`/../..
    MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
fi

. "$MH_OBJ_DIR/test/common.sh"

setup_test

expected=$MH_TEST_DIR/$$.expected
actual=$MH_TEST_DIR/$$.actual


# check -help
cat > $expected <<EOF
Usage: mhpath [+folder] [msgs] [switches]
  switches are:
  -version
  -help
EOF

run_prog mhpath -help > $actual 2>&1
check $expected $actual

# check -version
case `mhpath -v` in
  mhpath\ --*) ;;
  *          ) echo "$0: mhpath -v generated unexpected output" 1>&2
               failed=`expr ${failed:-0} + 1`;;
esac

# check +
run_test "mhpath +" "$MH_TEST_DIR/Mail"

# check with no options
folder -fast +inbox > /dev/null
run_test "mhpath" "$MH_TEST_DIR/Mail/inbox"

# check +inbox
run_test "mhpath +inbox" "$MH_TEST_DIR/Mail/inbox"

# check all
cat > $expected <<EOF
$MH_TEST_DIR/Mail/inbox/1
$MH_TEST_DIR/Mail/inbox/2
$MH_TEST_DIR/Mail/inbox/3
$MH_TEST_DIR/Mail/inbox/4
$MH_TEST_DIR/Mail/inbox/5
$MH_TEST_DIR/Mail/inbox/6
$MH_TEST_DIR/Mail/inbox/7
$MH_TEST_DIR/Mail/inbox/8
$MH_TEST_DIR/Mail/inbox/9
$MH_TEST_DIR/Mail/inbox/10
EOF
run_prog mhpath all > $actual 2>&1
check $expected $actual

# check message number greater than highest
run_test "mhpath 11" "mhpath: message 11 out of range 1-10"
run_test "mhpath 10 11" "mhpath: message 11 out of range 1-10"

# check range with message number greater than highest
cat > $expected <<EOF
$MH_TEST_DIR/Mail/inbox/1
$MH_TEST_DIR/Mail/inbox/2
$MH_TEST_DIR/Mail/inbox/3
$MH_TEST_DIR/Mail/inbox/4
$MH_TEST_DIR/Mail/inbox/5
$MH_TEST_DIR/Mail/inbox/6
$MH_TEST_DIR/Mail/inbox/7
$MH_TEST_DIR/Mail/inbox/8
$MH_TEST_DIR/Mail/inbox/9
$MH_TEST_DIR/Mail/inbox/10
EOF
run_prog mhpath 1-99999 > $actual 2>&1
check $expected $actual

# check new
run_test "mhpath new" "$MH_TEST_DIR/Mail/inbox/11"

# check multiple msgs, including new
cat > $expected <<EOF
$MH_TEST_DIR/Mail/inbox/1
$MH_TEST_DIR/Mail/inbox/10
$MH_TEST_DIR/Mail/inbox/11
EOF
run_prog mhpath first last new > $actual 2>&1
check $expected $actual

# check invalid message list using names
run_test "mhpath last-new" "mhpath: bad message list last-new"

# check cur
folder +inbox 5 > /dev/null
run_test "mhpath cur" "$MH_TEST_DIR/Mail/inbox/5"

# check prev
run_test "mhpath prev" "$MH_TEST_DIR/Mail/inbox/4"

# check next
run_test "mhpath next" "$MH_TEST_DIR/Mail/inbox/6"

# check invalid message list using numbers
rmm 1-2
run_test "mhpath 1-2" "mhpath: no messages in range 1-2"

# check ignoring of out-of-range message numbers in ranges
run_test "mhpath 1-3" "$MH_TEST_DIR/Mail/inbox/3"
run_test "mhpath first-3" "$MH_TEST_DIR/Mail/inbox/3"
run_test "mhpath 10-11" "$MH_TEST_DIR/Mail/inbox/10"
run_test "mhpath last-11" "$MH_TEST_DIR/Mail/inbox/10"

# check reference to existing messages
cat > $expected <<EOF
$MH_TEST_DIR/Mail/inbox/3
$MH_TEST_DIR/Mail/inbox/4
EOF
run_prog mhpath first:2 > $actual 2>&1
check $expected $actual

# check reference to non-existant messages
cat > $expected <<EOF
$MH_TEST_DIR/Mail/inbox/1
$MH_TEST_DIR/Mail/inbox/2
EOF
run_prog mhpath 1 2 > $actual 2>&1
check $expected $actual


exit $failed