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' anno -
20 check_exit '-eq 1' anno -comp
21 check_exit '-eq 1' anno -comp foo -comp bar
22 check_exit '-eq 1' anno -text
23 check_exit '-eq 1' anno -text foo -text bar
24 check_exit '-eq 1' anno -number 0
25 check_exit '-eq 1' anno -number -number
26 check_exit '-eq 1' anno + @
27 check_exit '-eq 1' anno -draft 42
28 check_exit '-eq 1' anno -draft -list </dev/null
29 check_exit '-eq 1' anno -draft -list -comp foo
30 check_exit '-eq 1' anno -draft -comp f.o:
31 check_exit '-eq 1' anno -draft -comp ''
36 check_exit '-eq 1' anno -draft -comp $d$c$c$c$c$l$x$x$x${x}123456789
38 expected=$MH_TEST_DIR/$$.expected
39 expected_err=$MH_TEST_DIR/$$.expected_err
40 actual=$MH_TEST_DIR/$$.actual
41 actual_err=$MH_TEST_DIR/$$.actual_err
45 cat >"$expected" <<EOF
46 Usage: anno [+folder] [msgs] [switches]
62 #### Skip nmh intro text.
63 run_prog anno -help 2>&1 | sed '/^$/,$d' >"$actual"
64 check "$expected" "$actual"
70 * ) printf '%s: anno -v generated unexpected output\n' "$0" >&2
71 failed=`expr ${failed:-0} + 1`;;
74 # check unknown switch
75 start_test "unknown switch"
76 run_test "anno -nonexistent" 'anno: -nonexistent unknown'
78 cat "${MH_TEST_DIR}/Mail/inbox/1" >"${MH_TEST_DIR}/Mail/inbox/11"
80 # check with no switches
81 start_test "with no switches"
82 printf 'Nmh-test:\n' >"$expected"
83 cat "${MH_TEST_DIR}/Mail/inbox/1" >>"$expected"
84 folder -fast 1 >/dev/null
86 printf 'Nmh-test' | run_prog anno >/dev/null
87 sed -e 's/^Nmh-test:.*/Nmh-test:/' "${MH_TEST_DIR}/Mail/inbox/1" >"$actual"
88 check "$expected" "$actual" 'keep first'
89 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
92 start_test "-component"
93 run_prog anno -component Nmh-test
94 sed -e 's/^Nmh-test:.*/Nmh-test:/' "${MH_TEST_DIR}/Mail/inbox/1" >"$actual"
95 check "$expected" "$actual" 'keep first'
96 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
100 run_prog anno -component Nmh-test +inbox
101 sed -e 's/^Nmh-test:.*/Nmh-test:/' "${MH_TEST_DIR}/Mail/inbox/1" >"$actual"
102 check "$expected" "$actual" 'keep first'
103 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
107 folder -fast 2 >/dev/null
108 run_prog anno 1 -component Nmh-test
109 sed -e 's/^Nmh-test:.*/Nmh-test:/' "${MH_TEST_DIR}/Mail/inbox/1" >"$actual"
110 check "$expected" "$actual" 'keep first'
111 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
114 if [ $hard_links_supported -eq 1 ]; then
116 start_test "-noinplace"
117 # Hard link the message and verify that the new one doesn't get annotated.
118 cp "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.copy"
119 ln "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link"
120 run_prog anno 8 -component Nmh-test -noinplace
121 mv -f "${MH_TEST_DIR}/Mail/inbox/8.copy" "${MH_TEST_DIR}/Mail/inbox/8"
122 check "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link" \
126 start_test "-inplace"
127 # Hard link the message and verify that the new one does get annotated.
128 ln "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link"
129 run_prog anno 8 -component Nmh-test -noinplace -inplace
130 check "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link"
133 # check -nodate. Without -text, it doesn't change the message.
134 start_test "-nodate. Without -text, it doesn't change the message."
135 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "$expected-nodate"
136 run_prog anno 1 -component Nmh-test -nodate
137 cp -f "${MH_TEST_DIR}/Mail/inbox/1" "$actual"
138 check "$expected-nodate" "$actual"
139 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
143 run_prog anno 1 -component Nmh-test -nodate -date
144 sed -e 's/^Nmh-test:.*/Nmh-test:/' "${MH_TEST_DIR}/Mail/inbox/1" >"$actual"
145 check "$expected" "$actual" 'keep first'
146 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
150 cp -f "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/draft"
151 run_prog anno -draft -component Nmh-test
152 sed -e 's/^Nmh-test:.*/Nmh-test:/' "${MH_TEST_DIR}/Mail/draft" >"$actual"
153 check "$expected" "$actual"
154 rm "${MH_TEST_DIR}/Mail/draft"
158 sed -e 's/\(Subject: Testing message 1\)/\1\
159 Nmh-test:/' <"${MH_TEST_DIR}/Mail/inbox/1" >"$expected"
160 run_prog anno 1 -component Nmh-test -append
161 sed -e 's/^Nmh-test:.*/Nmh-test:/' "${MH_TEST_DIR}/Mail/inbox/1" >"$actual"
162 check "$expected" "$actual"
163 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
167 printf 'Nmh-test: test of anno -list\n' >"$expected"
168 cat "${MH_TEST_DIR}/Mail/inbox/1" >>"$expected"
169 run_prog anno 1 -component Nmh-test -nodate -text 'test of anno -list'
170 run_test 'anno 1 -component Nmh-test -list' 'test of anno -list'
173 check "$expected" "${MH_TEST_DIR}/Mail/inbox/1"
174 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
176 # check -list -number
177 start_test "-list -number"
178 printf 'Nmh-test: test of anno -list -number\n' >"$expected"
179 cat "${MH_TEST_DIR}/Mail/inbox/1" >>"$expected"
180 run_prog anno 1 -component Nmh-test -nodate -text 'test of anno -list -number'
181 run_test 'anno 1 -component Nmh-test -list -number' \
182 '1 test of anno -list -number'
183 check "$expected" "${MH_TEST_DIR}/Mail/inbox/1"
184 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
188 cp "${MH_TEST_DIR}/Mail/inbox/1" "$expected"
189 run_prog anno 1 -component Nmh-test
190 run_prog anno 1 -component Nmh-test -delete
191 sed -e 's/^Nmh-test:.*/Nmh-test:/' "${MH_TEST_DIR}/Mail/inbox/1" >"$actual"
192 check "$expected" "$actual"
193 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
195 # check -delete -number
196 start_test "-delete -number"
197 printf 'Nmh-test: 1\nNmh-test: 3\n' >"$expected"
198 cat "${MH_TEST_DIR}/Mail/inbox/1" >>"$expected"
199 run_prog anno 1 -component Nmh-test -nodate -text 3
200 run_prog anno 1 -component Nmh-test -nodate -text 2
201 run_prog anno 1 -component Nmh-test -nodate -text 1
202 run_prog anno 1 -component Nmh-test -delete -number 2
203 cp -f "${MH_TEST_DIR}/Mail/inbox/1" "$actual"
204 check "$expected" "$actual"
205 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
208 start_test "-delete -all"
209 cp "${MH_TEST_DIR}/Mail/inbox/1" "$expected"
210 run_prog anno 1 -component Nmh-test -nodate -text 3
211 run_prog anno 1 -component Nmh-test -nodate -text 2
212 run_prog anno 1 -component Nmh-test -nodate -text 1
213 run_prog anno 1 -component Nmh-test -delete -number all
214 cp -f "${MH_TEST_DIR}/Mail/inbox/1" "$actual"
215 check "$expected" "$actual"
216 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
219 start_test "-preserve"
220 touch -t '201210010000.00' "${MH_TEST_DIR}/Mail/inbox/1"
221 ls -l "${MH_TEST_DIR}/Mail/inbox/1" >"$actual-ls1"
222 run_prog anno 1 -component Nmh-test -preserve
223 run_prog anno 1 -component Nmh-test -preserve -delete
224 ls -l "${MH_TEST_DIR}/Mail/inbox/1" >"$actual-ls2"
225 check "$actual-ls1" "$actual-ls2"
226 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
229 start_test "-nopreserve"
230 touch -t '2012100100.00' "${MH_TEST_DIR}/Mail/inbox/1"
231 ls -l "${MH_TEST_DIR}/Mail/inbox/1" >"$actual-ls1"
232 run_prog anno 1 -component Nmh-test -preserve -nopreserve
233 run_prog anno 1 -component Nmh-test -preserve -nopreserve -delete
234 ls -l "${MH_TEST_DIR}/Mail/inbox/1" >"$actual-ls2"
236 diff "$actual-ls1" "$actual-ls2" >/dev/null
237 run_test 'printf 1' "$?"
239 rm "$actual-ls1" "$actual-ls2"