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.'
120 if link $$.txt $$-2.txt 2>/dev/null; then
121 # Hard links are supported.
123 run_test 'refile 7 -src +inbox +other -link' ''
124 run_test 'folders -noheader' \
125 'inbox+ has 10 messages (1-10); cur=7.
126 other has 2 messages (1- 2).
128 TOTAL = 12 messages in 2 folders.'
129 # inbox/7 and other/2 are linked. Modify one and verify
130 # that the other changes as well.
131 echo '' >>$MH_TEST_DIR/Mail/other/2
132 run_test "cmp $MH_TEST_DIR/Mail/inbox/7 $MH_TEST_DIR/Mail/other/2" ''
134 # Hard links are not supported. Skip the -link test but emulate
135 # what it would have done using a copy instead of a link.
136 cp -p Mail/inbox/7 Mail/other/2
137 folder -f +inbox 7 >/dev/null
140 rm -f $$.txt $$-2.txt
143 run_test 'refile 7 +other -link -nolink' ''
144 run_test 'folders -noheader' \
145 'inbox+ has 9 messages (1-10); cur=7.
146 other has 3 messages (1- 3).
148 TOTAL = 12 messages in 2 folders.'
149 # inbox/7 should no longer exist because it was moved, not linked.
150 run_test 'scan +inbox 7' "scan: message 7 doesn't exist"
153 run_test 'refile 10 +other -preserve' ''
154 run_test 'folders -noheader' \
155 'inbox+ has 8 messages (1- 9).
156 other has 4 messages (1-10).
158 TOTAL = 12 messages in 2 folders.'
159 run_test 'scan +other last -format %(msg):%(decode{subject})' \
160 '10:Testing message 10'
163 run_test 'refile 9 -src +inbox +other -preserve -nopreserve' ''
164 run_test 'folders -noheader' \
165 'inbox+ has 7 messages (1- 8).
166 other has 5 messages (1-11).
168 TOTAL = 12 messages in 2 folders.'
169 run_test 'scan +other last -format %(msg):%(decode{subject})' \
170 '11:Testing message 9'
173 run_test 'refile 3 -src +inbox +other -unlink' ''
174 run_test 'folders -noheader' \
175 'inbox+ has 6 messages (1- 8); cur=3.
176 other has 6 messages (1-12).
178 TOTAL = 12 messages in 2 folders.'
179 if test -f $MH_TEST_DIR/Mail/inbox/,3; then
180 echo "$0: refile -unlink failed" 1>&2
181 failed=`expr ${failed:-0} + 1`
185 run_test 'refile 2 +other -unlink -nounlink' ''
186 run_test 'folders -noheader' \
187 'inbox+ has 5 messages (1- 8); cur=2.
188 other has 7 messages (1-13).
190 TOTAL = 12 messages in 2 folders.'
191 if test -f $MH_TEST_DIR/Mail/inbox/,2; then
194 echo "$0: refile -nounlink failed" 1>&2
195 failed=`expr ${failed:-0} + 1`
198 # test folder creation when stdin is not a tty
199 refile first +newfolder </dev/null
200 run_test 'folders -noheader' \
201 'inbox+ has 4 messages (4- 8).
202 newfolder has 1 message (1- 1).
203 other has 7 messages (1-13).
205 TOTAL = 12 messages in 3 folders.'
208 run_test 'refile first +other -rmmproc echo' '4'
209 run_test 'folders -noheader' \
210 'inbox+ has 4 messages (4- 8); cur=4.
211 newfolder has 1 message (1- 1).
212 other has 8 messages (1-14).
214 TOTAL = 13 messages in 3 folders.'
217 run_test 'refile first +other -rmmproc echo -normmproc' ''
218 run_test 'folders -noheader' \
219 'inbox+ has 3 messages (5- 8).
220 newfolder has 1 message (1- 1).
221 other has 9 messages (1-15).
223 TOTAL = 13 messages in 3 folders.'