12 if [ $res -ne 0 ]; then
13 echo "Failed to run agg ($res)."
22 if [ $res -eq 0 ]; then
23 echo "Failed to fail running agg."
33 if [ $res -ne 0 ]; then
34 echo "Failed to run agg_modify."
42 rm -rf "$FEED" item
"simple feed" "simple feed t" "simple feed d" "long feed" ||
exit 1
47 printf " %-32s: " "$1"
50 if [ $result -ne 0 ]; then
58 function test_feed_exists
()
60 [ -d "$1" ] && return 0
64 function test_feed_empty
()
66 [ `ls "$1" | wc -l` = "0" ] && return 0
70 function test_feed_date
()
72 [ `stat -c %Y "$1"` = "$2" ] && return 0
76 function test_item_exists
()
78 [ -f "$1" ] && return 0
82 function test_item_date
()
84 [ `stat -c %Y "$1"` = "$2" ] && return 0
88 function test_item_missing
()
90 [ ! -e "$1" ] && return 0
94 function test_item_contents
()
96 # BUG: "`cat`" drops trailing \n.
97 [ "`cat \"$1\"`" = "$2" ] && return 0
101 #################################################################
103 function test_simple_t_feed_exists
()
105 test_feed_exists
"simple feed t"
109 function test_simple_t_item_exists
()
111 test_item_exists
"simple feed t/item"
115 function test_simple_t_item_contents
()
117 test_item_contents
"simple feed t/item" "item"
121 function test_simple_d_feed_exists
()
123 test_feed_exists
"simple feed d"
127 function test_simple_d_item_contents
()
129 test_item_contents
"simple feed d/item" "item"
133 function test_complete_feed_exists
()
135 test_feed_exists
"$FEED"
139 function test_complete_feed_empty
()
141 test_feed_empty
"$FEED"
145 function test_complete_feed_date
()
147 test_feed_date
"$FEED" 1286052203
151 function test_complete_item1_exists
()
153 test_item_exists
"$FEED/$ITEM1"
157 function test_complete_item2_exists
()
159 test_item_exists
"$FEED/$ITEM2"
163 function test_complete_item3_exists
()
165 test_item_exists
"$FEED/$ITEM3"
169 function test_complete_item1_date
()
171 test_item_date
"$FEED/$ITEM1" 1286052203
175 function test_complete_item2_date
()
177 test_item_date
"$FEED/$ITEM2" 1270203000
181 function test_complete_item3_date
()
183 test_item_date
"$FEED/$ITEM3" 1270119246
187 function test_complete_item1_contents
()
194 Link: <a href=\"/dev/random\">/dev/random</a>"
195 test_item_contents
"$FEED/$ITEM1" "$exp"
199 function test_complete_item2_contents
()
206 Link: <a href=\"/dev/urandom\">/dev/urandom</a>"
207 test_item_contents
"$FEED/$ITEM2" "$exp"
211 function test_complete_item3_contents
()
218 Link: <a href=\"/dev/null\">/dev/null</a>"
219 test_item_contents
"$FEED/$ITEM3" "$exp"
223 function test_long_feed_exists
()
225 test_feed_exists
"long feed"
229 LO
=________________________________.
230 LC
=________________________________
232 function test_long_item_exists
()
234 test_item_exists
"long feed/$LC"
238 function test_long_item_contents
240 test_item_contents
"long feed/$LC" "$LO"
244 ###############################################
246 echo "Cleaning directory..."
249 echo "Running agg on feed without title..."
250 agg_fail tests_titleless.rss
253 echo "Running agg on feed with title after items..."
254 agg_fail tests_titlelate.rss
257 echo "Running agg on simple feed (titles)..."
258 agg_run tests_simple_titles.rss
259 t test_simple_t_feed_exists
260 t test_simple_t_item_exists
261 t test_simple_t_item_contents
263 echo "Running agg on simple feed (descriptions)..."
264 agg_run tests_simple_descriptions.rss
265 t test_simple_d_feed_exists
266 t test_simple_d_item_contents
268 echo "Running agg on missing directory..."
270 t test_complete_feed_exists
271 t test_complete_feed_date
272 t test_complete_item1_exists
273 t test_complete_item2_exists
274 t test_complete_item3_exists
275 t test_complete_item1_date
276 t test_complete_item2_date
277 t test_complete_item3_date
278 t test_complete_item1_contents
279 t test_complete_item2_contents
280 t test_complete_item3_contents
282 echo "Running agg on up-to-date directory..."
284 t test_complete_feed_exists
285 t test_complete_feed_date
286 t test_complete_item1_exists
287 t test_complete_item2_exists
288 t test_complete_item3_exists
289 t test_complete_item1_date
290 t test_complete_item2_date
291 t test_complete_item3_date
292 t test_complete_item1_contents
293 t test_complete_item2_contents
294 t test_complete_item3_contents
296 echo "Deleting old news..."
298 t test_complete_feed_exists
299 t test_complete_feed_date
300 t test_complete_feed_empty
302 echo "Running agg on clean up-to-date directory..."
304 t test_complete_feed_exists
305 t test_complete_feed_date
306 t test_complete_feed_empty
308 echo "Changing mtime..."
309 touch -md "1970-01-01 00:00:00.000000000 +0000" "$FEED"
311 echo "Running agg on clean outdated directory..."
313 t test_complete_feed_exists
314 t test_complete_feed_date
315 t test_complete_item1_exists
316 t test_complete_item2_exists
317 t test_complete_item3_exists
318 t test_complete_item1_date
319 t test_complete_item2_date
320 t test_complete_item3_date
321 t test_complete_item1_contents
322 t test_complete_item2_contents
323 t test_complete_item3_contents
325 echo "Running agg on feed with long items..."
326 agg_run tests_long.rss
327 t test_long_feed_exists
328 t test_long_item_exists
329 t test_long_item_contents
331 echo "Success! Cleaning up..."