]>
diplodocus.org Git - nmh/blob - test/anno/test-anno
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 #### Skip nmh intro text.
43 run_prog anno
-help | sed '/^$/,$d' >"$actual" 2>&1
44 check
"$expected" "$actual"
49 * ) printf '%s: anno -v generated unexpected output\n' "$0" >&2
50 failed
=`expr ${failed:-0} + 1`;;
53 # check unknown switch
54 run_test
"anno -nonexistent" 'anno: -nonexistent unknown'
56 cat "${MH_TEST_DIR}/Mail/inbox/1" >"${MH_TEST_DIR}/Mail/inbox/11"
58 # check with no switches
59 printf 'Nmh-test:\n' >"$expected"
60 cat "${MH_TEST_DIR}/Mail/inbox/1" >>"$expected"
61 folder
-fast 1 >/dev
/null
63 printf 'Nmh-test' | run_prog anno
>/dev
/null
64 sed -e 's/^Nmh-test:.*/Nmh-test:/' "${MH_TEST_DIR}/Mail/inbox/1" >"$actual"
65 check
"$expected" "$actual" 'keep first'
66 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
69 run_prog anno
-component Nmh
-test
70 sed -e 's/^Nmh-test:.*/Nmh-test:/' "${MH_TEST_DIR}/Mail/inbox/1" >"$actual"
71 check
"$expected" "$actual" 'keep first'
72 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
75 run_prog anno
-component Nmh
-test +inbox
76 sed -e 's/^Nmh-test:.*/Nmh-test:/' "${MH_TEST_DIR}/Mail/inbox/1" >"$actual"
77 check
"$expected" "$actual" 'keep first'
78 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
81 folder
-fast 2 >/dev
/null
82 run_prog anno
1 -component Nmh
-test
83 sed -e 's/^Nmh-test:.*/Nmh-test:/' "${MH_TEST_DIR}/Mail/inbox/1" >"$actual"
84 check
"$expected" "$actual" 'keep first'
85 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
88 if [ $hard_links_supported -eq 1 ]; then
90 # Hard link the message and verify that the new one doesn't get annotated.
91 cp "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.copy"
92 ln "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link"
93 run_prog anno
8 -component Nmh
-test -noinplace
94 mv -f "${MH_TEST_DIR}/Mail/inbox/8.copy" "${MH_TEST_DIR}/Mail/inbox/8"
95 check
"${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link" \
99 # Hard link the message and verify that the new one does get annotated.
100 ln "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link"
101 run_prog anno
8 -component Nmh
-test -noinplace -inplace
102 check
"${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link"
105 # check -nodate. Without -text, it doesn't change the message.
106 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "$expected-nodate"
107 run_prog anno
1 -component Nmh
-test -nodate
108 cp -f "${MH_TEST_DIR}/Mail/inbox/1" "$actual"
109 check
"$expected-nodate" "$actual"
110 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
113 run_prog anno
1 -component Nmh
-test -nodate -date
114 sed -e 's/^Nmh-test:.*/Nmh-test:/' "${MH_TEST_DIR}/Mail/inbox/1" >"$actual"
115 check
"$expected" "$actual" 'keep first'
116 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
119 cp -f "${MH_TEST_DIR}/Mail/inbox/1" "${MH_TEST_DIR}/Mail/draft"
120 run_prog anno
-draft -component Nmh
-test
121 sed -e 's/^Nmh-test:.*/Nmh-test:/' "${MH_TEST_DIR}/Mail/draft" >"$actual"
122 check
"$expected" "$actual"
123 rm "${MH_TEST_DIR}/Mail/draft"
126 sed -e 's/\(Subject: Testing message 1\)/\1\
127 Nmh-test:/' <"${MH_TEST_DIR}/Mail/inbox/1" >"$expected"
128 run_prog anno
1 -component Nmh
-test -append
129 sed -e 's/^Nmh-test:.*/Nmh-test:/' "${MH_TEST_DIR}/Mail/inbox/1" >"$actual"
130 check
"$expected" "$actual"
131 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
134 printf 'Nmh-test: test of anno -list\n' >"$expected"
135 cat "${MH_TEST_DIR}/Mail/inbox/1" >>"$expected"
136 run_prog anno
1 -component Nmh
-test -nodate -text 'test of anno -list'
137 run_test
'anno 1 -component Nmh-test -list' 'test of anno -list'
139 check
"$expected" "${MH_TEST_DIR}/Mail/inbox/1"
140 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
142 # check -list -number
143 printf 'Nmh-test: test of anno -list -number\n' >"$expected"
144 cat "${MH_TEST_DIR}/Mail/inbox/1" >>"$expected"
145 run_prog anno
1 -component Nmh
-test -nodate -text 'test of anno -list -number'
146 run_test
'anno 1 -component Nmh-test -list -number' \
147 '1 test of anno -list -number'
148 check
"$expected" "${MH_TEST_DIR}/Mail/inbox/1"
149 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
152 cp "${MH_TEST_DIR}/Mail/inbox/1" "$expected"
153 run_prog anno
1 -component Nmh
-test
154 run_prog anno
1 -component Nmh
-test -delete
155 sed -e 's/^Nmh-test:.*/Nmh-test:/' "${MH_TEST_DIR}/Mail/inbox/1" >"$actual"
156 check
"$expected" "$actual"
157 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
159 # check -delete -number
160 printf 'Nmh-test: 1\nNmh-test: 3\n' >"$expected"
161 cat "${MH_TEST_DIR}/Mail/inbox/1" >>"$expected"
162 run_prog anno
1 -component Nmh
-test -nodate -text 3
163 run_prog anno
1 -component Nmh
-test -nodate -text 2
164 run_prog anno
1 -component Nmh
-test -nodate -text 1
165 run_prog anno
1 -component Nmh
-test -delete -number 2
166 cp -f "${MH_TEST_DIR}/Mail/inbox/1" "$actual"
167 check
"$expected" "$actual"
168 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
171 cp "${MH_TEST_DIR}/Mail/inbox/1" "$expected"
172 run_prog anno
1 -component Nmh
-test -nodate -text 3
173 run_prog anno
1 -component Nmh
-test -nodate -text 2
174 run_prog anno
1 -component Nmh
-test -nodate -text 1
175 run_prog anno
1 -component Nmh
-test -delete -number all
176 cp -f "${MH_TEST_DIR}/Mail/inbox/1" "$actual"
177 check
"$expected" "$actual"
178 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
181 touch -t '201210010000.00' "${MH_TEST_DIR}/Mail/inbox/1"
182 ls -l "${MH_TEST_DIR}/Mail/inbox/1" >"$actual-ls1"
183 run_prog anno
1 -component Nmh
-test -preserve
184 run_prog anno
1 -component Nmh
-test -preserve -delete
185 ls -l "${MH_TEST_DIR}/Mail/inbox/1" >"$actual-ls2"
186 check
"$actual-ls1" "$actual-ls2"
187 cp -f "${MH_TEST_DIR}/Mail/inbox/11" "${MH_TEST_DIR}/Mail/inbox/1"
190 touch -t '2012100100.00' "${MH_TEST_DIR}/Mail/inbox/1"
191 ls -l "${MH_TEST_DIR}/Mail/inbox/1" >"$actual-ls1"
192 run_prog anno
1 -component Nmh
-test -preserve -nopreserve
193 run_prog anno
1 -component Nmh
-test -preserve -nopreserve -delete
194 ls -l "${MH_TEST_DIR}/Mail/inbox/1" >"$actual-ls2"
196 diff "$actual-ls1" "$actual-ls2" >/dev
/null
197 run_test
'printf 1' "$?"
199 rm "$actual-ls1" "$actual-ls2"