summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2010-12-20 14:27:21 +0100
committerintrigeri <intrigeri@boum.org>2010-12-20 14:27:21 +0100
commit75196e76b627709a6ecae3fa948e1fba7928a5ce (patch)
tree6aa2baeb9cc68f98ca256ce0ff5cb20909f52ef9 /t
parent8c2962ec48ae57605d6d0e297be437a97b6229ca (diff)
parente5ed3c9e3801360cc00ce4f4f325f68ac0770bff (diff)
Merge remote branch 'upstream/master' into prv/po
Diffstat (limited to 't')
-rwxr-xr-xt/bazaar.t8
-rwxr-xr-xt/pagespec_match.t5
-rwxr-xr-xt/permalink.t4
-rwxr-xr-xt/rssurls.t37
-rwxr-xr-xt/urlto.t46
5 files changed, 97 insertions, 3 deletions
diff --git a/t/bazaar.t b/t/bazaar.t
index cd840fbe1..6e58f48f1 100755
--- a/t/bazaar.t
+++ b/t/bazaar.t
@@ -25,6 +25,14 @@ $config{srcdir} = "$dir/repo";
IkiWiki::loadplugins();
IkiWiki::checkconfig();
+# XXX
+# This is a workaround for bzr's new requirement that bzr whoami be run
+# before committing. This makes the test suite work with an unconfigured
+# bzr, but ignores the need to have a properly configured bzr before
+# using ikiwiki with bzr.
+$ENV{HOME}=$dir;
+system 'bzr whoami test@example.com';
+
system "bzr init $config{srcdir}";
use CGI::Session;
diff --git a/t/pagespec_match.t b/t/pagespec_match.t
index 97bcc969c..a37b06e8e 100755
--- a/t/pagespec_match.t
+++ b/t/pagespec_match.t
@@ -1,7 +1,7 @@
#!/usr/bin/perl
use warnings;
use strict;
-use Test::More tests => 85;
+use Test::More tests => 87;
BEGIN { use_ok("IkiWiki"); }
@@ -82,6 +82,8 @@ ok(! pagespec_match("foo.png", "page(foo*)"), "page() fails on non-page glob");
ok(pagespec_match("foo", "page(foo)"), "page() glob");
ok(pagespec_match("foo", "page(f*)"), "page() glob fail");
ok(pagespec_match("foo", "link(bar)"), "link");
+ok(pagespec_match("foo", "link(.)", location => "bar"), "link with .");
+ok(! pagespec_match("foo", "link(.)"), "link with . but missing location");
ok(pagespec_match("foo", "link(ba?)"), "glob link");
ok(! pagespec_match("foo", "link(quux)"), "failed link");
ok(! pagespec_match("foo", "link(qu*)"), "failed glob link");
@@ -99,6 +101,7 @@ ok(pagespec_match("ook", "link(blog/tags/foo)"), "link internal absolute success
ok(pagespec_match("ook", "link(/blog/tags/foo)"), "link explicit absolute success");
ok(pagespec_match("meh", "!link(done)"), "negated failing match is a success");
+$ENV{TZ}="GMT";
$IkiWiki::pagectime{foo}=1154532692; # Wed Aug 2 11:26 EDT 2006
$IkiWiki::pagectime{bar}=1154532695; # after
ok(pagespec_match("foo", "created_before(bar)"));
diff --git a/t/permalink.t b/t/permalink.t
index adb8648b4..81d4d1820 100755
--- a/t/permalink.t
+++ b/t/permalink.t
@@ -8,6 +8,6 @@ ok(! system("make -s ikiwiki.out"));
ok(! system("perl -I. ./ikiwiki.out -plugin inline -url=http://example.com -cgiurl=http://example.com/ikiwiki.cgi -rss -atom -underlaydir=underlays/basewiki -set underlaydirbase=underlays -templatedir=templates t/tinyblog t/tmp/out"));
# This guid should never, ever change, for any reason whatsoever!
my $guid="http://example.com/post/";
-ok(length `grep '<guid>$guid</guid>' t/tmp/out/index.rss`);
-ok(length `grep '<id>$guid</id>' t/tmp/out/index.atom`);
+ok(length `egrep '<guid.*>$guid</guid>' t/tmp/out/index.rss`);
+ok(length `egrep '<id>$guid</id>' t/tmp/out/index.atom`);
ok(! system("rm -rf t/tmp t/tinyblog/.ikiwiki"));
diff --git a/t/rssurls.t b/t/rssurls.t
new file mode 100755
index 000000000..870770496
--- /dev/null
+++ b/t/rssurls.t
@@ -0,0 +1,37 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use Test::More tests => 13;
+
+BEGIN { use_ok("IkiWiki::Plugin::inline"); }
+
+# Test the absolute_urls function, used to fix up relative urls for rss
+# feeds.
+sub test {
+ my $input=shift;
+ my $baseurl=shift;
+ my $expected=shift;
+ $expected=~s/URL/$baseurl/g;
+ is(IkiWiki::absolute_urls($input, $baseurl), $expected);
+ # try it with single quoting -- it's ok if the result comes back
+ # double or single-quoted
+ $input=~s/"/'/g;
+ my $expected_alt=$expected;
+ $expected_alt=~s/"/'/g;
+ my $ret=IkiWiki::absolute_urls($input, $baseurl);
+ ok(($ret eq $expected) || ($ret eq $expected_alt), "$ret vs $expected");
+}
+
+sub unchanged {
+ test($_[0], $_[1], $_[0]);
+}
+
+my $url="http://example.com/blog/foo/";
+unchanged("foo", $url);
+unchanged('<a href="http://other.com/bar.html">', $url, );
+test('<a href="bar.html">', $url, '<a href="URLbar.html">');
+test('<a href="/bar.html">', $url, '<a href="http://example.com/bar.html">');
+test('<img src="bar.png" />', $url, '<img src="URLbar.png" />');
+test('<img src="/bar.png" />', $url, '<img src="http://example.com/bar.png" />');
+# off until bug #603736 is fixed
+#test('<video controls src="bar.ogg">', $url, '<video controls src="URLbar.ogg">');
diff --git a/t/urlto.t b/t/urlto.t
new file mode 100755
index 000000000..254455792
--- /dev/null
+++ b/t/urlto.t
@@ -0,0 +1,46 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use Test::More tests => 21;
+
+BEGIN { use_ok("IkiWiki"); }
+
+$IkiWiki::config{srcdir} = '/does/not/exist/';
+$IkiWiki::config{usedirs} = 1;
+$IkiWiki::config{htmlext} = "HTML";
+$IkiWiki::config{wiki_file_chars} = "A-Za-z0-9._";
+
+$IkiWiki::config{url} = "http://smcv.example.co.uk";
+$IkiWiki::config{cgiurl} = "http://smcv.example.co.uk/cgi-bin/ikiwiki.cgi";
+is(IkiWiki::checkconfig(), 1);
+
+# absolute version
+is(IkiWiki::cgiurl(cgiurl => $config{cgiurl}), "http://smcv.example.co.uk/cgi-bin/ikiwiki.cgi");
+is(IkiWiki::cgiurl(cgiurl => $config{cgiurl}, do => 'badger'), "http://smcv.example.co.uk/cgi-bin/ikiwiki.cgi?do=badger");
+is(IkiWiki::urlto('index', undef, 1), "http://smcv.example.co.uk/");
+is(IkiWiki::urlto('stoats', undef, 1), "http://smcv.example.co.uk/stoats/");
+
+# "local" (absolute path within site) version (default for cgiurl)
+is(IkiWiki::cgiurl(), "/cgi-bin/ikiwiki.cgi");
+is(IkiWiki::cgiurl(do => 'badger'), "/cgi-bin/ikiwiki.cgi?do=badger");
+is(IkiWiki::baseurl(undef), "/");
+is(IkiWiki::urlto('index', undef), "/");
+is(IkiWiki::urlto('index'), "/");
+is(IkiWiki::urlto('stoats', undef), "/stoats/");
+is(IkiWiki::urlto('stoats'), "/stoats/");
+
+# fully-relative version (default for urlto and baseurl)
+is(IkiWiki::baseurl('badger/mushroom'), "../../");
+is(IkiWiki::urlto('badger/mushroom', 'snake'), "../badger/mushroom/");
+
+# explicit cgiurl override
+is(IkiWiki::cgiurl(cgiurl => 'https://foo/ikiwiki'), "https://foo/ikiwiki");
+is(IkiWiki::cgiurl(do => 'badger', cgiurl => 'https://foo/ikiwiki'), "https://foo/ikiwiki?do=badger");
+
+# with url and cgiurl on different sites, "local" degrades to absolute
+$IkiWiki::config{url} = "http://example.co.uk/~smcv";
+$IkiWiki::config{cgiurl} = "http://dynamic.example.co.uk/~smcv/ikiwiki.cgi";
+is(IkiWiki::checkconfig(), 1);
+is(IkiWiki::cgiurl(), "http://dynamic.example.co.uk/~smcv/ikiwiki.cgi");
+is(IkiWiki::baseurl(undef), "http://example.co.uk/~smcv/");
+is(IkiWiki::urlto('stoats', undef), "http://example.co.uk/~smcv/stoats/");