3 # TODO this must have bitrotted to oblivion...
7 # setup copied from test-scan
9 if test -z "$MH_OBJ_DIR"; then
10 srcdir
=`dirname "$0"`/..
/..
11 MH_OBJ_DIR
=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
14 .
"$MH_OBJ_DIR/test/common.sh"
16 setup_test_without_data Mail
18 rm -rf "$MH_TEST_DIR/panda"
21 #### Save exit status to use as status for this program.
25 [ -n "$imapd_pid" ] && kill $imapd_pid
26 "$MH_OBJ_DIR/target/debug/mhimap" imap shutdown
28 # TODO have cleanup allow additional cleanup registration?
29 # Or just allow it to accept status as argument.
35 covdir
="$MH_OBJ_DIR/covdata/${MH_COVERAGE_PROFILE:-default}/$testname"
37 export LLVM_PROFILE_FILE
="$covdir/$profile-%m.profraw"
39 start_fakeinetd env
"HOME=$MH_TEST_DIR/panda" "$PANDA_IMAPD"
40 imapd_pid
=$fakeinetd_pid
42 # TODO imap-manager: $MH_LIBEXEC_DIR/folder-managers/imap
43 # TODO imap-socket: relative path
44 # TODO can we come up with reasonable default of socket path?
47 imap-manager: $MH_OBJ_DIR/target/debug/imap-folder-manager
48 imap-socket: $MH_TEST_DIR/Mail/imap.d/socket
49 imap-db: $MH_TEST_DIR/Mail/imap.d
51 imap-port: $fakeinetd_port
53 imap-tls: don't protect my data i know what i'm doing
54 imap-mailbox-root: test/
56 if [ -n "$MH_TEST_IMAP_LOG_LEVEL" ]; then
57 echo "imap-log-level: $MH_TEST_IMAP_LOG_LEVEL" >> "$MH"
58 echo "imap-log-$MH_TEST_IMAP_LOG_LEVEL-to: $MH_TEST_DIR/$profile/imap.d/log.$MH_TEST_IMAP_LOG_LEVEL" >> "$MH"
61 mkdir "$MH_TEST_DIR/panda"
62 mkdir "$MH_TEST_DIR/panda/test"
64 expected
="$MH_TEST_DIR/$$.expected"
65 actual
="$MH_TEST_DIR/$$.actual"
68 cat > "$MH_TEST_DIR/panda/test/fold$i" <<EOF
69 From nmh@example.com Sat Oct 24 19:20:38 2020 -0500
70 Date:Sat, 24 Oct 2020 19:20:38 -0500
73 X-IMAPbase: 1603585238 1
79 initial message in fold$i
84 start_test
'initial inc'
86 cat > "$expected.inc" <<EOF
87 Incorporating new mail into imap/fold1...
89 1 10/24 me <<initial message in fold1 >>
90 Incorporating new mail into imap/fold2...
92 1 10/24 me <<initial message in fold2 >>
93 Incorporating new mail into imap/fold3...
95 1 10/24 me <<initial message in fold3 >>
99 check
"$actual" "$expected.inc"
101 ################################################################################
104 check_exit
'-eq 0' refile
-src +imap
/fold1
1 +imap
/fold2
106 start_test
'scan src folder after refile finds no messages'
108 cat > "$expected" <<EOF
109 scan: no messages match specification
111 scan
-width 80 +imap
/fold1
> "$actual" 2>&1 || :
112 check
"$actual" "$expected"
114 start_test
'scan dst folder after refile finds refiled message'
116 cat > "$expected" <<EOF
117 1 10/24 me <<initial message in fold2 >>
118 2+ 10/24 me <<initial message in fold1 >>
120 scan
-width 80 +imap
/fold2
> "$actual"
121 check
"$actual" "$expected"
123 ################################################################################
124 start_test
'refile -link -file'
126 refiled_file
="$MH_TEST_DIR/$$.refiled-file"
127 cat > "$refiled_file" <<EOF
128 Date:Sat, 24 Oct 2020 19:20:38 -0500
134 check_exit
'-eq 0' refile
-link -file "$refiled_file" +imap
/fold1
135 if [ -e "$refiled_file" ]; then
138 fail
"$refiled_file missing after refile -link"
141 start_test
'scan dst folder after refile -link -file finds refiled message'
143 cat > "$expected" <<EOF
144 1+ 10/24 me <<refile-link file >>
146 scan
-width 80 +imap
/fold1
> "$actual"
147 check
"$actual" "$expected"
149 ################################################################################
150 start_test
'refile -file'
152 refiled_file
="$MH_TEST_DIR/$$.refiled-file"
153 cat > "$refiled_file" <<EOF
154 Date:Sat, 24 Oct 2020 19:20:38 -0500
160 check_exit
'-eq 0' refile
-file "$refiled_file" +imap
/fold3
161 if [ -e "$refiled_file" ]; then
162 rm -f "$refiled_file" || :
163 fail
"$refiled_file missing after refile"
166 start_test
'scan dst folder after refile -file finds refiled message'
168 cat > "$expected" <<EOF
169 1 10/24 me <<initial message in fold3 >>
170 2+ 10/24 me <<refiled file >>
172 scan
-width 80 +imap
/fold3
> "$actual"
173 check
"$actual" "$expected"
175 ################################################################################
176 start_test
'rebuild local from scratch'
178 rm -rf "$MH_TEST_DIR/Mail/imap" "$MH_TEST_DIR/Mail/imap.d/imap"
180 cat > "$expected.inc" <<EOF
181 Incorporating new mail into imap/fold1...
183 1 10/24 me <<refile-link file >>
184 Incorporating new mail into imap/fold2...
186 1 10/24 me <<initial message in fold2 >>
187 2 10/24 me <<initial message in fold1 >>
188 Incorporating new mail into imap/fold3...
190 1 10/24 me <<initial message in fold3 >>
191 2 10/24 me <<refiled file >>
194 inc
+imap
> "$actual"
195 check
"$actual" "$expected.inc"