]> diplodocus.org Git - nmh/blob - test/folder/test-packf
Added start_test/finish_test to a bunch of tests.
[nmh] / test / folder / test-packf
1 #!/bin/sh
2 ######################################################
3 #
4 # Test packf
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 check_exit '-eq 1' packf -
20
21 expected="$MH_TEST_DIR/$$.expected"
22 actual="$MH_TEST_DIR/$$.actual"
23
24
25 # check -help
26 start_test "-help"
27 cat >"$expected" <<EOF
28 Usage: packf [+folder] [msgs] [switches]
29 switches are:
30 -file name
31 -mbox
32 -mmdf
33 -version
34 -help
35 EOF
36
37 #### Skip nmh intro text.
38 packf -help 2>&1 | sed '/^$/,$d' >"$actual"
39 check "$expected" "$actual"
40
41 # check -version
42 start_test "-version"
43 case `packf -v` in
44 packf\ --*) ;;
45 * ) printf '%s: packf -v generated unexpected output\n' "$0" >&2
46 failed=`expr ${failed:-0} + 1`;;
47 esac
48
49 # check unknown switch
50 start_test "unknown switch"
51 run_test "packf -nonexistent" 'packf: -nonexistent unknown'
52
53 cd "${MH_TEST_DIR}" || exit 1
54 printf 'y\n' >Mail/yes
55
56 # check with no switches
57 start_test "with no switches"
58 run_prog packf <Mail/yes
59 inc +inbox2 -file msgbox <Mail/yes >/dev/null
60 rm -f msgbox
61 for i in `pick +inbox`; do
62 diff "`mhpath +inbox $i`" "`mhpath +inbox2 $i`"
63 done
64 run_test "printf $i" '10'
65 rmm +inbox2 -unlink `pick +inbox2`
66
67 # check +folder
68 start_test "+folder"
69 run_prog packf +inbox <Mail/yes
70 inc +inbox2 -file msgbox >/dev/null
71 rm -f msgbox
72 for i in `pick +inbox`; do
73 diff "`mhpath +inbox $i`" "`mhpath +inbox2 $i`"
74 done
75 run_test "printf $i" '10'
76 rmm +inbox2 -unlink `pick +inbox2`
77
78 # check msgs
79 start_test "msgs"
80 run_prog packf +inbox 1 2 3 <Mail/yes
81 inc +inbox2 -file msgbox >/dev/null
82 rm -f msgbox
83 for i in `pick +inbox2`; do
84 diff "`mhpath +inbox $i`" "`mhpath +inbox2 $i`"
85 done
86 run_test "printf $i" '3'
87 rmm +inbox2 -unlink `pick +inbox2`
88
89 # check -file
90 start_test "-file"
91 run_prog packf +inbox -file msgbox2 <Mail/yes
92 inc +inbox2 -file msgbox2 >/dev/null
93 for i in `pick +inbox2`; do
94 diff "`mhpath +inbox $i`" "`mhpath +inbox2 $i`"
95 done
96 run_test "printf $i" '10'
97 rmm +inbox2 -unlink `pick +inbox2`
98
99 # check append to existing mbox file
100 start_test "append to existing mbox file"
101 run_prog packf +inbox -file msgbox2 <Mail/yes
102 inc +inbox2 -file msgbox2 >/dev/null
103 rm -f msgbox2
104 for i in `pick +inbox2`; do
105 if [ $i -le 10 ]; then
106 diff "`mhpath +inbox $i`" "`mhpath +inbox2 $i`"
107 else
108 arith_eval $i - 10
109 diff "`mhpath +inbox $arith_val`" "`mhpath +inbox2 $i`"
110 fi
111 done
112 run_test "printf $i" '20'
113 rmm +inbox2 -unlink `pick +inbox2`
114
115 # check -mbox
116 start_test "-mbox"
117 run_prog packf +inbox -mbox <Mail/yes
118 inc +inbox2 -file msgbox >/dev/null
119 rm -f msgbox
120 for i in `pick +inbox2`; do
121 diff "`mhpath +inbox $i`" "`mhpath +inbox2 $i`"
122 done
123 run_test "printf $i" '10'
124 rmm +inbox2 -unlink `pick +inbox2`
125
126 # check -mmdf
127 start_test "-mmdf"
128 run_prog packf +inbox -mmdf <Mail/yes
129 inc +inbox2 -file msgbox >/dev/null
130 rm -f msgbox
131 for i in `pick +inbox2`; do
132 diff "`mhpath +inbox $i`" "`mhpath +inbox2 $i`"
133 done
134 run_test "printf $i" '10'
135 rmm +inbox2 -unlink `pick +inbox2`
136
137 # check append to existing mmdf file
138 start_test "append to existing mmdf file"
139 run_prog packf +inbox -mmdf <Mail/yes
140 inc +inbox2 -file msgbox >/dev/null
141 rm -f msgbox
142 for i in `pick +inbox2`; do
143 if [ $i -le 10 ]; then
144 diff "`mhpath +inbox $i`" "`mhpath +inbox2 $i`"
145 else
146 arith_eval $i - 10
147 diff "`mhpath +inbox $arith_val`" "`mhpath +inbox2 $i`"
148 fi
149 done
150 run_test "printf $i" '10'
151 rmm +inbox2 -unlink `pick +inbox2`
152
153
154 finish_test
155 exit ${failed:-0}