]>
diplodocus.org Git - nmh/blob - test/refile/test-refile
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 check_exit
'-eq 1' refile
-
21 expected
=$MH_TEST_DIR/$$.expected
22 actual
=$MH_TEST_DIR/$$.actual
26 run_prog folder
-create +other
-fast >/dev
/null
27 run_prog folder
-create +another
-fast >/dev
/null
29 # check with no options and no current message
30 start_test
"with no options and no current message"
31 run_test
'refile' 'refile: no folder specified'
33 # check with current message
34 start_test
"with current message"
35 run_prog folder
+inbox
4 >/dev
/null
36 run_test
'refile +other' ''
37 run_test
'folders -noheader' \
38 'another has no messages.
39 inbox+ has 9 messages (1-10); cur=4.
40 other has 1 message (1- 1).
42 TOTAL = 10 messages in 3 folders.'
44 # check with specified message
45 start_test
"with specified message"
46 run_prog folder
+inbox
5 >/dev
/null
47 run_test
'refile 5 +other' ''
48 run_test
'folders -noheader' \
49 'another has no messages.
50 inbox+ has 8 messages (1-10); cur=5.
51 other has 2 messages (1- 2).
53 TOTAL = 10 messages in 3 folders.'
55 # check multiple messages
56 start_test
"multiple messages"
57 run_test
'refile 6 7 +other' ''
58 run_test
'folders -noheader' \
59 'another has no messages.
60 inbox+ has 6 messages (1-10); cur=7.
61 other has 4 messages (1- 4).
63 TOTAL = 10 messages in 3 folders.'
65 # check multiple folders
66 start_test
"multiple folders"
67 run_test
'refile 8 +other +another' ''
68 run_test
'folders -noheader' \
69 'another has 1 message (1- 1).
70 inbox+ has 5 messages (1-10); cur=8.
71 other has 5 messages (1- 5).
73 TOTAL = 11 messages in 3 folders.'
75 # check message number greater than highest
76 start_test
"message number greater than highest"
77 run_test
'refile 11 +other' "refile: message 11 doesn't exist"
78 run_prog folder
-f +another
>/dev
/null
82 run_test
'refile 9 -src +inbox +other' ''
83 run_test
'folders -noheader' \
84 'another has 1 message (1- 1).
85 inbox+ has 4 messages (1-10); cur=9.
86 other has 6 messages (1- 6).
88 TOTAL = 11 messages in 3 folders.'
92 run_test
"refile -file $MH_TEST_DIR/Mail/inbox/10 +other" ''
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 # check -file -, which isn't supported
101 start_test
"-file -, which isn't supported"
102 run_test
"refile -file - +other <$MH_TEST_DIR/Mail/inbox/9" \
103 'refile: missing argument to -file'
104 run_test
'folders -noheader' \
105 'another has 1 message (1-1).
106 inbox+ has 3 messages (1-3).
107 other has 7 messages (1-7).
109 TOTAL = 11 messages in 3 folders.'
111 run_test
"refile -src +other all +inbox"
112 run_test
'folders -noheader' \
113 'another has 1 message (1- 1).
114 inbox has 10 messages (1-10); cur=9.
115 other+ has no messages.
117 TOTAL = 11 messages in 3 folders.'
121 mv $MH_TEST_DIR/Mail
/another
/1 $MH_TEST_DIR/Mail
/draft
122 rmdir $MH_TEST_DIR/Mail
/another
123 run_test
'refile -draft +other' ''
124 run_test
'folders -noheader' \
125 'inbox has 10 messages (1-10); cur=9.
126 other+ has 1 message (1- 1).
128 TOTAL = 11 messages in 2 folders.'
131 if [ $xdir_links_supported -eq 1 ]; then
133 run_test
'refile 7 -src +inbox +other -link' ''
134 run_test
'folders -noheader' \
135 'inbox+ has 10 messages (1-10); cur=7.
136 other has 2 messages (1- 2).
138 TOTAL = 12 messages in 2 folders.'
139 # inbox/7 and other/2 are linked. Modify one and verify
140 # that the other changes as well.
141 echo '' >>$MH_TEST_DIR/Mail
/other
/2
142 run_test
"cmp $MH_TEST_DIR/Mail/inbox/7 $MH_TEST_DIR/Mail/other/2" ''
144 # Hard links are not supported. Skip the -link test but emulate
145 # what it would have done using a copy instead of a link.
146 cp -p Mail
/inbox
/7 Mail
/other
/2
147 folder
-f +inbox
7 >/dev
/null
152 run_test
'refile 7 +other -link -nolink' ''
153 run_test
'folders -noheader' \
154 'inbox+ has 9 messages (1-10); cur=7.
155 other has 3 messages (1- 3).
157 TOTAL = 12 messages in 2 folders.'
158 # inbox/7 should no longer exist because it was moved, not linked.
159 run_test
'scan +inbox 7' "scan: message 7 doesn't exist"
162 start_test
"-preserve"
163 run_test
'refile 10 +other -preserve' ''
164 run_test
'folders -noheader' \
165 'inbox+ has 8 messages (1- 9).
166 other has 4 messages (1-10).
168 TOTAL = 12 messages in 2 folders.'
169 run_test
'scan +other last -format %(msg):%(decode{subject})' \
170 '10:Testing message 10'
173 start_test
"-nopreserve"
174 run_test
'refile 9 -src +inbox +other -preserve -nopreserve' ''
175 run_test
'folders -noheader' \
176 'inbox+ has 7 messages (1- 8).
177 other has 5 messages (1-11).
179 TOTAL = 12 messages in 2 folders.'
180 run_test
'scan +other last -format %(msg):%(decode{subject})' \
181 '11:Testing message 9'
183 sbackup
="`mhparam sbackup`"
187 run_test
'refile 3 -src +inbox +other -unlink' ''
188 run_test
'folders -noheader' \
189 'inbox+ has 6 messages (1- 8); cur=3.
190 other has 6 messages (1-12).
192 TOTAL = 12 messages in 2 folders.'
193 if test -f "$MH_TEST_DIR/Mail/inbox/${sbackup}3"; then
194 echo "$0: refile -unlink failed" 1>&2
195 failed
=`expr ${failed:-0} + 1`
199 start_test
"-nounlink"
200 run_test
'refile 2 +other -unlink -nounlink' ''
201 run_test
'folders -noheader' \
202 'inbox+ has 5 messages (1- 8); cur=2.
203 other has 7 messages (1-13).
205 TOTAL = 12 messages in 2 folders.'
206 if test -f "$MH_TEST_DIR/Mail/inbox/${sbackup}2"; then
209 echo "$0: refile -nounlink failed" 1>&2
210 failed
=`expr ${failed:-0} + 1`
213 # test folder creation when stdin is not a tty
214 start_test
"folder creation when stdin is not a tty"
215 refile first
+newfolder
</dev
/null
216 run_test
'folders -noheader' \
217 'inbox+ has 4 messages (4- 8).
218 newfolder has 1 message (1- 1).
219 other has 7 messages (1-13).
221 TOTAL = 12 messages in 3 folders.'
224 start_test
"-rmmproc"
225 run_test
'refile first +other -rmmproc echo' '4'
226 run_test
'folders -noheader' \
227 'inbox+ has 4 messages (4- 8); cur=4.
228 newfolder has 1 message (1- 1).
229 other has 8 messages (1-14).
231 TOTAL = 13 messages in 3 folders.'
234 start_test
"-normmproc"
235 run_test
'refile first +other -rmmproc echo -normmproc' ''
236 run_test
'folders -noheader' \
237 'inbox+ has 3 messages (5- 8).
238 newfolder has 1 message (1- 1).
239 other has 9 messages (1-15).
241 TOTAL = 13 messages in 3 folders.'
243 # test -retainsequences
244 start_test
"-retainsequences"
247 refile first last
-retainsequences +other
248 #### The following command changes the current folder to +other.
249 run_test
'mark +other -list -sequence seq1 -sequence seq2' \
253 # test -retainsequences when refiling to same folder (+other)
254 # cur is set to the original message number of the last message refiled.
255 start_test
"-retainsequences when refiling to same folder (+other)"
256 mark first
-seq seq1
-zero
257 mark first
=2 -seq seq2
-zero
258 refile first
:2 -retainsequences +other
259 run_test
'mark -list' "cur: 2