2 ######################################################
6 ######################################################
10 if test -z "${MH_OBJ_DIR}"; then
11 srcdir=`dirname $0`/../..
12 MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
15 . "$MH_OBJ_DIR/test/common.sh"
19 expected=$MH_TEST_DIR/$$.expected
20 actual=$MH_TEST_DIR/$$.actual
24 folder -create +other -fast >/dev/null
25 folder -create +another -fast >/dev/null
27 # check with no options and no current message
28 run_test 'refile' 'refile: no folder specified'
30 # check with current message
31 folder +inbox 4 >/dev/null
32 run_test 'refile +other' ''
33 run_test 'folders -noheader' \
34 'another has no messages.
35 inbox+ has 9 messages (1-10); cur=4.
36 other has 1 message (1- 1).
38 TOTAL = 10 messages in 3 folders.'
40 # check with specified message
41 folder +inbox 5 >/dev/null
42 run_test 'refile 5 +other' ''
43 run_test 'folders -noheader' \
44 'another has no messages.
45 inbox+ has 8 messages (1-10); cur=5.
46 other has 2 messages (1- 2).
48 TOTAL = 10 messages in 3 folders.'
50 # check multiple messages
51 run_test 'refile 6 7 +other' ''
52 run_test 'folders -noheader' \
53 'another has no messages.
54 inbox+ has 6 messages (1-10); cur=7.
55 other has 4 messages (1- 4).
57 TOTAL = 10 messages in 3 folders.'
59 # check multiple folders
60 run_test 'refile 8 +other +another' ''
61 run_test 'folders -noheader' \
62 'another has 1 message (1- 1).
63 inbox+ has 5 messages (1-10); cur=8.
64 other has 5 messages (1- 5).
66 TOTAL = 11 messages in 3 folders.'
68 # check message number greater than highest
69 run_test 'refile 11 +other' "refile: message 11 doesn't exist"
70 folder -f +another >/dev/null
73 run_test 'refile 9 -src +inbox +other' ''
74 run_test 'folders -noheader' \
75 'another has 1 message (1- 1).
76 inbox+ has 4 messages (1-10); cur=9.
77 other has 6 messages (1- 6).
79 TOTAL = 11 messages in 3 folders.'
82 run_test "refile -file $MH_TEST_DIR/Mail/inbox/10 +other" ''
83 run_test 'folders -noheader' \
84 'another has 1 message (1-1).
85 inbox+ has 3 messages (1-3).
86 other has 7 messages (1-7).
88 TOTAL = 11 messages in 3 folders.'
90 # check -file -, which isn't supported
91 run_test "refile -file - +other <$MH_TEST_DIR/Mail/inbox/9" \
92 'refile: missing argument to -file'
93 run_test 'folders -noheader' \
94 'another has 1 message (1-1).
95 inbox+ has 3 messages (1-3).
96 other has 7 messages (1-7).
98 TOTAL = 11 messages in 3 folders.'
100 run_test "refile -src +other all +inbox"
101 run_test 'folders -noheader' \
102 'another has 1 message (1- 1).
103 inbox has 10 messages (1-10); cur=9.
104 other+ has no messages.
106 TOTAL = 11 messages in 3 folders.'
109 mv $MH_TEST_DIR/Mail/another/1 $MH_TEST_DIR/Mail/draft
110 rmdir $MH_TEST_DIR/Mail/another
111 run_test 'refile -draft +other' ''
112 run_test 'folders -noheader' \
113 'inbox has 10 messages (1-10); cur=9.
114 other+ has 1 message (1- 1).
116 TOTAL = 11 messages in 2 folders.'
119 run_test 'refile 7 -src +inbox +other -link' ''
120 run_test 'folders -noheader' \
121 'inbox+ has 10 messages (1-10); cur=7.
122 other has 2 messages (1- 2).
124 TOTAL = 12 messages in 2 folders.'
125 # inbox/7 and other/2 are linked. Modify one and verify
126 # that the other changes as well.
127 echo '' >>$MH_TEST_DIR/Mail/other/2
128 run_test "cmp $MH_TEST_DIR/Mail/inbox/7 $MH_TEST_DIR/Mail/other/2" ''
131 run_test 'refile 7 +other -link -nolink' ''
132 run_test 'folders -noheader' \
133 'inbox+ has 9 messages (1-10); cur=7.
134 other has 3 messages (1- 3).
136 TOTAL = 12 messages in 2 folders.'
137 # inbox/7 should no longer exist because it was moved, not linked.
138 run_test 'scan +inbox 7' "scan: message 7 doesn't exist"
141 run_test 'refile 10 +other -preserve' ''
142 run_test 'folders -noheader' \
143 'inbox+ has 8 messages (1- 9).
144 other has 4 messages (1-10).
146 TOTAL = 12 messages in 2 folders.'
147 run_test 'scan +other last -format %(msg):%(decode{subject})' \
148 '10:Testing message 10'
151 run_test 'refile 9 -src +inbox +other -preserve -nopreserve' ''
152 run_test 'folders -noheader' \
153 'inbox+ has 7 messages (1- 8).
154 other has 5 messages (1-11).
156 TOTAL = 12 messages in 2 folders.'
157 run_test 'scan +other last -format %(msg):%(decode{subject})' \
158 '11:Testing message 9'
161 run_test 'refile 3 -src +inbox +other -unlink' ''
162 run_test 'folders -noheader' \
163 'inbox+ has 6 messages (1- 8); cur=3.
164 other has 6 messages (1-12).
166 TOTAL = 12 messages in 2 folders.'
167 if test -f $MH_TEST_DIR/Mail/inbox/,3; then
168 echo "$0: refile -unlink failed" 1>&2
169 failed=`expr ${failed:-0} + 1`
173 run_test 'refile 2 +other -unlink -nounlink' ''
174 run_test 'folders -noheader' \
175 'inbox+ has 5 messages (1- 8); cur=2.
176 other has 7 messages (1-13).
178 TOTAL = 12 messages in 2 folders.'
179 if ! test -f $MH_TEST_DIR/Mail/inbox/,2; then
180 echo "$0: refile -nounlink failed" 1>&2
181 failed=`expr ${failed:-0} + 1`
184 # test folder creation when stdin is not a tty
185 refile first +newfolder </dev/null
186 run_test 'folders -noheader' \
187 'inbox+ has 4 messages (4- 8).
188 newfolder has 1 message (1- 1).
189 other has 7 messages (1-13).
191 TOTAL = 12 messages in 3 folders.'
194 run_test 'refile first +other -rmmproc echo' '4'
195 run_test 'folders -noheader' \
196 'inbox+ has 4 messages (4- 8); cur=4.
197 newfolder has 1 message (1- 1).
198 other has 8 messages (1-14).
200 TOTAL = 13 messages in 3 folders.'
203 run_test 'refile first +other -rmmproc echo -normmproc' ''
204 run_test 'folders -noheader' \
205 'inbox+ has 3 messages (5- 8).
206 newfolder has 1 message (1- 1).
207 other has 9 messages (1-15).
209 TOTAL = 13 messages in 3 folders.'