5 if test -z "$MH_OBJ_DIR"; then
6 srcdir
=`dirname "$0"`/..
/..
7 MH_OBJ_DIR
=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
10 .
"$MH_OBJ_DIR/test/common.sh"
12 setup_test_without_data Mail
14 rm -rf "$MH_TEST_DIR/panda"
17 #### Save exit status to use as status for this program.
21 [ -n "$imapd_pid" ] && kill $imapd_pid
22 "$MH_OBJ_DIR/target/debug/mhimap" imap shutdown
24 # TODO have cleanup allow additional cleanup registration?
25 # Or just allow it to accept status as argument.
31 covdir
="$MH_OBJ_DIR/covdata/${MH_COVERAGE_PROFILE:-default}/$testname"
33 export LLVM_PROFILE_FILE
="$covdir/$profile-%m.profraw"
35 start_fakeinetd env
"HOME=$MH_TEST_DIR/panda" "$PANDA_IMAPD"
36 imapd_pid
=$fakeinetd_pid
39 Unseen-Sequence: unseen
41 imap-manager: $MH_OBJ_DIR/target/debug/imap-folder-manager
42 imap-socket: $MH_TEST_DIR/Mail/imap.d/socket
43 imap-db: $MH_TEST_DIR/Mail/imap.d
45 imap-port: $fakeinetd_port
47 imap-tls: don't protect my data i know what i'm doing
48 imap-mailbox-root: test/
50 if [ -n "$MH_TEST_IMAP_LOG_LEVEL" ]; then
51 echo "imap-log-level: $MH_TEST_IMAP_LOG_LEVEL" >> "$MH"
52 echo "imap-log-$MH_TEST_IMAP_LOG_LEVEL-to: $MH_TEST_DIR/$profile/imap.d/log.$MH_TEST_IMAP_LOG_LEVEL" >> "$MH"
55 mkdir "$MH_TEST_DIR/panda"
56 mkdir "$MH_TEST_DIR/panda/test"
58 expected
="$MH_TEST_DIR/$$.expected"
59 actual
="$MH_TEST_DIR/$$.actual"
61 # TODO duplicated with test-inc
65 cat > $MH_TEST_DIR/panda
/test
/fold <<EOF
66 From nmh@example.com Sat Oct 24 19:20:38 2020 -0500
67 Date:Sat, 24 Oct 2020 19:20:38 -0500
70 X-IMAPbase: 1603585238 $message_count testseq
79 echo " $arith_val 10/24 me <<body >>" > "$expected.scan-all"
81 while [ $arith_val -lt $message_count ]; do
82 arith_eval
$arith_val + 1
83 printf ' %2d 10/24 me <<body >>\n' $arith_val >> "$expected.scan-all"
84 printf ' %2d U 10/24 me <<body >>\n' $arith_val >> "$expected.scan-unseen"
85 cat >> $MH_TEST_DIR/panda
/test
/fold <<EOF
86 From nmh@example.com Sat Oct 24 19:20:38 2020 -0500
87 Date:Sat, 24 Oct 2020 19:20:38 -0500
98 arith_eval
$arith_val + 1
99 if [ $arith_val -ne $removed_message ]; then
100 printf ' %2d U 10/24 me <<body >>\n' $arith_val >> "$expected.scan-unseen"
101 printf ' %2d 10/24 me <<body >>\n' $arith_val >> "$expected.scan-all"
103 cat >> $MH_TEST_DIR/panda
/test
/fold <<EOF
104 From nmh@example.com Sat Oct 24 19:20:38 2020 -0500
105 Date:Sat, 24 Oct 2020 19:20:38 -0500
118 start_test
'inc then remove mesage 5'
119 check_exit
'-eq 0' inc
+imap
120 check_exit
'-eq 0' rmm
-unlink +imap
/fold $removed_message
122 ################################################################################
123 start_test
'scan all implicitly'
125 run_prog scan
+imap
/fold -width 80 > "$actual"
126 check
"$expected.scan-all" "$actual" 'keep first'
128 ################################################################################
129 start_test
'scan all explicitly'
131 run_prog scan
+imap
/fold -width 80 all
> "$actual"
132 check
"$expected.scan-all" "$actual" 'keep first'
134 ################################################################################
135 start_test
'scan unseen'
137 run_prog scan
+imap
/fold -form scan.unseen
-width 80 unseen
> "$actual"
138 check
"$expected.scan-unseen" "$actual"
140 cat > "$expected" <<EOF
144 check
"$MH_TEST_DIR/Mail/imap/fold/.mh_sequences" "$expected" 'keep first'
146 ################################################################################
147 start_test
'scan some messages'
149 cat > "$expected" <<EOF
150 2 U 10/24 me <<body >>
151 3 U 10/24 me <<body >>
152 4 U 10/24 me <<body >>
153 6 U 10/24 me <<body >>
154 8 U 10/24 me <<body >>
155 9 U 10/24 me <<body >>
156 10 U 10/24 me <<body >>
158 run_prog scan
+imap
/fold -form scan.unseen
-width 80 8-9 9-10 2-6 > "$actual"
159 check
"$expected" "$actual"
161 cat > "$expected" <<EOF
162 nmh-picked: 2-4 6 8-10
165 check
"$MH_TEST_DIR/Mail/imap/fold/.mh_sequences" "$expected" 'keep first'
167 ################################################################################
168 start_test
'scan non-existent message'
170 cat > "$expected" <<EOF
171 scan: no messages match specification
174 run_prog scan
+imap
/fold -form scan.unseen
-width 80 $removed_message > "$actual" 2>&1 || :
175 check
"$expected" "$actual"
177 ################################################################################
178 start_test
'mark -del testseq unseen'
180 check_exit
'-eq 0' mark
-add -seq testseq
6 8 10
182 check_exit
'-eq 0' scan testseq
184 check_exit
'-eq 0' mark
-del -seq testseq unseen
186 # TODO should be 'scan: bad message list testseq'
187 cat > "$expected" <<EOF
188 scan: no messages match specification
191 run_prog scan
+imap
/fold -form scan.unseen
-width 80 testseq
> "$actual" 2>&1 || :
192 check
"$expected" "$actual"
194 ################################################################################
195 start_test
'show unseen twice'
197 sed 's/^ 11 / 11+/' "$expected.scan-all" > "$expected"
199 check_exit
'-eq 0' show unseen unseen
201 run_prog scan
+imap
/fold -width 80 > "$actual"
202 check
"$expected" "$actual"
204 ################################################################################
205 start_test
'show 1-11'
207 sed 's/^ 11 / 11+/' "$expected.scan-all" > "$expected"
208 rm "$expected.scan-all"
210 check_exit
'-eq 0' show
1-11
212 ################################################################################
213 start_test
'scan testseq'
215 check_exit
'-eq 0' mark
-add -seq testseq
2-3 6-8 11
216 cat > "$expected" <<EOF
222 11+ 10/24 me <<body >>
224 run_prog scan
+imap
/fold -form scan.unseen
-width 80 testseq
> "$actual"
225 check
"$expected" "$actual"
227 ################################################################################
228 start_test
'mark -del testseq 1'
230 check_exit
'-eq 0' mark
-del -seq testseq
2
232 cat > "$expected" <<EOF
237 11+ 10/24 me <<body >>
239 run_prog scan
+imap
/fold -form scan.unseen
-width 80 testseq
> "$actual"
240 check
"$expected" "$actual"
242 ################################################################################
243 start_test
'mark -del testseq all'
245 check_exit
'-eq 0' mark
-del -seq testseq testseq
247 ################################################################################
248 start_test
'scan testseq after mark -del'
250 # TODO should be 'scan: bad message list testseq'
251 cat > "$expected" <<EOF
252 scan: no messages match specification
255 run_prog scan
+imap
/fold -form scan.unseen
-width 80 testseq
> "$actual" 2>&1 || :
256 check
"$expected" "$actual"