]> diplodocus.org Git - nmh/blob - test/new/test-basic
inc.c: Make maildir_srt() static.
[nmh] / test / new / test-basic
1 #!/bin/sh
2 ######################################################
3 #
4 # Test many basic nmh capabilities.
5 #
6 ######################################################
7
8 if test -z "${MH_OBJ_DIR}"; then
9 srcdir=`dirname "$0"`/../..
10 MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
11 fi
12
13 . "$MH_OBJ_DIR/test/common.sh"
14
15 setup_test
16
17 folders=$MH_TEST_DIR/Mail/.folders
18
19 expected=$MH_TEST_DIR/$$.expected
20 actual=$MH_TEST_DIR/$$.actual
21
22 # make second folder
23 cp -r $MH_TEST_DIR/Mail/inbox $MH_TEST_DIR/Mail/foo1
24 cp -r $MH_TEST_DIR/Mail/inbox $MH_TEST_DIR/Mail/foo2
25 # but only list inbox and foo2 in .folders, and sorted differently
26 cat > $folders <<EOF
27 inbox
28 foo2
29 EOF
30
31 # test with no sequence
32 start_test 'test with no sequence'
33 cat > $expected <<EOF
34 new: must specify sequences or set Unseen-Sequence
35 EOF
36 run_prog new > $actual 2>&1 || true
37 check $expected $actual
38
39 # test with no desired messages
40 start_test 'test with no desired messages'
41 cat > $expected <<EOF
42 total 0.
43 EOF
44 run_prog new aseq > $actual 2>&1
45 check $expected $actual 'keep first'
46 run_prog new -folders $folders aseq > $actual 2>&1
47 check $expected $actual
48
49 # test fnext/fprev with no desired messages
50 start_test 'test fnext/fprev with no desired messages'
51 cat /dev/null > $expected
52 run_prog fnext aseq > $actual 2>&1
53 check $expected $actual 'keep first'
54 run_prog fprev aseq > $actual 2>&1
55 check $expected $actual
56
57 # add 1 desired message in each folder
58 echo 'aseq: 1' > $MH_TEST_DIR/Mail/inbox/.mh_sequences
59 echo 'aseq: 1' > $MH_TEST_DIR/Mail/foo1/.mh_sequences
60 echo 'aseq: 1' > $MH_TEST_DIR/Mail/foo2/.mh_sequences
61
62 # test with all folders
63 start_test 'test with all folders'
64 cat > $expected <<EOF
65 foo1 1. 1
66 foo2 1. 1
67 inbox 1.* 1
68 total 3.
69 EOF
70 run_prog new aseq > $actual 2>&1
71 check $expected $actual
72
73 # test with .folders
74 start_test 'test with .folders'
75 cat > $expected <<EOF
76 inbox 1.* 1
77 foo2 1. 1
78 total 2.
79 EOF
80 run_prog new -folders $folders aseq > $actual 2>&1
81 check $expected $actual
82
83 # add 2 desired messages to another sequence in each folder
84 echo 'bseq: 3-4' >> $MH_TEST_DIR/Mail/inbox/.mh_sequences
85 echo 'bseq: 3-4' >> $MH_TEST_DIR/Mail/foo1/.mh_sequences
86 echo 'bseq: 3-4' >> $MH_TEST_DIR/Mail/foo2/.mh_sequences
87
88 # test listing aseq and bseq
89 start_test 'test listing aseq and bseq'
90 cat > $expected <<EOF
91 foo1 3. 1 3-4
92 foo2 3. 1 3-4
93 inbox 3.* 1 3-4
94 total 9.
95 EOF
96 run_prog new aseq bseq > $actual 2>&1
97 check $expected $actual 'keep first'
98
99 # set aseq bseq as unseen
100 echo 'Unseen-Sequence: aseq bseq' >> $MH
101 run_prog new > $actual 2>&1
102 check $expected $actual
103
104 # test unseen
105 start_test 'test unseen'
106 cat > $expected <<EOF
107
108 3 aseq bseq messages in foo1
109 1 09/29 Test1 Testing message 1<<This is message number 1 >>
110 3 09/29 Test3 Testing message 3<<This is message number 3 >>
111 4 09/29 Test4 Testing message 4<<This is message number 4 >>
112
113 3 aseq bseq messages in foo2
114 1 09/29 Test1 Testing message 1<<This is message number 1 >>
115 3 09/29 Test3 Testing message 3<<This is message number 3 >>
116 4 09/29 Test4 Testing message 4<<This is message number 4 >>
117
118 3 aseq bseq messages in inbox (*: current folder)
119 1 09/29 Test1 Testing message 1<<This is message number 1 >>
120 3 09/29 Test3 Testing message 3<<This is message number 3 >>
121 4 09/29 Test4 Testing message 4<<This is message number 4 >>
122 EOF
123 run_prog unseen > $actual 2>&1
124 check $expected $actual
125
126 # test fnext with the current folder not in the list
127 start_test 'test fnext with the current folder not in the list'
128 echo 'Current-Folder: foo1' > $MH_TEST_DIR/Mail/context
129 echo 'inbox 1 3-4' > $expected
130 run_prog fnext -folders $folders > $actual 2>&1
131 check $expected $actual
132
133 # test fprev with the current folder not in the list
134 start_test 'test fprev with the current folder not in the list'
135 echo 'Current-Folder: foo1' > $MH_TEST_DIR/Mail/context
136 echo 'inbox 1 3-4' > $expected
137 run_prog fprev -folders $folders > $actual 2>&1
138 check $expected $actual
139
140 # test fnext with current folder in the middle of the list
141 start_test 'test fnext with current folder in the middle of the list'
142 echo 'Current-Folder: foo2' > $MH_TEST_DIR/Mail/context
143 echo 'inbox 1 3-4' > $expected
144 run_prog fnext > $actual 2>&1
145 check $expected $actual
146
147 # test fprev with current folder in the middle of the list
148 start_test 'test fprev with current folder in the middle of the list'
149 echo 'Current-Folder: foo2' > $MH_TEST_DIR/Mail/context
150 echo 'foo1 1 3-4' > $expected
151 run_prog fprev > $actual 2>&1
152 check $expected $actual
153
154 # test fprev with current folder at the beginning of the list
155 start_test 'test fprev with current folder at the beginning of the list'
156 echo 'Current-Folder: foo1' > $MH_TEST_DIR/Mail/context
157 echo 'inbox 1 3-4' > $expected
158 run_prog fprev > $actual 2>&1
159 check $expected $actual
160
161 # test fnext with current folder at the end of the list
162 start_test 'test fnext with current folder at the end of the list'
163 echo 'Current-Folder: inbox' > $MH_TEST_DIR/Mail/context
164 echo 'foo1 1 3-4' > $expected
165 run_prog fnext > $actual 2>&1
166 check $expected $actual
167
168 # test fnext with no current folder
169 start_test 'test fnext with no current folder'
170 rm $MH_TEST_DIR/Mail/context
171 echo 'foo1 1 3-4' > $expected
172 run_prog fnext > $actual 2>&1
173 check $expected $actual
174
175 # test fnext with only one folder in the list
176 start_test 'test fnext with only one folder in the list'
177 cat > $folders <<EOF
178 inbox
179 EOF
180 echo 'inbox 1 3-4' > $expected
181 run_prog fnext -folders $folders > $actual 2>&1
182 check $expected $actual
183
184 finish_test
185
186 exit $failed