]>
diplodocus.org Git - nmh/blob - test/pick/test-pick
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
22 # Add an 11th message.
25 -e 's/^To:\(.*\)/To:\1\
26 Cc: <another@example.com>/' \
27 -e 's/^\(Date:.*\)2006\( 00:00:\)00/\12008\200\
28 Delivery-Date: \12009\241/' \
29 $MH_TEST_DIR/Mail
/inbox
/10 >$MH_TEST_DIR/Mail
/inbox
/11
31 # Test message specification.
32 run_test
'pick first last' '1
36 run_test
'pick -subject message.3 -and -from Test3' '3'
37 run_test
'pick -subject message.3 -and -from Test4' \
38 'pick: no messages match specification
42 run_test
'pick -subject message.3 -or -from Test3' '3'
43 run_test
'pick -subject message.3 -or -from Test4' '3
47 run_test
'pick -not -subject message.8 last:5' '7
52 # Test -lbrace, -rbrace.
53 run_test
'pick -subject message.12 -and -subject message.3 -or -from Test4' '4'
54 run_test
'pick -subject message.12 -and -lbrace -subject message.3 -rbrace' \
55 'pick: no messages match specification
58 # -and takes precedence over -or.
59 run_test
'pick -subject message.12 -or -subject message.3 -and -from Test3' '3'
60 run_test
'pick -subject message.12 -or -subject message.3 -and -from Test4' \
61 'pick: no messages match specification
64 # -not takes precedence over -and.
65 run_test
'pick -not -subject message.12 -and -subject message.3' '3'
66 run_test
'pick -not -lbrace -subject NoMatch -and -subject message.3 -rbrace' \
80 MHPDEBUG
=1 pick
-not -lbrace -subject NoMatch
-and -subject message
.3 -rbrace \
85 | | PATTERN(header) ^subject[ ]*:.*NoMatch
86 | | PATTERN(header) ^subject[ ]*:.*message.3
88 check
$expected $actual
91 # Produce 0 if no messages match and standard output is not a tty.
92 # Note that there is an error message on stderr, but it's redirected
94 echo `pick -subject message.3 -and -from Test4 >$actual 2>/dev/null` >/dev
/null
98 check
$expected $actual
103 if test -w /dev
/tty
; then
104 # Produce no standard output if no messages match and standard
105 # output is a tty. To test that, move stderr to stdout and
106 # write the output directly to the tty. If there is output,
107 # it probably won't be captured, but pretend that it would be.
108 output
=`pick -subject message.3 -and -from Test4 >&2- >/dev/tty`
109 run_test
"echo $output" ''
111 echo "$0: skip tty test because can't write to /dev/tty"
114 # Also, check that the exit status is 1.
115 pick
-subject message
.3 -and -from Test4
>/dev
/null
2>&1
116 run_test
"echo $?" '1'
121 run_test
'pick -cc another' '11'
124 run_test
'pick -date 29.Sep.2008' '11'
127 run_test
'pick -from test7' '7'
130 run_test
'pick -search This.is.message.number.[456]' '4
135 run_test
'pick -subject message.2' '2'
138 run_test
'pick -to some -nolist' '11 hits'
139 run_test
'pick -to user@example.com -nolist' '11 hits'
142 pick
-after '28 Sep 2008 00:00:00' >$actual 2>&1
146 check
$expected $actual
148 # Invert exit status so execution doesn't terminate due to -e.
149 ! pick
-after '29 Sep 2008 00:00:00' >$actual 2>/dev
/null
153 check
$expected $actual
155 # Test -before. While -after doesn't include the specified date, -before does.
156 pick
-before '29 Sep 2008 00:00:01' last
:3 >$actual 2>&1
162 check
$expected $actual
163 pick
-before '28 Sep 2008 00:00:00:' last
:3 >$actual 2>&1
168 check
$expected $actual
169 # Invert exit status so execution doesn't terminate due to -e.
170 ! pick
-before '28 Sep 2006 00:00:00' last
:3 >$actual 2>/dev
/null
174 check
$expected $actual
177 # Invert exit status so execution doesn't terminate due to -e.
178 ! pick
-datefield date -after '29 Sep 2008 00:00:00' >$actual 2>/dev
/null
182 check
$expected $actual
183 pick
-datefield delivery
-date -after '29 Sep 2008 00:00:00' >$actual 2>&1
187 check
$expected $actual
189 # Test sequence creation.
190 run_test
'pick 2 4 6 8 10 -sequence even' '5 hits'
191 run_test
'mark -s even -list' 'even: 2 4 6 8 10'
193 # Test private sequence creation.
194 # Set current message for following tests.
195 folder
+inbox
1 > /dev
/null
196 run_test
'pick -date 29.Sep.2008 -sequence privateseq -nopublic' '1 hit'
197 run_test
'mark -list' 'cur: 1
199 privateseq (private): 11'
201 # Test add to private sequence.
202 run_test
'pick first -sequence privateseq -nozero -nopublic' '1 hit'
203 run_test
'mark -list' 'cur: 1
205 privateseq (private): 1 11'
207 # Test sequence creation, with -list.
208 run_test
'pick 5 7 -sequence odd -list' '5
210 run_test
'mark -s odd -list' 'odd: 5 7'
212 # Test sequence creation, with default of -zero.
213 run_test
'pick 1 3 -sequence odd' '2 hits'
214 run_test
'mark -s odd -list' 'odd: 1 3'
216 # Test sequence creation, with -nozero.
217 run_test
'pick 5 7 9 -sequence odd -nozero' '3 hits'
218 run_test
'mark -s odd -list' 'odd: 1 3 5 7 9'
220 # Test sequence creation, with explicit folder, -public, and -zero.
221 run_test
'pick +inbox 5 7 9 11 -public -sequence odd' '4 hits'
222 run_test
'mark -s odd -list' 'odd: 5 7 9 11'
225 run_test
'pick all -nolist' '11 hits'