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