4 # MH_IMAP_TEST_SERVER=127.0.0.1 MH_IMAP_TEST_PORT=143 MH_IMAP_TEST_USER=test MH_IMAP_TEST_PASSWORD=test MH_IMAP_TEST_EMAIL_ADDRESS=test MH_IMAP_TEST_TLS=no MH_IMAP_TEST_MAILBOX_ROOT=test/ make check TESTS=test/imap/test-live
6 # MH_IMAP_TEST_SERVER=127.0.0.1 MH_IMAP_TEST_PORT=1043 MH_IMAP_TEST_USER=test MH_IMAP_TEST_PASSWORD=testpw MH_IMAP_TEST_EMAIL_ADDRESS=test MH_IMAP_TEST_TLS=no MH_IMAP_SERVER_EATS_TRAILING_EOL=' ' make check TESTS=test/imap/test-live
8 # MH_IMAP_TEST_SERVER=panda make check TESTS=test/imap/test-live
9 # Gandi (looks like they use Dovecot)
10 # MH_IMAP_TEST_SERVER=mail.gandi.net MH_IMAP_TEST_PORT=imaps MH_IMAP_TEST_USER=... MH_IMAP_TEST_PASSWORD='...' MH_IMAP_TEST_EMAIL_ADDRESS=test@pretzelnet.org MH_IMAP_TEST_TLS=implicit MH_IMAP_TEST_MAILBOX_ROOT=test/ make check TESTS=test/imap/test-live
12 # MH_IMAP_TEST_SERVER=gmail MH_IMAP_TEST_PORT=imaps MH_IMAP_TEST_USER=... MH_IMAP_TEST_OAUTH_FILE="/path/to/oauth-gmail" MH_IMAP_TEST_EMAIL_ADDRESS=... MH_IMAP_TEST_MAILBOX_ROOT=test/ make check TESTS=test/imap/test-live
14 testname
=${0#$srcdir/}
16 if test -z "$MH_OBJ_DIR"; then
17 srcdir
=`dirname "$0"`/..
/..
18 MH_OBJ_DIR
=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
21 .
"$MH_OBJ_DIR/test/common.sh"
23 if [ -z "$MH_IMAP_TEST_SERVER" ]; then
24 test_skip
'no IMAP test server selected'
28 rm -f "$MH_TEST_DIR/$profile/imap.d/socket"
30 LLVM_PROFILE_FILE
="$covdir/$profile-%m.profraw" "$MH_OBJ_DIR/target/debug/mhimap" imap start
> "$actual" 2>&1 || status
=$?
33 MH_template
="$MH_TEST_DIR/template.mh_profile"
34 components_template
="$MH_TEST_DIR/template.components"
35 scan_template
="$MH_TEST_DIR/template.scan.nodate"
37 rm -f "$MH_template" "$components_template" "$scan_template"
38 rm -rf "$MH_TEST_DIR/dovecot" "$MH_TEST_DIR/panda"
40 rm -rf "$MH_TEST_DIR"/*/imap.d
43 #### Save exit status to use as status for this program.
47 if [ -z "$MH_TEST_NOCLEANUP" ]; then
48 for i
in $test_folders; do
49 rmf
+$i -nointeractive
53 [ -n "$imapd_pid" ] && kill $imapd_pid
55 for profile
in $profiles; do
56 set_mh_profile
$profile
57 "$MH_OBJ_DIR/target/debug/mhimap" imap shutdown
60 # TODO have cleanup allow additional cleanup registration?
61 # Or just allow it to accept status as argument.
66 if [ "$MH_IMAP_TEST_SERVER" = 'panda' ]; then
67 # TODO It seems drafts are born unseen on Cyrus and GMail.
68 MH_IMAP_SERVER_DRAFT_BORN_UNSEEN
=' '
69 # TODO Why is Cyrus eating the trailing CRLF?
70 # I'm planning to use refile -file instead of comp anyway; will that help?
71 MH_IMAP_SERVER_EATS_TRAILING_EOL
=' '
72 [ -z "$LOGNAME" ] && fail
'LOGNAME not set'
73 MH_IMAP_TEST_EMAIL_ADDRESS
="$LOGNAME"
74 mkdir "$MH_TEST_DIR/panda"
75 # Thought creating this stopped Panda from looking at the developer's real
76 # inbox, but it doesn't stop it from mangling /var/mail!
77 # TODO Ship customized Panda for testing.
78 touch "$MH_TEST_DIR/panda/mbox"
79 start_fakeinetd env
"HOME=$MH_TEST_DIR/panda" "$PANDA_IMAPD"
80 imapd_pid
=$fakeinetd_pid
81 cat > "$MH_template" <<EOF
83 imap-port: $fakeinetd_port
85 imap-tls: don't protect my data i know what i'm doing
86 imap-mailbox-root: test/
88 elif [ "$MH_IMAP_TEST_SERVER" = dovecot
]; then
89 # TODO dovecot "-Fc$MH_TEST_DIR/dovecot/cf"
90 # currently starting manually before running tests:
91 # rm -rf .o/std/dovecot && mkdir .o/std/dovecot && dovecot -Fcdocs/imap/testing/dovecot.conf &
92 cat > "$MH_TEST_DIR/dovecot/cf" <<EOF
93 base_dir = $MH_TEST_DIR/dovecot
94 state_dir = $MH_TEST_DIR/dovecot/db
95 log_path = $MH_TEST_DIR/dovecot/log
97 default_internal_user = $LOGNAME
98 default_login_user = $LOGNAME
99 default_internal_group = $LOGNAME
101 mail_location = mbox:$MH_TEST_DIR/dovecot/db/mail/%d/%1n/%n:INDEX=$MH_TEST_DIR/dovecot/db/indexes/%d/%1n/%n
124 inet_listener imaps {
129 elif [ "$MH_IMAP_TEST_SERVER" = 'gmail' ]; then
130 # * LIST (\All \HasNoChildren) "/" "[Gmail]/All Mail"
131 cat > "$MH_template" <<EOF
132 oauth-gmail-credential-file: $MH_IMAP_TEST_OAUTH_FILE
133 imap-host: imap.gmail.com
135 imap-user: $MH_IMAP_TEST_USER
138 imap-saslmech: xoauth2
139 imap-authservice: gmail
141 if [ -n "$MH_IMAP_TEST_MAILBOX_ROOT" ]; then
142 echo "imap-mailbox-root: $MH_IMAP_TEST_MAILBOX_ROOT" >> "$MH_template"
144 elif [ -z "$MH_IMAP_TEST_PORT" ] \
145 || [ -z "$MH_IMAP_TEST_TLS" ] \
146 || [ -z "$MH_IMAP_TEST_USER" ] \
147 || [ -z "$MH_IMAP_TEST_PASSWORD" ] \
148 || [ -z "$MH_IMAP_TEST_EMAIL_ADDRESS" ]; then
149 fail
'MH_IMAP_TEST_PORT MH_IMAP_TEST_USER MH_IMAP_TEST_PASSWORD MH_IMAP_TEST_EMAIL_ADDRESS must all be set'
151 case $MH_IMAP_TEST_TLS in
153 MH_IMAP_TEST_TLS
="don't protect my data i know what i'm doing"
156 MH_IMAP_TEST_TLS
="implicit but don't verify the cert i already did out of band"
159 cat > "$MH_TEST_DIR/netrc" <<EOF
160 machine $MH_IMAP_TEST_SERVER login $MH_IMAP_TEST_USER password $MH_IMAP_TEST_PASSWORD
162 cat >> "$MH_template" <<EOF
163 credentials: file-nopermcheck:$MH_TEST_DIR/netrc
164 imap-host: $MH_IMAP_TEST_SERVER
165 imap-port: $MH_IMAP_TEST_PORT
166 imap-user: $MH_IMAP_TEST_USER
168 imap-tls: $MH_IMAP_TEST_TLS
170 if [ -n "$MH_IMAP_TEST_MAILBOX_ROOT" ]; then
171 echo "imap-mailbox-root: $MH_IMAP_TEST_MAILBOX_ROOT" >> "$MH_template"
175 # it seems with cyrus everything has to go under INBOX? i probably
176 # messed something up but whatever, let's roll with it.
177 # * LIST (\HasChildren) "/" INBOX
178 #* LIST (\HasNoChildren) "/" INBOX/foo
180 imap_folder
=imap
/imap$
(date '+%j%H%M%S')
182 cat >> "$MH_template" <<EOF
183 Unseen-Sequence: unseen
184 Local-Mailbox: $MH_IMAP_TEST_EMAIL_ADDRESS
185 Draft-Folder: $imap_folder/drafts
186 Managed-Folders: imap
188 imap-manager: $MH_OBJ_DIR/target/debug/imap-folder-manager
191 cat > "$scan_template" <<EOF
192 %4(msg)%<(cur)+%| %>%<(unseen)U%| %>%<{replied}-%| %>\
193 %<(mymbox{from})%<{to}To:%(unquote(decode(friendly{to})))%>%>\
194 %<(zero)%(unquote(decode(friendly{from})))%> \
195 %(decode{subject})%<{body}<<%{body}>>%>
198 # TODO default components use '--------' to close header...
199 cat > "$components_template" <<EOF
200 %<{from}%|%(void(localmbox))%>%(void(width))%(putaddr From: )
201 %<{to}%(void(width))%(putaddr To: )%|To:%>
202 %<{cc}%(void(width))%(putaddr cc: )%|cc:%>
203 Fcc: %<{fcc}%(putstr)%|+outbox%>
204 Subject:%<{subject} %(putstr)%>
209 expected
="$MH_TEST_DIR/$$.expected"
210 actual
="$MH_TEST_DIR/$$.actual"
212 ################################################################################
214 rm -rf "$MH_TEST_DIR/$profile"
215 setup_test_without_data
$profile
218 cat "$MH_template" >> "$MH"
219 cp "$components_template" "$MH_TEST_DIR/$profile/components"
220 cp "$scan_template" "$MH_TEST_DIR/$profile/scan.nodate"
221 if [ -n "$MH_TEST_IMAP_LOG_LEVEL" ]; then
222 echo "imap-log-level: $MH_TEST_IMAP_LOG_LEVEL" >> "$MH"
223 echo "imap-log-$MH_TEST_IMAP_LOG_LEVEL-to: $MH_TEST_DIR/$profile/imap.d/log.$MH_TEST_IMAP_LOG_LEVEL" >> "$MH"
226 # Set this for the EHLO command
227 echo "clientname: nosuchhost.example.com" >> "$MHMTSCONF"
230 imap-socket: $MH_TEST_DIR/$profile/imap.d/socket
231 imap-db: $MH_TEST_DIR/$profile/imap.d
234 covdir
="$MH_OBJ_DIR/covdata/${MH_COVERAGE_PROFILE:-default}/$testname"
238 ################################################################################
240 ################################################################################
241 start_test
'folder -create'
243 cat > "$expected" <<EOF
244 $imap_folder/drafts+ has no messages.
245 $imap_folder/sent+ has no messages.
247 test_folders
="$imap_folder/drafts $imap_folder/sent"
248 (run_prog folder
+$imap_folder/drafts
-create \
249 && run_prog folder
+$imap_folder/sent
-create) > "$actual"
250 check
"$actual" "$expected"
252 check_exit
'-eq 0' "$MH_OBJ_DIR/target/debug/mhimap" imap check
$imap_folder/drafts
253 check_exit
'-eq 0' "$MH_OBJ_DIR/target/debug/mhimap" imap check
$imap_folder/sent
255 ################################################################################
256 start_test
'inc when nothing to fetch'
258 cat /dev
/null
> "$expected"
259 check_exit
'-eq 0' inc
+imap
-width 80
261 ################################################################################
262 start_test
'comp creates draft in empty draft folder'
264 check_exit
'-eq 0' comp
-noedit -to "$MH_IMAP_TEST_EMAIL_ADDRESS" -fcc $imap_folder/sent
-subject 'testing imap' -nowhatnowproc
266 # comp creates a message, stores a UID/msgnum pair, runs the user's editor,
267 # creates a new message with the user's edits, and replaces the UID/msgnum pair.
268 # So verify the integrity of the database after that.
269 # TODO any other operations worth having this integrity check on?
270 check_exit
'-eq 0' "$MH_OBJ_DIR/target/debug/mhimap" imap check
$imap_folder/drafts
272 start_test
'scan drafts after comp'
273 cat > "$expected" <<EOF
274 1 To:$MH_IMAP_TEST_EMAIL_ADDRESS testing imap<<body >>
276 run_prog scan
-form scan.nodate
+$imap_folder/drafts
-width 80 > "$actual"
277 check
"$actual" "$expected"
279 start_test
'show draft after comp'
280 cat > "$expected" <<EOF
281 (Message $imap_folder/drafts:1)
283 To: $MH_IMAP_TEST_EMAIL_ADDRESS
285 From: $MH_IMAP_TEST_EMAIL_ADDRESS
286 Subject: testing imap
288 Fcc: $imap_folder/sent
292 run_prog show
+$imap_folder/drafts
1 > "$actual"
293 check
"$actual" "$expected"
295 start_test
'check .mh_sequences after show after comp'
296 cat > "$expected" <<EOF
299 check
"$MH_TEST_DIR/$profile/$imap_folder/drafts/.mh_sequences" "$expected" 'keep first'
301 ################################################################################
302 start_test
'comp creates draft in non-empty draft folder'
304 check_exit
'-eq 0' comp
-noedit -to "$MH_IMAP_TEST_EMAIL_ADDRESS" -fcc $imap_folder/sent
-subject 'testing imap 2' -nowhatnowproc
306 check_exit
'-eq 0' "$MH_OBJ_DIR/target/debug/mhimap" imap check
$imap_folder/drafts
308 start_test
'scan non-empty drafts after comp'
309 cat > "$expected" <<EOF
310 1+ To:$MH_IMAP_TEST_EMAIL_ADDRESS testing imap<<body >>
311 2 To:$MH_IMAP_TEST_EMAIL_ADDRESS testing imap 2<<body >>
313 run_prog scan
-form scan.nodate
+$imap_folder/drafts
-width 80 > "$actual"
314 check
"$actual" "$expected"
316 start_test
'check .mh_sequences after non-empty comp'
317 cat > "$expected" <<EOF
321 check
"$MH_TEST_DIR/$profile/$imap_folder/drafts/.mh_sequences" "$expected" 'keep first'
323 ################################################################################
324 start_test
'send refiles draft to fcc folder'
326 arith_eval
64000 + $$
% 1000
328 "$MH_OBJ_DIR/test/fakesmtp" /dev
/null
$localport > /dev
/null
329 check_exit
'-eq 0' send
-server 127.0.0.1 -port $localport -draftfolder $imap_folder/drafts
332 check_exit
'-eq 0' "$MH_OBJ_DIR/target/debug/mhimap" imap check
$imap_folder/drafts
333 check_exit
'-eq 0' "$MH_OBJ_DIR/target/debug/mhimap" imap check
$imap_folder/sent
335 # TODO what?! this test started out as this and evolved into something else?
336 start_test
'scan drafts finds no messages after send'
338 # Check draft moved to FCC folder
339 cat > "$expected" <<EOF
340 2 To:$MH_IMAP_TEST_EMAIL_ADDRESS testing imap 2<<body >>
342 run_prog scan
-form scan.nodate
+$imap_folder/drafts
-width 80 > "$actual"
343 check
"$actual" "$expected"
345 start_test
'scan sent finds the sent messages after send'
347 cat > "$expected" <<EOF
348 1 To:$MH_IMAP_TEST_EMAIL_ADDRESS testing imap<<body >>
350 run_prog scan
-form scan.nodate
+$imap_folder/sent
-width 80 > "$actual"
351 check
"$actual" "$expected"
353 ################################################################################
355 rm -rf "$MH_TEST_DIR/$profile"
356 setup_test_without_data
$profile
359 cat "$MH_template" >> "$MH"
360 cp "$components_template" "$MH_TEST_DIR/$profile/components"
361 cp "$scan_template" "$MH_TEST_DIR/$profile/scan.nodate"
362 if [ -n "$MH_TEST_IMAP_LOG_LEVEL" ]; then
363 echo "imap-log-level: $MH_TEST_IMAP_LOG_LEVEL" >> "$MH"
364 echo "imap-log-$MH_TEST_IMAP_LOG_LEVEL-to: $MH_TEST_DIR/$profile/imap.d/log.$MH_TEST_IMAP_LOG_LEVEL" >> "$MH"
368 imap-socket: $MH_TEST_DIR/$profile/imap.d/socket
369 imap-db: $MH_TEST_DIR/$profile/imap.d
373 ################################################################################
375 ################################################################################
376 start_test
'inc on empty managed folder fetches all mail in that folder'
378 cat > "$expected" <<EOF
379 Incorporating new mail into $imap_folder/drafts...
381 1 $MH_IMAP_SERVER_DRAFT_BORN_UNSEEN To:$MH_IMAP_TEST_EMAIL_ADDRESS testing imap 2<<body$MH_IMAP_SERVER_EATS_TRAILING_EOL>>
382 Incorporating new mail into $imap_folder/sent...
384 1 To:$MH_IMAP_TEST_EMAIL_ADDRESS testing imap<<body$MH_IMAP_SERVER_EATS_TRAILING_EOL>>
387 inc
+imap
-form scan.nodate
-width 80 > "$actual"
388 check
"$actual" "$expected"
390 check_exit
'-eq 0' "$MH_OBJ_DIR/target/debug/mhimap" imap check
$imap_folder/drafts
391 check_exit
'-eq 0' "$MH_OBJ_DIR/target/debug/mhimap" imap check
$imap_folder/sent
393 ################################################################################
394 start_test
'show the sent message after inc'
396 cat > "$expected" <<EOF
397 (Message $imap_folder/sent:1)
400 To: $MH_IMAP_TEST_EMAIL_ADDRESS
401 From: $MH_IMAP_TEST_EMAIL_ADDRESS
402 Subject: testing imap
408 if [ -n "$MH_IMAP_SERVER_EATS_TRAILING_EOL" ]; then
409 echo 'body
' >> "$expected"
411 echo -n body
>> "$expected"
414 run_prog show
+$imap_folder/sent
1 > "$actual"
415 sed -e 's/^Date:.*/Date:/' "$actual" > "$actual".nodate
417 check
"$actual.nodate" "$expected"
419 ################################################################################
420 start_test
'mark the sent message unseen'
422 check_exit
'-eq 0' mark
-add -seq unseen
+$imap_folder/sent
1
424 start_test
'scan after mark unseen'
426 cat > "$expected" <<EOF
427 1+U To:$MH_IMAP_TEST_EMAIL_ADDRESS testing imap<<body$MH_IMAP_SERVER_EATS_TRAILING_EOL>>
429 run_prog scan
-form scan.nodate
-width 80 > "$actual"
430 check
"$actual" "$expected"
432 ################################################################################
433 start_test
'show the now-unseen message'
435 check_exit
'-eq 0' show all
437 start_test
'scan after show'
439 cat > "$expected" <<EOF
440 1+ To:$MH_IMAP_TEST_EMAIL_ADDRESS testing imap<<body$MH_IMAP_SERVER_EATS_TRAILING_EOL>>
442 run_prog scan
-form scan.nodate
-width 80 > "$actual"
443 check
"$actual" "$expected"
445 ################################################################################
446 start_test
'refile -file'
448 refiled_file
="$MH_TEST_DIR/$$.refiled-file"
449 cat > "$refiled_file" <<EOF
450 Date:Sat, 24 Oct 2020 19:20:38 -0500
456 check_exit
'-eq 0' refile
-file "$refiled_file" +$imap_folder/drafts
457 if [ -e "$refiled_file" ]; then
458 rm -f "$refiled_file" || :
459 fail
"$refiled_file missing after refile"
462 start_test
'scan dst folder after refile -file finds refiled message'
464 cat > "$expected" <<EOF
465 1 To:$MH_IMAP_TEST_EMAIL_ADDRESS testing imap 2<<body$MH_IMAP_SERVER_EATS_TRAILING_EOL>>
466 2 me <<refile-test >>
468 scan
-form scan.nodate
-width 80 +$imap_folder/drafts
> "$actual"
469 check
"$actual" "$expected"
471 check_exit
'-eq 0' "$MH_OBJ_DIR/target/debug/mhimap" imap check
$imap_folder/drafts
473 ################################################################################
476 check_exit
'-eq 0' refile
-src +$imap_folder/drafts
2 +$imap_folder/sent
478 # TODO what?! this test started out as this and evolved into something else?
479 start_test
'scan src folder after refile finds no messages'
481 cat > "$expected" <<EOF
482 1 To:$MH_IMAP_TEST_EMAIL_ADDRESS testing imap 2<<body$MH_IMAP_SERVER_EATS_TRAILING_EOL>>
484 scan
-form scan.nodate
-width 80 +$imap_folder/drafts
> "$actual"
485 check
"$actual" "$expected"
487 start_test
'scan dst folder after refile finds refiled message'
489 cat > "$expected" <<EOF
490 1+ To:$MH_IMAP_TEST_EMAIL_ADDRESS testing imap<<body$MH_IMAP_SERVER_EATS_TRAILING_EOL>>
491 2 me <<refile-test >>
493 scan
-form scan.nodate
-width 80 +$imap_folder/sent
> "$actual"
494 check
"$actual" "$expected"
496 check_exit
'-eq 0' "$MH_OBJ_DIR/target/debug/mhimap" imap check
$imap_folder/drafts
497 check_exit
'-eq 0' "$MH_OBJ_DIR/target/debug/mhimap" imap check
$imap_folder/sent
499 ################################################################################
500 start_test
'mark unseen after refile'
502 # This tests the UID update in the local database.
504 check_exit
'-eq 0' mark
-add -seq unseen
2
505 cat > "$expected" <<EOF
506 1+ To:$MH_IMAP_TEST_EMAIL_ADDRESS testing imap<<body$MH_IMAP_SERVER_EATS_TRAILING_EOL>>
507 2 U me <<refile-test >>
509 scan
-form scan.nodate
-width 80 +$imap_folder/sent
> "$actual"
510 check
"$actual" "$expected"
512 ################################################################################
513 start_test
'show all before rmm'
515 cat > "$expected" <<EOF
516 >>> $imap_folder/sent:1
520 To: $MH_IMAP_TEST_EMAIL_ADDRESS
521 From: $MH_IMAP_TEST_EMAIL_ADDRESS
522 Subject: testing imap
528 if [ -n "$MH_IMAP_SERVER_EATS_TRAILING_EOL" ]; then
529 echo 'body
' >> "$expected"
531 echo -n body
>> "$expected"
533 cat >> "$expected" <<EOF
537 >>> $imap_folder/sent:2
546 # TODO Why is this one unaffected?! Really need to get to the bottom of this...
547 if [ -n "$MH_IMAP_SERVER_EATS_TRAILING_EOL" ]; then
548 echo refile-test
>> "$expected"
550 echo refile-test
>> "$expected"
553 run_prog show
+$imap_folder/sent all
> "$actual"
554 sed -e 's/^Date:.*/Date:/' "$actual" > "$actual.nodate"
556 check
"$actual.nodate" "$expected"
558 start_test
'check .mh_sequences after show before rmm'
559 cat > "$expected" <<EOF
562 check
"$MH_TEST_DIR/$profile/$imap_folder/sent/.mh_sequences" "$expected" 'keep first'
564 ################################################################################
565 start_test
'show cur shows 2 after show all'
567 cat > "$expected" <<EOF
568 (Message $imap_folder/sent:2)
570 Date: Sat, 24 Oct 2020 19:20:38 -0500
576 # TODO Why is this one unaffected?! Really need to get to the bottom of this...
577 if [ -n "$MH_IMAP_SERVER_EATS_TRAILING_EOL" ]; then
578 echo refile-test
>> "$expected"
580 echo refile-test
>> "$expected"
583 run_prog show
+$imap_folder/sent
> "$actual"
584 check
"$actual" "$expected"
586 start_test
'check .mh_sequences after show cur shows 2 after show all'
587 cat > "$expected" <<EOF
590 check
"$MH_TEST_DIR/$profile/$imap_folder/sent/.mh_sequences" "$expected" 'keep first'
592 ################################################################################
593 start_test
'show 1 before rmm'
595 cat > "$expected" <<EOF
596 (Message $imap_folder/sent:1)
599 To: $MH_IMAP_TEST_EMAIL_ADDRESS
600 From: $MH_IMAP_TEST_EMAIL_ADDRESS
601 Subject: testing imap
607 if [ -n "$MH_IMAP_SERVER_EATS_TRAILING_EOL" ]; then
608 echo 'body
' >> "$expected"
610 echo -n body
>> "$expected"
613 run_prog show
+$imap_folder/sent
1 > "$actual"
614 sed -e 's/^Date:.*/Date:/' "$actual" > "$actual".nodate
616 check
"$actual.nodate" "$expected"
618 start_test
'check .mh_sequences after show 1 before rmm'
619 cat > "$expected" <<EOF
622 check
"$MH_TEST_DIR/$profile/$imap_folder/sent/.mh_sequences" "$expected" 'keep first'
624 ################################################################################
625 start_test
'show cur shows 1 after show 1'
627 cat > "$expected" <<EOF
628 (Message $imap_folder/sent:1)
631 To: $MH_IMAP_TEST_EMAIL_ADDRESS
632 From: $MH_IMAP_TEST_EMAIL_ADDRESS
633 Subject: testing imap
639 if [ -n "$MH_IMAP_SERVER_EATS_TRAILING_EOL" ]; then
640 echo 'body
' >> "$expected"
642 echo -n body
>> "$expected"
645 run_prog show
+$imap_folder/sent
> "$actual"
646 sed -e 's/^Date:.*/Date:/' "$actual" > "$actual".nodate
648 check
"$actual.nodate" "$expected"
650 start_test
'check .mh_sequences after show cur shows 1 after show 1'
651 cat > "$expected" <<EOF
654 check
"$MH_TEST_DIR/$profile/$imap_folder/sent/.mh_sequences" "$expected" 'keep first'
656 ################################################################################
659 check_exit
'-eq 0' rmm
-unlink 2
661 start_test
'scan after rmm'
663 cat > "$expected" <<EOF
664 1+ To:$MH_IMAP_TEST_EMAIL_ADDRESS testing imap<<body$MH_IMAP_SERVER_EATS_TRAILING_EOL>>
666 scan
-form scan.nodate
-width 80 +$imap_folder/sent
> "$actual"
667 check
"$actual" "$expected"
669 check_exit
'-eq 0' "$MH_OBJ_DIR/target/debug/mhimap" imap check
$imap_folder/sent
671 ################################################################################
672 start_test
'inc finds messages to delete 1. create messages in profile2'
674 for i
in 2 3 4 5 6; do
675 refiled_file
="$MH_TEST_DIR/$$.refiled-file"
676 cat > "$refiled_file" <<EOF
677 Date:Sat, 24 Oct 2020 19:20:38 -0500
684 check_exit
'-eq 0' refile
-file "$refiled_file" +$imap_folder/drafts
685 if [ -e "$refiled_file" ]; then
686 rm -f "$refiled_file" || :
687 fail
"$refiled_file missing after refile"
691 cat > "$expected" <<EOF
692 1 To:$MH_IMAP_TEST_EMAIL_ADDRESS testing imap 2<<body$MH_IMAP_SERVER_EATS_TRAILING_EOL>>
693 2 me refile 2<<refile-test 2 >>
694 3 me refile 3<<refile-test 3 >>
695 4 me refile 4<<refile-test 4 >>
696 5 me refile 5<<refile-test 5 >>
697 6 me refile 6<<refile-test 6 >>
699 scan
-form scan.nodate
-width 80 +$imap_folder/drafts
> "$actual"
700 check
"$actual" "$expected"
702 for i
in $test_folders; do
703 check_exit
'-eq 0' "$MH_OBJ_DIR/target/debug/mhimap" imap check
$i
706 ################################################################################
707 start_test
'inc finds messages to delete 2. inc new messages into profile1'
709 set_mh_profile profile1
711 # Message numbers are one greater in profile1 than in profile2.
712 cat > "$expected" <<EOF
713 Incorporating new mail into $imap_folder/drafts...
715 3 me refile 2<<refile-test 2$MH_IMAP_SERVER_EATS_TRAILING_EOL>>
716 4 me refile 3<<refile-test 3$MH_IMAP_SERVER_EATS_TRAILING_EOL>>
717 5 me refile 4<<refile-test 4$MH_IMAP_SERVER_EATS_TRAILING_EOL>>
718 6 me refile 5<<refile-test 5$MH_IMAP_SERVER_EATS_TRAILING_EOL>>
719 7 me refile 6<<refile-test 6$MH_IMAP_SERVER_EATS_TRAILING_EOL>>
721 inc
+imap
-form scan.nodate
-width 80 > "$actual" || :
722 check
"$actual" "$expected"
724 ################################################################################
725 start_test
'inc finds messages to delete 3. rmm messages out of profile2'
727 set_mh_profile profile2
729 check_exit
'-eq 0' rmm
-unlink 2
730 check_exit
'-eq 0' rmm
-unlink 4
731 check_exit
'-eq 0' rmm
-unlink 5
733 cat > "$expected" <<EOF
734 1 To:$MH_IMAP_TEST_EMAIL_ADDRESS testing imap 2<<body$MH_IMAP_SERVER_EATS_TRAILING_EOL>>
735 3 me refile 3<<refile-test 3 >>
736 6 me refile 6<<refile-test 6 >>
738 scan
-form scan.nodate
-width 80 +$imap_folder/drafts
> "$actual"
739 check
"$actual" "$expected"
741 ################################################################################
742 start_test
'inc finds messages to delete 4. inc deletes from profile1'
744 set_mh_profile profile1
746 inc
+imap
-form scan.nodate
-width 80 > "$actual" || :
747 check
/dev
/null
"$actual" 'keep first'
749 ################################################################################
750 start_test
'inc finds messages to delete 5. scan profile1 to see messages gone'
752 # Message numbers are one greater in profile1 than in profile2.
753 cat > "$expected" <<EOF
754 2 To:$MH_IMAP_TEST_EMAIL_ADDRESS testing imap 2<<body >>
755 4 me refile 3<<refile-test 3$MH_IMAP_SERVER_EATS_TRAILING_EOL>>
756 7 me refile 6<<refile-test 6$MH_IMAP_SERVER_EATS_TRAILING_EOL>>
758 scan
-form scan.nodate
-width 80 +$imap_folder/drafts
> "$actual"
759 check
"$actual" "$expected"
762 # - refile old message into a folder with newer messages: UID validity preserved?
764 ################################################################################
765 start_test
'check all folder databases one last time'
767 for profile
in $profiles; do
768 set_mh_profile
$profile
769 for i
in $test_folders; do
770 check_exit
'-eq 0' "$MH_OBJ_DIR/target/debug/mhimap" imap check
$i