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 if [ $hard_links_supported -eq 1 ]; then
121 run_test 'refile 7 -src +inbox +other -link' ''
122 run_test 'folders -noheader' \
123 'inbox+ has 10 messages (1-10); cur=7.
124 other has 2 messages (1- 2).
126 TOTAL = 12 messages in 2 folders.'
127 # inbox/7 and other/2 are linked. Modify one and verify
128 # that the other changes as well.
129 echo '' >>$MH_TEST_DIR/Mail/other/2
130 run_test "cmp $MH_TEST_DIR/Mail/inbox/7 $MH_TEST_DIR/Mail/other/2" ''
132 # Hard links are not supported. Skip the -link test but emulate
133 # what it would have done using a copy instead of a link.
134 cp -p Mail/inbox/7 Mail/other/2
135 folder -f +inbox 7 >/dev/null
139 run_test 'refile 7 +other -link -nolink' ''
140 run_test 'folders -noheader' \
141 'inbox+ has 9 messages (1-10); cur=7.
142 other has 3 messages (1- 3).
144 TOTAL = 12 messages in 2 folders.'
145 # inbox/7 should no longer exist because it was moved, not linked.
146 run_test 'scan +inbox 7' "scan: message 7 doesn't exist"
149 run_test 'refile 10 +other -preserve' ''
150 run_test 'folders -noheader' \
151 'inbox+ has 8 messages (1- 9).
152 other has 4 messages (1-10).
154 TOTAL = 12 messages in 2 folders.'
155 run_test 'scan +other last -format %(msg):%(decode{subject})' \
156 '10:Testing message 10'
159 run_test 'refile 9 -src +inbox +other -preserve -nopreserve' ''
160 run_test 'folders -noheader' \
161 'inbox+ has 7 messages (1- 8).
162 other has 5 messages (1-11).
164 TOTAL = 12 messages in 2 folders.'
165 run_test 'scan +other last -format %(msg):%(decode{subject})' \
166 '11:Testing message 9'
169 run_test 'refile 3 -src +inbox +other -unlink' ''
170 run_test 'folders -noheader' \
171 'inbox+ has 6 messages (1- 8); cur=3.
172 other has 6 messages (1-12).
174 TOTAL = 12 messages in 2 folders.'
175 if test -f $MH_TEST_DIR/Mail/inbox/,3; then
176 echo "$0: refile -unlink failed" 1>&2
177 failed=`expr ${failed:-0} + 1`
181 run_test 'refile 2 +other -unlink -nounlink' ''
182 run_test 'folders -noheader' \
183 'inbox+ has 5 messages (1- 8); cur=2.
184 other has 7 messages (1-13).
186 TOTAL = 12 messages in 2 folders.'
187 if test -f $MH_TEST_DIR/Mail/inbox/,2; then
190 echo "$0: refile -nounlink failed" 1>&2
191 failed=`expr ${failed:-0} + 1`
194 # test folder creation when stdin is not a tty
195 refile first +newfolder </dev/null
196 run_test 'folders -noheader' \
197 'inbox+ has 4 messages (4- 8).
198 newfolder has 1 message (1- 1).
199 other has 7 messages (1-13).
201 TOTAL = 12 messages in 3 folders.'
204 run_test 'refile first +other -rmmproc echo' '4'
205 run_test 'folders -noheader' \
206 'inbox+ has 4 messages (4- 8); cur=4.
207 newfolder has 1 message (1- 1).
208 other has 8 messages (1-14).
210 TOTAL = 13 messages in 3 folders.'
213 run_test 'refile first +other -rmmproc echo -normmproc' ''
214 run_test 'folders -noheader' \
215 'inbox+ has 3 messages (5- 8).
216 newfolder has 1 message (1- 1).
217 other has 9 messages (1-15).
219 TOTAL = 13 messages in 3 folders.'