Debian Codegraph @

test/folder/test-packf

raw
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 rm -f msgbox
59 run_prog packf <Mail/yes
60 inc +inbox2 -file msgbox <Mail/yes >/dev/null
61 rm -f msgbox
62 for i in `pick +inbox`; do
63 diff "`mhpath +inbox $i`" "`mhpath +inbox2 $i`"
64 done
65 run_test "printf $i" '10'
66 rmm +inbox2 -unlink `pick +inbox2`
67
68 # check +folder
69 start_test "+folder"
70 run_prog packf +inbox <Mail/yes
71 inc +inbox2 -file msgbox >/dev/null
72 rm -f msgbox
73 for i in `pick +inbox`; do
74 diff "`mhpath +inbox $i`" "`mhpath +inbox2 $i`"
75 done
76 run_test "printf $i" '10'
77 rmm +inbox2 -unlink `pick +inbox2`
78
79 # check msgs
80 start_test "msgs"
81 run_prog packf +inbox 1 2 3 <Mail/yes
82 inc +inbox2 -file msgbox >/dev/null
83 rm -f msgbox
84 for i in `pick +inbox2`; do
85 diff "`mhpath +inbox $i`" "`mhpath +inbox2 $i`"
86 done
87 run_test "printf $i" '3'
88 rmm +inbox2 -unlink `pick +inbox2`
89
90 # check -file
91 start_test "-file"
92 rm -f msgbox2
93 run_prog packf +inbox -file msgbox2 <Mail/yes
94 inc +inbox2 -file msgbox2 >/dev/null
95 for i in `pick +inbox2`; do
96 diff "`mhpath +inbox $i`" "`mhpath +inbox2 $i`"
97 done
98 run_test "printf $i" '10'
99 rmm +inbox2 -unlink `pick +inbox2`
100
101 # check append to existing mbox file
102 start_test "append to existing mbox file"
103 run_prog packf +inbox -file msgbox2 <Mail/yes
104 inc +inbox2 -file msgbox2 >/dev/null
105 rm -f msgbox2
106 for i in `pick +inbox2`; do
107 if [ $i -le 10 ]; then
108 diff "`mhpath +inbox $i`" "`mhpath +inbox2 $i`"
109 else
110 arith_eval $i - 10
111 diff "`mhpath +inbox $arith_val`" "`mhpath +inbox2 $i`"
112 fi
113 done
114 run_test "printf $i" '20'
115 rmm +inbox2 -unlink `pick +inbox2`
116
117 # check -mbox
118 start_test "-mbox"
119 run_prog packf +inbox -mbox <Mail/yes
120 inc +inbox2 -file msgbox >/dev/null
121 rm -f msgbox
122 for i in `pick +inbox2`; do
123 diff "`mhpath +inbox $i`" "`mhpath +inbox2 $i`"
124 done
125 run_test "printf $i" '10'
126 rmm +inbox2 -unlink `pick +inbox2`
127
128 # check -mmdf
129 start_test "-mmdf"
130 run_prog packf +inbox -mmdf <Mail/yes
131 inc +inbox2 -file msgbox >/dev/null
132 rm -f msgbox
133 for i in `pick +inbox2`; do
134 diff "`mhpath +inbox $i`" "`mhpath +inbox2 $i`"
135 done
136 run_test "printf $i" '10'
137 rmm +inbox2 -unlink `pick +inbox2`
138
139 # check append to existing mmdf file
140 start_test "append to existing mmdf file"
141 run_prog packf +inbox -mmdf <Mail/yes
142 inc +inbox2 -file msgbox >/dev/null
143 rm -f msgbox
144 for i in `pick +inbox2`; do
145 if [ $i -le 10 ]; then
146 diff "`mhpath +inbox $i`" "`mhpath +inbox2 $i`"
147 else
148 arith_eval $i - 10
149 diff "`mhpath +inbox $arith_val`" "`mhpath +inbox2 $i`"
150 fi
151 done
152 run_test "printf $i" '10'
153 rmm +inbox2 -unlink `pick +inbox2`
154
155
156 finish_test
157 exit ${failed:-0}