]> diplodocus.org Git - nmh/blob - test/rcv/test-rcvpack
Replace GNUism with standard touch flag in test-scan-file.
[nmh] / test / rcv / test-rcvpack
1 #!/bin/sh
2 ######################################################
3 #
4 # Test rcvpack
5 #
6 ######################################################
7
8 set -e
9
10 if test -z "${MH_OBJ_DIR}"; then
11 srcdir=`dirname $0`/../..
12 MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
13 fi
14
15 . "$MH_OBJ_DIR/test/common.sh"
16
17 setup_test
18
19 # Use proper program, likely not the first one on PATH.
20 rcvpack="${MH_LIBEXEC_DIR}/rcvpack"
21
22 check_exit '-eq 1' $rcvpack -
23
24 expected="$MH_TEST_DIR/$$.expected"
25 actual="$MH_TEST_DIR/$$.actual"
26
27
28 # check -help
29 start_test "-help"
30 cat >"$expected" <<EOF
31 Usage: rcvpack [switches] file
32 switches are:
33 -mbox
34 -mmdf
35 -version
36 -help
37 EOF
38
39 #### Skip nmh intro text.
40 run_prog "$rcvpack" -help 2>&1 | sed '/^$/,$d' >"$actual"
41 check "$expected" "$actual"
42
43 # check -version
44 start_test "-version"
45 case `$rcvpack -v` in
46 rcvpack\ --*) ;;
47 * ) printf '%s: rcvpack -v generated unexpected output\n' "$0" >&2
48 failed=`expr ${failed:-0} + 1`;;
49 esac
50
51 # check unknown switch
52 start_test "unknown switch"
53 run_test "$rcvpack -nonexistent" 'rcvpack: -nonexistent unknown'
54
55 # check with no switches
56 start_test "with no switches"
57 run_test "$rcvpack" 'rcvpack: rcvpack [switches] file'
58
59 # check mbox creation
60 start_test "mbox creation"
61 run_prog $rcvpack <${MH_TEST_DIR}/Mail/inbox/1 ${MH_TEST_DIR}/Mail/mbox
62 inc -file ${MH_TEST_DIR}/Mail/mbox -silent
63 check "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/inbox/11" 'keep first'
64
65 # check -mbox
66 start_test "-mbox"
67 run_prog $rcvpack -mmdf -mbox ${MH_TEST_DIR}/Mail/mbox2 \
68 <${MH_TEST_DIR}/Mail/inbox/1
69 # Filter out "From " lines because their timestamps can differ by a second.
70 grep -v '^From ' "${MH_TEST_DIR}/Mail/mbox" >"${MH_TEST_DIR}/Mail/mbox-filt"
71 grep -v '^From ' "${MH_TEST_DIR}/Mail/mbox2" >"${MH_TEST_DIR}/Mail/mbox2-filt"
72 check "${MH_TEST_DIR}/Mail/mbox-filt" "${MH_TEST_DIR}/Mail/mbox2-filt"
73
74 # check append to existing mbox file
75 start_test "append to existing mbox file"
76 run_prog $rcvpack <${MH_TEST_DIR}/Mail/inbox/2 ${MH_TEST_DIR}/Mail/mbox
77 inc -file ${MH_TEST_DIR}/Mail/mbox -silent
78 check "${MH_TEST_DIR}/Mail/inbox/2" "${MH_TEST_DIR}/Mail/inbox/12" 'keep first'
79
80 # check -mmdf
81 start_test "-mmdf"
82 run_prog $rcvpack -mmdf <${MH_TEST_DIR}/Mail/inbox/3 ${MH_TEST_DIR}/Mail/mmdf
83 inc -file ${MH_TEST_DIR}/Mail/mmdf -silent
84 check "${MH_TEST_DIR}/Mail/inbox/3" "${MH_TEST_DIR}/Mail/inbox/12" 'keep first'
85
86 # check append to existing mmdf file
87 start_test "append to existing mmdf file"
88 run_prog $rcvpack -mmdf <${MH_TEST_DIR}/Mail/inbox/4 ${MH_TEST_DIR}/Mail/mmdf
89 inc -file ${MH_TEST_DIR}/Mail/mmdf -silent
90 check "${MH_TEST_DIR}/Mail/inbox/4" "${MH_TEST_DIR}/Mail/inbox/13" 'keep first'
91
92
93 finish_test
94 exit ${failed:-0}