]> diplodocus.org Git - nmh/blob - test/imap/test-rmm
expect this commit to be force-replaced periodically
[nmh] / test / imap / test-rmm
1 #!/bin/sh
2
3 testname=${0#$srcdir/}
4
5 # setup copied from test-scan
6
7 if test -z "$MH_OBJ_DIR"; then
8 srcdir=`dirname "$0"`/../..
9 MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
10 fi
11
12 . "$MH_OBJ_DIR/test/common.sh"
13
14 setup_test_without_data Mail
15
16 rm -rf "$MH_TEST_DIR/panda"
17
18 imap_cleanup() {
19 #### Save exit status to use as status for this program.
20 status=$?
21 set +e
22
23 [ -n "$imapd_pid" ] && kill $imapd_pid
24 "$MH_OBJ_DIR/target/debug/mhimap" imap shutdown
25
26 # TODO have cleanup allow additional cleanup registration?
27 # Or just allow it to accept status as argument.
28 (exit $status)
29 cleanup
30 }
31 trap imap_cleanup 0
32
33 covdir="$MH_OBJ_DIR/covdata/${MH_COVERAGE_PROFILE:-default}/$testname"
34 install -d "$covdir"
35 export LLVM_PROFILE_FILE="$covdir/$profile-%m.profraw"
36
37 start_fakeinetd env "HOME=$MH_TEST_DIR/panda" "$PANDA_IMAPD"
38 imapd_pid=$fakeinetd_pid
39
40 # TODO imap-manager: $MH_LIBEXEC_DIR/folder-managers/imap
41 # TODO imap-socket: relative path
42 # TODO can we come up with reasonable default of socket path?
43 cat >> "$MH" <<EOF
44 Managed-Folders: imap
45 imap-manager: $MH_OBJ_DIR/target/debug/imap-folder-manager
46 imap-socket: $MH_TEST_DIR/Mail/imap.d/socket
47 imap-db: $MH_TEST_DIR/Mail/imap.d
48 imap-host: 127.0.0.1
49 imap-port: $fakeinetd_port
50 imap-auth: PREAUTH
51 imap-tls: don't protect my data i know what i'm doing
52 imap-mailbox-root: test/
53 EOF
54 if [ -n "$MH_TEST_IMAP_LOG_LEVEL" ]; then
55 echo "imap-log-level: $MH_TEST_IMAP_LOG_LEVEL" >> "$MH"
56 echo "imap-log-$MH_TEST_IMAP_LOG_LEVEL-to: $MH_TEST_DIR/$profile/imap.d/log.$MH_TEST_IMAP_LOG_LEVEL" >> "$MH"
57 fi
58
59 mkdir "$MH_TEST_DIR/panda"
60 mkdir "$MH_TEST_DIR/panda/test"
61
62 expected="$MH_TEST_DIR/$$.expected"
63 actual="$MH_TEST_DIR/$$.actual"
64
65 cat > "$MH_TEST_DIR/panda/test/fold1" <<EOF
66 From nmh@example.com Sat Oct 24 19:20:38 2020 -0500
67 Date:Sat, 24 Oct 2020 19:20:38 -0500
68 from:me
69 to:you
70 X-IMAPbase: 1603585238 1
71 Status: RO
72 X-Status:
73 X-Keywords:
74 X-UID: 1
75
76 body
77
78 EOF
79
80 start_test 'inc'
81 check_exit '-eq 0' inc +imap
82
83 ################################################################################
84 start_test 'rmm over IMAP'
85
86 check_exit '-eq 0' rmm -unlink +imap/fold1 1
87
88 ################################################################################
89 start_test 'scan shows no messages'
90
91 cat > "$expected" <<EOF
92 scan: no messages match specification
93 EOF
94 scan -width 80 +imap/fold1 > "$actual" 2>&1 || :
95 check "$actual" "$expected"
96
97 finish_test
98 exit ${failed:-0}