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."
36 find "$FEED" -type f
-exec .
/nomtime
rm '{}' \
;
38 if [ $res -ne 0 ]; then
39 echo "Failed to run nomtime."
46 rm -rf "$FEED" item
"simple feed" "simple feed t" "simple feed d" "long feed" ||
exit 1
52 printf " %-32s: " "$1"
55 if [ $result -ne 0 ]; then
57 FAILURES
=`expr $FAILURES + 1 `
63 function test_feed_exists
() { [ -d "$1" ]; }
64 function test_feed_empty
() { [ `ls "$1" | wc -l` = "0" ]; }
65 function test_feed_date
() { [ `stat -c %Y "$1"` = "$2" ]; }
66 function test_item_exists
() { [ -f "$1" ]; }
67 function test_item_date
() { [ `stat -c %Y "$1"` = "$2" ]; }
68 function test_item_missing
() { [ ! -e "$1" ]; }
69 # BUG: "`cat`" drops trailing \n.
70 function test_item_contents
() { [ "`cat \"$1\"`" = "$2" ]; }
72 ################## TEST CASES FOLLOW ######################
74 function test_simple_t_feed_exists
() { test_feed_exists
"simple feed t"; }
75 function test_simple_t_item_exists
() { test_item_exists
"simple feed t/item"; }
76 function test_simple_t_item_date
() { test_item_date
"simple feed t/item" 0; }
77 function test_simple_t_item_contents
() { test_item_contents
"simple feed t/item" "item"; }
79 function test_simple_d_feed_exists
() { test_feed_exists
"simple feed d"; }
80 function test_simple_d_item_contents
() { test_item_contents
"simple feed d/item" "item"; }
82 LO
=________________________________________________________________.
83 LC
=________________________________________________________________
84 function test_long_feed_exists
() { test_feed_exists
"long feed"; }
85 function test_long_item_exists
() { test_item_exists
"long feed/$LC"; }
86 function test_long_item_contents
{ test_item_contents
"long feed/$LC" "$LO"; }
88 function test_complete_feed_exists
() { test_feed_exists
"$FEED"; }
89 function test_complete_feed_empty
() { test_feed_empty
"$FEED"; }
90 function test_complete_feed_date
() { test_feed_date
"$FEED" 1286052203; }
91 function test_complete_item1_exists
() { test_item_exists
"$FEED/$ITEM1"; }
92 function test_complete_item2_exists
() { test_item_exists
"$FEED/$ITEM2"; }
93 function test_complete_item3_exists
() { test_item_exists
"$FEED/$ITEM3"; }
94 function test_complete_item1_date
() { test_item_date
"$FEED/$ITEM1" 1286052203; }
95 function test_complete_item2_date
() { test_item_date
"$FEED/$ITEM2" 1270203000; }
96 function test_complete_item3_date
() { test_item_date
"$FEED/$ITEM3" 1270119246; }
97 function test_complete_item1_contents
()
104 Link: <a href=\"/dev/random\">/dev/random</a>"
105 test_item_contents
"$FEED/$ITEM1" "$exp"
107 function test_complete_item2_contents
()
114 Link: <a href=\"/dev/urandom\">/dev/urandom</a>"
115 test_item_contents
"$FEED/$ITEM2" "$exp"
117 function test_complete_item3_contents
()
124 Link: <a href=\"/dev/null\">/dev/null</a>"
125 test_item_contents
"$FEED/$ITEM3" "$exp"
128 ###############################################
130 echo "Cleaning directory..."
133 echo "Running agg on feed without title..."
134 agg_fail tests_titleless.rss
137 echo "Running agg on feed with title after items..."
138 agg_fail tests_titlelate.rss
141 echo "Running agg on simple feed (titles)..."
142 agg_run tests_simple_titles.rss
143 t test_simple_t_feed_exists
144 t test_simple_t_item_exists
145 t test_simple_t_item_date
146 t test_simple_t_item_contents
148 echo "Running agg on simple feed (descriptions)..."
149 agg_run tests_simple_descriptions.rss
150 t test_simple_d_feed_exists
151 t test_simple_d_item_contents
153 echo "Running agg on missing directory..."
155 t test_complete_feed_exists
156 t test_complete_feed_date
157 t test_complete_item1_exists
158 t test_complete_item2_exists
159 t test_complete_item3_exists
160 t test_complete_item1_date
161 t test_complete_item2_date
162 t test_complete_item3_date
163 t test_complete_item1_contents
164 t test_complete_item2_contents
165 t test_complete_item3_contents
167 echo "Running agg on up-to-date directory..."
169 t test_complete_feed_exists
170 t test_complete_feed_date
171 t test_complete_item1_exists
172 t test_complete_item2_exists
173 t test_complete_item3_exists
174 t test_complete_item1_date
175 t test_complete_item2_date
176 t test_complete_item3_date
177 t test_complete_item1_contents
178 t test_complete_item2_contents
179 t test_complete_item3_contents
181 echo "Deleting old news..."
183 t test_complete_feed_exists
184 t test_complete_feed_date
185 t test_complete_feed_empty
187 echo "Running agg on clean up-to-date directory..."
189 t test_complete_feed_exists
190 t test_complete_feed_date
191 t test_complete_feed_empty
193 echo "Changing mtime..."
194 touch -md "1970-01-01 00:00:00.000000000 +0000" "$FEED"
196 echo "Running agg on clean outdated directory..."
198 t test_complete_feed_exists
199 t test_complete_feed_date
200 t test_complete_item1_exists
201 t test_complete_item2_exists
202 t test_complete_item3_exists
203 t test_complete_item1_date
204 t test_complete_item2_date
205 t test_complete_item3_date
206 t test_complete_item1_contents
207 t test_complete_item2_contents
208 t test_complete_item3_contents
210 echo "Running agg on feed with long items..."
211 agg_run tests_long.rss
212 t test_long_feed_exists
213 t test_long_item_exists
214 t test_long_item_contents
216 echo "Cleaning up..."
219 echo "Failed $FAILURES times!"