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 expected_err=$MH_TEST_DIR/$$.expected_err
21 actual=$MH_TEST_DIR/$$.actual
22 actual_err=$MH_TEST_DIR/$$.actual_err
25 cat >"$expected" <<EOF
26 Usage: anno [+folder] [msgs] [switches]
42 anno -help >"$actual" 2>&1
43 check "$expected" "$actual"
48 * ) printf '%s: anno -v generated unexpected output\n' "$0" >&2
49 failed=`expr ${failed:-0} + 1`;;
52 # check unknown switch
53 run_test "anno -nonexistent" 'anno: -nonexistent unknown'
55 cat "${MH_TEST_DIR}/Mail/inbox/1" >"${MH_TEST_DIR}/Mail/inbox/11"
57 # check with no switches
58 printf 'Nmh-test:\n' >"$expected"
59 cat "${MH_TEST_DIR}/Mail/inbox/1" >>"$expected"
60 folder -fast 1 >/dev/null
62 printf 'Nmh-test' | anno >/dev/null
63 sed -e 's/^Nmh-test:.*/Nmh-test:/' "${MH_TEST_DIR}/Mail/inbox/1" >"$actual"
64 check "$expected" "$actual" 'keep first'
65 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
68 anno -component Nmh-test
69 sed -e 's/^Nmh-test:.*/Nmh-test:/' "${MH_TEST_DIR}/Mail/inbox/1" >"$actual"
70 check "$expected" "$actual" 'keep first'
71 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
74 anno -component Nmh-test +inbox
75 sed -e 's/^Nmh-test:.*/Nmh-test:/' "${MH_TEST_DIR}/Mail/inbox/1" >"$actual"
76 check "$expected" "$actual" 'keep first'
77 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
80 folder -fast 2 >/dev/null
81 anno 1 -component Nmh-test
82 sed -e 's/^Nmh-test:.*/Nmh-test:/' "${MH_TEST_DIR}/Mail/inbox/1" >"$actual"
83 check "$expected" "$actual" 'keep first'
84 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
87 if [ $hard_links_supported -eq 1 ]; then
89 # Hard link the message and verify that the new one doesn't get annotated.
90 cp "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.copy"
91 ln "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link"
92 anno 8 -component Nmh-test -noinplace
93 mv -f "${MH_TEST_DIR}/Mail/inbox/8.copy" "${MH_TEST_DIR}/Mail/inbox/8"
94 check "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link" \
98 # Hard link the message and verify that the new one does get annotated.
99 ln "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link"
100 anno 8 -component Nmh-test -noinplace -inplace
101 check "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link"
104 # check -nodate. Without -text, it doesn't change the message.
105 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "$expected-nodate"
106 anno 1 -component Nmh-test -nodate
107 cp -f "${MH_TEST_DIR}/Mail/inbox/1" "$actual"
108 check "$expected-nodate" "$actual"
109 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
112 anno 1 -component Nmh-test -nodate -date
113 sed -e 's/^Nmh-test:.*/Nmh-test:/' "${MH_TEST_DIR}/Mail/inbox/1" >"$actual"
114 check "$expected" "$actual" 'keep first'
115 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
118 cp -f "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/draft"
119 anno -draft -component Nmh-test
120 sed -e 's/^Nmh-test:.*/Nmh-test:/' "${MH_TEST_DIR}/Mail/draft" >"$actual"
121 check "$expected" "$actual"
122 rm "${MH_TEST_DIR}/Mail/draft"
126 Nmh-test:' "${MH_TEST_DIR}/Mail/inbox/1" >"$expected"
127 anno 1 -component Nmh-test -append
128 sed -e 's/^Nmh-test:.*/Nmh-test:/' "${MH_TEST_DIR}/Mail/inbox/1" >"$actual"
129 check "$expected" "$actual"
130 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
133 printf 'Nmh-test: test of anno -list\n' >"$expected"
134 cat "${MH_TEST_DIR}/Mail/inbox/1" >>"$expected"
135 anno 1 -component Nmh-test -nodate -text 'test of anno -list'
136 run_test 'anno 1 -component Nmh-test -list' 'test of anno -list'
138 check "$expected" "${MH_TEST_DIR}/Mail/inbox/1" "$actual"
139 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
141 # check -list -number
142 printf 'Nmh-test: test of anno -list -number\n' >"$expected"
143 cat "${MH_TEST_DIR}/Mail/inbox/1" >>"$expected"
144 anno 1 -component Nmh-test -nodate -text 'test of anno -list -number'
145 run_test 'anno 1 -component Nmh-test -list -number' \
146 '1 test of anno -list -number'
147 check "$expected" "${MH_TEST_DIR}/Mail/inbox/1" "$actual"
148 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
151 cp "${MH_TEST_DIR}/Mail/inbox/1" "$expected"
152 anno 1 -component Nmh-test
153 anno 1 -component Nmh-test -delete
154 sed -e 's/^Nmh-test:.*/Nmh-test:/' "${MH_TEST_DIR}/Mail/inbox/1" >"$actual"
155 check "$expected" "$actual"
156 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
158 # check -delete -number
159 printf 'Nmh-test: 1\nNmh-test: 3\n' >"$expected"
160 cat "${MH_TEST_DIR}/Mail/inbox/1" >>"$expected"
161 anno 1 -component Nmh-test -nodate -text 3
162 anno 1 -component Nmh-test -nodate -text 2
163 anno 1 -component Nmh-test -nodate -text 1
164 anno 1 -component Nmh-test -delete -number 2
165 cp -f "${MH_TEST_DIR}/Mail/inbox/1" "$actual"
166 check "$expected" "$actual"
167 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
170 cp "${MH_TEST_DIR}/Mail/inbox/1" "$expected"
171 anno 1 -component Nmh-test -nodate -text 3
172 anno 1 -component Nmh-test -nodate -text 2
173 anno 1 -component Nmh-test -nodate -text 1
174 anno 1 -component Nmh-test -delete -number all
175 cp -f "${MH_TEST_DIR}/Mail/inbox/1" "$actual"
176 check "$expected" "$actual"
177 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
180 touch -t '201210010000.00' "${MH_TEST_DIR}/Mail/inbox/1"
181 ls -l "${MH_TEST_DIR}/Mail/inbox/1" >"$actual-ls1"
182 anno 1 -component Nmh-test -preserve
183 anno 1 -component Nmh-test -preserve -delete
184 ls -l "${MH_TEST_DIR}/Mail/inbox/1" >"$actual-ls2"
185 check "$actual-ls1" "$actual-ls2"
186 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
189 touch -t '2012100100.00' "${MH_TEST_DIR}/Mail/inbox/1"
190 ls -l "${MH_TEST_DIR}/Mail/inbox/1" >"$actual-ls1"
191 anno 1 -component Nmh-test -preserve -nopreserve
192 anno 1 -component Nmh-test -preserve -nopreserve -delete
193 ls -l "${MH_TEST_DIR}/Mail/inbox/1" >"$actual-ls2"
195 diff "$actual-ls1" "$actual-ls2" >/dev/null
196 run_test 'printf 1' "$?"
198 rm "$actual-ls1" "$actual-ls2"