#!/bin/sh # TODO this must have bitrotted to oblivion... testname=${0#$srcdir/} # setup copied from test-scan if test -z "$MH_OBJ_DIR"; then srcdir=`dirname "$0"`/../.. MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR fi . "$MH_OBJ_DIR/test/common.sh" setup_test_without_data Mail rm -rf "$MH_TEST_DIR/panda" imap_cleanup() { #### Save exit status to use as status for this program. status=$? set +e [ -n "$imapd_pid" ] && kill $imapd_pid "$MH_OBJ_DIR/target/debug/mhimap" imap shutdown # TODO have cleanup allow additional cleanup registration? # Or just allow it to accept status as argument. (exit $status) cleanup } trap imap_cleanup 0 covdir="$MH_OBJ_DIR/covdata/${MH_COVERAGE_PROFILE:-default}/$testname" install -d "$covdir" export LLVM_PROFILE_FILE="$covdir/$profile-%m.profraw" start_fakeinetd env "HOME=$MH_TEST_DIR/panda" "$PANDA_IMAPD" imapd_pid=$fakeinetd_pid # TODO imap-manager: $MH_LIBEXEC_DIR/folder-managers/imap # TODO imap-socket: relative path # TODO can we come up with reasonable default of socket path? cat >> "$MH" <> "$MH" echo "imap-log-$MH_TEST_IMAP_LOG_LEVEL-to: $MH_TEST_DIR/$profile/imap.d/log.$MH_TEST_IMAP_LOG_LEVEL" >> "$MH" fi mkdir "$MH_TEST_DIR/panda" mkdir "$MH_TEST_DIR/panda/test" expected="$MH_TEST_DIR/$$.expected" actual="$MH_TEST_DIR/$$.actual" for i in 1 2 3; do cat > "$MH_TEST_DIR/panda/test/fold$i" < "$expected.inc" <> Incorporating new mail into imap/fold2... 1 10/24 me <> Incorporating new mail into imap/fold3... 1 10/24 me <> EOF inc +imap > "$actual" check "$actual" "$expected.inc" ################################################################################ start_test 'refile' check_exit '-eq 0' refile -src +imap/fold1 1 +imap/fold2 start_test 'scan src folder after refile finds no messages' cat > "$expected" < "$actual" 2>&1 || : check "$actual" "$expected" start_test 'scan dst folder after refile finds refiled message' cat > "$expected" <> 2+ 10/24 me <> EOF scan -width 80 +imap/fold2 > "$actual" check "$actual" "$expected" ################################################################################ start_test 'refile -link -file' refiled_file="$MH_TEST_DIR/$$.refiled-file" cat > "$refiled_file" < "$expected" <> EOF scan -width 80 +imap/fold1 > "$actual" check "$actual" "$expected" ################################################################################ start_test 'refile -file' refiled_file="$MH_TEST_DIR/$$.refiled-file" cat > "$refiled_file" < "$expected" <> 2+ 10/24 me <> EOF scan -width 80 +imap/fold3 > "$actual" check "$actual" "$expected" ################################################################################ start_test 'rebuild local from scratch' rm -rf "$MH_TEST_DIR/Mail/imap" "$MH_TEST_DIR/Mail/imap.d/imap" cat > "$expected.inc" <> Incorporating new mail into imap/fold2... 1 10/24 me <> 2 10/24 me <> Incorporating new mail into imap/fold3... 1 10/24 me <> 2 10/24 me <> EOF inc +imap > "$actual" check "$actual" "$expected.inc" finish_test exit ${failed:-0}