2 # Copyright (C) 2011 Andreas Waidler <arandes@programmers.at>
4 # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
5 # TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
7 # 0. You just DO WHAT THE FUCK YOU WANT TO.
18 if [ $res -ne 0 ]; then
19 echo "Failed to run agg ($res)."
28 if [ $res -eq 0 ]; then
29 echo "Failed to fail running agg."
37 find -type f
-exec ..
/nomtime
"rm '{}'" \
;
39 if [ $res -ne 0 ]; then
40 echo "Failed to run nomtime."
48 rm -rf "$FEED" item
"simple feed" "simple feed t" "simple feed d" "long feed" ||
exit 1
54 printf " %-32s: " "$1"
57 if [ $result -ne 0 ]; then
59 FAILURES
=`expr $FAILURES + 1 `
65 function test_feed_exists
() { [ -d "$1" ]; }
66 function test_feed_empty
() { [ `ls "$1" | wc -l` = "0" ]; }
67 function test_feed_date
() { [ `stat -c %Y "$1"` = "$2" ]; }
68 function test_item_exists
() { [ -f "$1" ]; }
69 function test_item_date
() { [ `stat -c %Y "$1"` = "$2" ]; }
70 function test_item_missing
() { [ ! -e "$1" ]; }
71 # BUG: "`cat`" drops trailing \n.
72 function test_item_contents
() { [ "`cat \"$1\"`" = "$2" ]; }
74 ################## TEST CASES FOLLOW ######################
76 function test_simple_t_feed_exists
() { test_feed_exists
"simple feed t"; }
77 function test_simple_t_item_exists
() { test_item_exists
"simple feed t/item"; }
78 function test_simple_t_item_date
() { test_item_date
"simple feed t/item" 0; }
79 function test_simple_t_item_contents
() { test_item_contents
"simple feed t/item" "item"; }
81 function test_simple_d_feed_exists
() { test_feed_exists
"simple feed d"; }
82 function test_simple_d_item_contents
() { test_item_contents
"simple feed d/item" "item"; }
84 LO
=________________________________________________________________.
85 LC
=________________________________________________________________
86 function test_long_feed_exists
() { test_feed_exists
"long feed"; }
87 function test_long_item_exists
() { test_item_exists
"long feed/$LC"; }
88 function test_long_item_contents
{ test_item_contents
"long feed/$LC" "$LO"; }
90 function test_complete_feed_exists
() { test_feed_exists
"$FEED"; }
91 function test_complete_feed_empty
() { test_feed_empty
"$FEED"; }
92 function test_complete_feed_date
() { test_feed_date
"$FEED" 1286052203; }
93 function test_complete_item1_exists
() { test_item_exists
"$FEED/$ITEM1"; }
94 function test_complete_item2_exists
() { test_item_exists
"$FEED/$ITEM2"; }
95 function test_complete_item3_exists
() { test_item_exists
"$FEED/$ITEM3"; }
96 function test_complete_item1_date
() { test_item_date
"$FEED/$ITEM1" 1286052203; }
97 function test_complete_item2_date
() { test_item_date
"$FEED/$ITEM2" 1270203000; }
98 function test_complete_item3_date
() { test_item_date
"$FEED/$ITEM3" 1270119246; }
99 function test_complete_item1_contents
()
106 Link: <a href=\"/dev/random\">/dev/random</a>"
107 test_item_contents
"$FEED/$ITEM1" "$exp"
109 function test_complete_item2_contents
()
116 Link: <a href=\"/dev/urandom\">/dev/urandom</a>"
117 test_item_contents
"$FEED/$ITEM2" "$exp"
119 function test_complete_item3_contents
()
126 Link: <a href=\"/dev/null\">/dev/null</a>"
127 test_item_contents
"$FEED/$ITEM3" "$exp"
130 ###############################################
132 echo "Cleaning directory..."
135 echo "Running agg on feed without title..."
136 agg_fail tests_titleless.rss
139 echo "Running agg on feed with title after items..."
140 agg_fail tests_titlelate.rss
143 echo "Running agg on simple feed (titles)..."
144 agg_run tests_simple_titles.rss
145 t test_simple_t_feed_exists
146 t test_simple_t_item_exists
147 t test_simple_t_item_date
148 t test_simple_t_item_contents
150 echo "Running agg on simple feed (descriptions)..."
151 agg_run tests_simple_descriptions.rss
152 t test_simple_d_feed_exists
153 t test_simple_d_item_contents
155 echo "Running agg on missing directory..."
157 t test_complete_feed_exists
158 t test_complete_feed_date
159 t test_complete_item1_exists
160 t test_complete_item2_exists
161 t test_complete_item3_exists
162 t test_complete_item1_date
163 t test_complete_item2_date
164 t test_complete_item3_date
165 t test_complete_item1_contents
166 t test_complete_item2_contents
167 t test_complete_item3_contents
169 echo "Running agg on up-to-date directory..."
171 t test_complete_feed_exists
172 t test_complete_feed_date
173 t test_complete_item1_exists
174 t test_complete_item2_exists
175 t test_complete_item3_exists
176 t test_complete_item1_date
177 t test_complete_item2_date
178 t test_complete_item3_date
179 t test_complete_item1_contents
180 t test_complete_item2_contents
181 t test_complete_item3_contents
183 echo "Deleting old news..."
185 t test_complete_feed_exists
186 t test_complete_feed_date
187 t test_complete_feed_empty
189 echo "Running agg on clean up-to-date directory..."
191 t test_complete_feed_exists
192 t test_complete_feed_date
193 t test_complete_feed_empty
195 echo "Changing mtime..."
196 touch -md "1970-01-01 00:00:00.000000000 +0000" "$FEED"
198 echo "Running agg on clean outdated directory..."
200 t test_complete_feed_exists
201 t test_complete_feed_date
202 t test_complete_item1_exists
203 t test_complete_item2_exists
204 t test_complete_item3_exists
205 t test_complete_item1_date
206 t test_complete_item2_date
207 t test_complete_item3_date
208 t test_complete_item1_contents
209 t test_complete_item2_contents
210 t test_complete_item3_contents
212 echo "Running agg on feed with long items..."
213 agg_run tests_long.rss
214 t test_long_feed_exists
215 t test_long_item_exists
216 t test_long_item_contents
218 echo "Cleaning up..."
221 echo "Failed $FAILURES times!"