From b55c49311ac2d38069b60a1f28e288bd3bd1a633 Mon Sep 17 00:00:00 2001 From: Andreas Waidler Date: Fri, 24 Jun 2011 13:34:11 +0200 Subject: [PATCH] Added tests for nomtime. --- TODO | 2 +- tests_usr/libtests.sh | 6 ++++++ tests_usr/nomtime.sh | 36 ++++++++++++++++++++++++++++++++++++ tests_usr/sanity_d.sh | 4 ++-- tests_usr/sanity_f.sh | 4 ++-- tests_usr/sanity_t.sh | 4 ++-- tests_usr/special_d.rss | 10 ++++++++++ tests_usr/special_f.rss | 10 ++++++++++ tests_usr/special_t.rss | 10 ++++++++++ tests_usr/tests | 5 +++-- 10 files changed, 82 insertions(+), 9 deletions(-) create mode 100755 tests_usr/nomtime.sh create mode 100644 tests_usr/special_d.rss create mode 100644 tests_usr/special_f.rss create mode 100644 tests_usr/special_t.rss diff --git a/TODO b/TODO index ef40a25..b672434 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,4 @@ -* test whether nomtime can handle complicated filenames +* do not fail on arbitrarily ordered tags in * more assertions * do not stop on first old item, consume whole feed channel pubDate is not old. diff --git a/tests_usr/libtests.sh b/tests_usr/libtests.sh index 8e9c1a5..f32b8fa 100755 --- a/tests_usr/libtests.sh +++ b/tests_usr/libtests.sh @@ -60,3 +60,9 @@ function assert_empty() { [ `ls "$1" | wc -l` = "0" ]; } function assert_missing() { [ ! -e "$1" ]; } # BUG: "`cat`" drops trailing \n. function assert_value() { [ "`cat \"$1/$2\"`" = "$3" ]; } +function assert_delete() { + BASENAME="`dirname "$1"`" + OLD_DATE="`stat -c %Y "$BASENAME"`" + ../src/nomtime "rm -rf" "$1" + assert_date "$BASENAME" "$OLD_DATE" +} diff --git a/tests_usr/nomtime.sh b/tests_usr/nomtime.sh new file mode 100755 index 0000000..f0912c2 --- /dev/null +++ b/tests_usr/nomtime.sh @@ -0,0 +1,36 @@ +#!/bin/sh +# Copyright (C) 2011 Andreas Waidler +# +# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE +# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION +# +# 0. You just DO WHAT THE FUCK YOU WANT TO. + +. ./libtests.sh + +feed_exists_f() { assert_exists "feed '\" feed!?"; } +feed_item_exists_f() { assert_exists "feed '\" feed!?/item"; } +feed_item_delete_f() { assert_delete "feed '\" feed!?/item"; } + +feed_item_exists_t() { assert_exists "feed/item '\" !?"; } +feed_item_delete_t() { assert_delete "feed/item '\" !?"; } + +echo "Running agg on feed with special characters in title..." +agg_run special_f.rss +t feed_exists_f +t feed_item_exists_f +t feed_item_delete_f + +echo "Running agg on feed with special characters in item title..." +agg_run special_t.rss +t feed_item_exists_t +t feed_item_delete_t + +## FIXME: The following feed could not be handled by agg, +## because date after desc without title. +## write a acceptance test for this case (that +## either fails or passes). +#echo "Running agg on feed with special characters in item description..." +#agg_run special_d.rss +#t feed_item_exists_t +#t feed_item_delete_t diff --git a/tests_usr/sanity_d.sh b/tests_usr/sanity_d.sh index b30dc66..52ee4c1 100755 --- a/tests_usr/sanity_d.sh +++ b/tests_usr/sanity_d.sh @@ -8,8 +8,8 @@ . ./libtests.sh -item_contents() { assert_value feed/\\item desc /item; } +item_contents_d() { assert_value feed/\\item desc /item; } echo "Running agg on evil feed (item description)..." agg_run sanity_d.rss -t item_contents +t item_contents_d diff --git a/tests_usr/sanity_f.sh b/tests_usr/sanity_f.sh index 30602dd..b5b7696 100755 --- a/tests_usr/sanity_f.sh +++ b/tests_usr/sanity_f.sh @@ -8,8 +8,8 @@ . ./libtests.sh -feed_exists() { assert_exists \\feed; } -item_exists() { assert_exists \\feed/item; } +feed_exists() { assert_exists \\feed; } +item_exists() { assert_exists \\feed/item; } echo "Running agg on evil feed (feed title)..." agg_run sanity_f.rss diff --git a/tests_usr/sanity_t.sh b/tests_usr/sanity_t.sh index df9b3c2..644e81c 100755 --- a/tests_usr/sanity_t.sh +++ b/tests_usr/sanity_t.sh @@ -8,8 +8,8 @@ . ./libtests.sh -item_contents() { assert_value feed/\\item title /item; } +item_contents_t() { assert_value feed/\\item title /item; } echo "Running agg on evil feed (item title)..." agg_run sanity_t.rss -t item_contents +t item_contents_t diff --git a/tests_usr/special_d.rss b/tests_usr/special_d.rss new file mode 100644 index 0000000..82021b0 --- /dev/null +++ b/tests_usr/special_d.rss @@ -0,0 +1,10 @@ + + + + feed + + item '" !? + Sat, 02 Oct 2010 22:43:23 +0200 + + + diff --git a/tests_usr/special_f.rss b/tests_usr/special_f.rss new file mode 100644 index 0000000..dee0e32 --- /dev/null +++ b/tests_usr/special_f.rss @@ -0,0 +1,10 @@ + + + + feed '" feed!? + + item + Sat, 02 Oct 2010 22:43:23 +0200 + + + diff --git a/tests_usr/special_t.rss b/tests_usr/special_t.rss new file mode 100644 index 0000000..efa1cc1 --- /dev/null +++ b/tests_usr/special_t.rss @@ -0,0 +1,10 @@ + + + + feed + + item '" !? + Sat, 02 Oct 2010 22:43:23 +0200 + + + diff --git a/tests_usr/tests b/tests_usr/tests index b9bf0cd..b93bd9c 100755 --- a/tests_usr/tests +++ b/tests_usr/tests @@ -8,7 +8,7 @@ function cleanup() { - rm -rf feed \\feed || exit 1 + rm -rf feed \\feed "feed '\" feed!?" || exit 1 } function fail() @@ -27,7 +27,8 @@ feed_title_broken.sh item_title_broken.sh sanity_f.sh sanity_t.sh -sanity_d.sh" +sanity_d.sh +nomtime.sh" cleanup for t in $TESTS; do -- 2.11.4.GIT