diff options
author | joey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071> | 2006-09-09 22:50:27 +0000 |
---|---|---|
committer | joey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071> | 2006-09-09 22:50:27 +0000 |
commit | dae0f48e91304afcb6ebe0936360e51b22a56548 (patch) | |
tree | 930090e4343087dac7ae6693d420d80b826c57f2 /t | |
parent | d92142d09eaec9018c0cdc96f9ad3bd4a0c876a7 (diff) |
* Work on firming up the plugin interface:
- Plugins should not need to load IkiWiki::Render to get commonly
used functions, so moved some functions from there to IkiWiki.
- Picked out the set of functions and variables that most plugins
use, documented them, and made IkiWiki export them by default,
like a proper perl module should.
- Use the other functions at your own risk.
- This is not quite complete, I still have to decide whether to
export some other things.
* Changed all plugins included in ikiwiki to not use "IkiWiki::" when
referring to stuff now exported by the IkiWiki module.
* Anyone with a third-party ikiwiki plugin is strongly enrouraged
to make like changes to it and avoid use of non-exported symboles from
"IkiWiki::".
* Link debian/changelog and debian/news to NEWS and CHANGELOG.
* Support hyperestradier version 1.4.2, which adds a new required phraseform
setting.
Diffstat (limited to 't')
-rwxr-xr-x | t/bestlink.t | 10 | ||||
-rwxr-xr-x | t/crazy-badass-perl-bug.t | 11 | ||||
-rwxr-xr-x | t/html.t | 3 | ||||
-rwxr-xr-x | t/htmlize.t | 11 | ||||
-rwxr-xr-x | t/linkify.t | 12 | ||||
-rwxr-xr-x | t/pagespec_match.t | 70 | ||||
-rwxr-xr-x | t/pagespec_merge.t | 12 | ||||
-rwxr-xr-x | t/readfile.t | 4 |
8 files changed, 65 insertions, 68 deletions
diff --git a/t/bestlink.t b/t/bestlink.t index ece900152..9358bf376 100755 --- a/t/bestlink.t +++ b/t/bestlink.t @@ -3,23 +3,23 @@ use warnings; use strict; use Test::More tests => 9; +BEGIN { use_ok("IkiWiki"); } + sub test ($$$) { my $page=shift; my $link=shift; my @existing_pages=@{shift()}; %IkiWiki::pagecase=(); - %IkiWiki::links=(); + %links=(); foreach my $page (@existing_pages) { $IkiWiki::pagecase{lc $page}=$page; - $IkiWiki::links{$page}=[]; + $links{$page}=[]; } - return IkiWiki::bestlink($page, $link); + return bestlink($page, $link); } -BEGIN { use_ok("IkiWiki"); } - is(test("bar", "foo", ["bar"]), "", "broken link"); is(test("bar", "foo", ["bar", "foo"]), "foo", "simple link"); is(test("bar", "FoO", ["bar", "foo"]), "foo", "simple link with different input case"); diff --git a/t/crazy-badass-perl-bug.t b/t/crazy-badass-perl-bug.t index 78f0b5011..27812559b 100755 --- a/t/crazy-badass-perl-bug.t +++ b/t/crazy-badass-perl-bug.t @@ -4,16 +4,15 @@ # to htmlize are changed. use warnings; use strict; -use Test::More tests => 103; +use Test::More tests => 102; use Encode; BEGIN { use_ok("IkiWiki"); } -BEGIN { use_ok("IkiWiki::Render"); } # Initialize htmlscrubber plugin -%IkiWiki::config=IkiWiki::defaultconfig(); -$IkiWiki::config{srcdir}=$IkiWiki::config{destdir}="/dev/null"; +%config=IkiWiki::defaultconfig(); +$config{srcdir}=$config{destdir}="/dev/null"; IkiWiki::loadplugins(); IkiWiki::checkconfig(); -ok(IkiWiki::htmlize("foo", "mdwn", IkiWiki::readfile("t/test1.mdwn"))); -ok(IkiWiki::htmlize("foo", "mdwn", IkiWiki::readfile("t/test3.mdwn")), +ok(IkiWiki::htmlize("foo", "mdwn", readfile("t/test1.mdwn"))); +ok(IkiWiki::htmlize("foo", "mdwn", readfile("t/test3.mdwn")), "wtf?") for 1..100; @@ -11,10 +11,9 @@ BEGIN { plan skip_all => "/usr/bin/validate html validator not present"; } else { - plan(tests => int @pages + 3); + plan(tests => int @pages + 2); } use_ok("IkiWiki"); - use_ok("IkiWiki::Render"); } # Have to build the html pages first. diff --git a/t/htmlize.t b/t/htmlize.t index fc9ca5b84..a9ccfedcb 100755 --- a/t/htmlize.t +++ b/t/htmlize.t @@ -1,22 +1,21 @@ #!/usr/bin/perl use warnings; use strict; -use Test::More tests => 5; +use Test::More tests => 4; use Encode; BEGIN { use_ok("IkiWiki"); } -BEGIN { use_ok("IkiWiki::Render"); } # Initialize htmlscrubber plugin -%IkiWiki::config=IkiWiki::defaultconfig(); -$IkiWiki::config{srcdir}=$IkiWiki::config{destdir}="/dev/null"; +%config=IkiWiki::defaultconfig(); +$config{srcdir}=$config{destdir}="/dev/null"; IkiWiki::loadplugins(); IkiWiki::checkconfig(); is(IkiWiki::htmlize("foo", "mdwn", "foo\n\nbar\n"), "<p>foo</p>\n\n<p>bar</p>\n", "basic"); -is(IkiWiki::htmlize("foo", "mdwn", IkiWiki::readfile("t/test1.mdwn")), +is(IkiWiki::htmlize("foo", "mdwn", readfile("t/test1.mdwn")), Encode::decode_utf8(qq{<p><img src="../images/o.jpg" alt="o" title="ó" />\nóóóóó</p>\n}), "utf8; bug #373203"); -ok(IkiWiki::htmlize("foo", "mdwn", IkiWiki::readfile("t/test2.mdwn")), +ok(IkiWiki::htmlize("foo", "mdwn", readfile("t/test2.mdwn")), "this file crashes markdown if it's fed in as decoded utf-8"); diff --git a/t/linkify.t b/t/linkify.t index 2ed3face3..74747e127 100755 --- a/t/linkify.t +++ b/t/linkify.t @@ -3,6 +3,8 @@ use warnings; use strict; use Test::More tests => 13; +BEGIN { use_ok("IkiWiki"); } + sub linkify ($$$$) { my $lpage=shift; my $page=shift; @@ -13,13 +15,13 @@ sub linkify ($$$$) { # This is what linkify and htmllink need set right now to work. # This could change, if so, update it.. %IkiWiki::pagecase=(); - %IkiWiki::links=(); + %links=(); foreach my $page (@existing_pages) { $IkiWiki::pagecase{lc $page}=$page; - $IkiWiki::links{$page}=[]; - $IkiWiki::renderedfiles{"$page.mdwn"}=$page; + $links{$page}=[]; + $renderedfiles{"$page.mdwn"}=$page; } - %IkiWiki::config=IkiWiki::defaultconfig(); + %config=IkiWiki::defaultconfig(); return IkiWiki::linkify($lpage, $page, $content); } @@ -64,8 +66,6 @@ sub links_text ($$) { } -BEGIN { use_ok("IkiWiki::Render"); } - ok(links_to("bar", linkify("foo", "foo", "link to [[bar]] ok", ["foo", "bar"])), "ok link"); ok(not_links_to("bar", linkify("foo", "foo", "link to \\[[bar]] ok", ["foo", "bar"])), "escaped link"); ok(links_to("page=bar", linkify("foo", "foo", "link to [[bar]] ok", ["foo"])), "broken link"); diff --git a/t/pagespec_match.t b/t/pagespec_match.t index 20243dfa6..bf6c8cbdf 100755 --- a/t/pagespec_match.t +++ b/t/pagespec_match.t @@ -5,44 +5,44 @@ use Test::More tests => 35; BEGIN { use_ok("IkiWiki"); } -ok(IkiWiki::pagespec_match("foo", "*")); -ok(IkiWiki::pagespec_match("page", "?ag?")); -ok(! IkiWiki::pagespec_match("page", "?a?g?")); -ok(IkiWiki::pagespec_match("foo.png", "*.*")); -ok(! IkiWiki::pagespec_match("foo", "*.*")); -ok(IkiWiki::pagespec_match("foo", "foo or bar"), "simple list"); -ok(IkiWiki::pagespec_match("bar", "foo or bar"), "simple list 2"); -ok(IkiWiki::pagespec_match("foo", "f?? and !foz")); -ok(! IkiWiki::pagespec_match("foo", "f?? and !foo")); -ok(! IkiWiki::pagespec_match("foo", "* and !foo")); -ok(! IkiWiki::pagespec_match("foo", "foo and !foo")); -ok(! IkiWiki::pagespec_match("foo.png", "* and !*.*")); -ok(IkiWiki::pagespec_match("foo", "(bar or ((meep and foo) or (baz or foo) or beep))")); +ok(pagespec_match("foo", "*")); +ok(pagespec_match("page", "?ag?")); +ok(! pagespec_match("page", "?a?g?")); +ok(pagespec_match("foo.png", "*.*")); +ok(! pagespec_match("foo", "*.*")); +ok(pagespec_match("foo", "foo or bar"), "simple list"); +ok(pagespec_match("bar", "foo or bar"), "simple list 2"); +ok(pagespec_match("foo", "f?? and !foz")); +ok(! pagespec_match("foo", "f?? and !foo")); +ok(! pagespec_match("foo", "* and !foo")); +ok(! pagespec_match("foo", "foo and !foo")); +ok(! pagespec_match("foo.png", "* and !*.*")); +ok(pagespec_match("foo", "(bar or ((meep and foo) or (baz or foo) or beep))")); -$IkiWiki::links{foo}=[qw{bar baz}]; -ok(IkiWiki::pagespec_match("foo", "link(bar)")); -ok(! IkiWiki::pagespec_match("foo", "link(quux)")); -ok(IkiWiki::pagespec_match("bar", "backlink(foo)")); -ok(! IkiWiki::pagespec_match("quux", "backlink(foo)")); +$links{foo}=[qw{bar baz}]; +ok(pagespec_match("foo", "link(bar)")); +ok(! pagespec_match("foo", "link(quux)")); +ok(pagespec_match("bar", "backlink(foo)")); +ok(! pagespec_match("quux", "backlink(foo)")); $IkiWiki::pagectime{foo}=1154532692; # Wed Aug 2 11:26 EDT 2006 $IkiWiki::pagectime{bar}=1154532695; # after -ok(IkiWiki::pagespec_match("foo", "created_before(bar)")); -ok(! IkiWiki::pagespec_match("foo", "created_after(bar)")); -ok(! IkiWiki::pagespec_match("bar", "created_before(foo)")); -ok(IkiWiki::pagespec_match("bar", "created_after(foo)")); -ok(IkiWiki::pagespec_match("foo", "creation_year(2006)"), "year"); -ok(! IkiWiki::pagespec_match("foo", "creation_year(2005)"), "other year"); -ok(IkiWiki::pagespec_match("foo", "creation_month(8)"), "month"); -ok(! IkiWiki::pagespec_match("foo", "creation_month(9)"), "other month"); -ok(IkiWiki::pagespec_match("foo", "creation_day(2)"), "day"); -ok(! IkiWiki::pagespec_match("foo", "creation_day(3)"), "other day"); +ok(pagespec_match("foo", "created_before(bar)")); +ok(! pagespec_match("foo", "created_after(bar)")); +ok(! pagespec_match("bar", "created_before(foo)")); +ok(pagespec_match("bar", "created_after(foo)")); +ok(pagespec_match("foo", "creation_year(2006)"), "year"); +ok(! pagespec_match("foo", "creation_year(2005)"), "other year"); +ok(pagespec_match("foo", "creation_month(8)"), "month"); +ok(! pagespec_match("foo", "creation_month(9)"), "other month"); +ok(pagespec_match("foo", "creation_day(2)"), "day"); +ok(! pagespec_match("foo", "creation_day(3)"), "other day"); # old style globlists -ok(IkiWiki::pagespec_match("foo", "foo bar"), "simple list"); -ok(IkiWiki::pagespec_match("bar", "foo bar"), "simple list 2"); -ok(IkiWiki::pagespec_match("foo", "f?? !foz")); -ok(! IkiWiki::pagespec_match("foo", "f?? !foo")); -ok(! IkiWiki::pagespec_match("foo", "* !foo")); -ok(! IkiWiki::pagespec_match("foo", "foo !foo")); -ok(! IkiWiki::pagespec_match("foo.png", "* !*.*")); +ok(pagespec_match("foo", "foo bar"), "simple list"); +ok(pagespec_match("bar", "foo bar"), "simple list 2"); +ok(pagespec_match("foo", "f?? !foz")); +ok(! pagespec_match("foo", "f?? !foo")); +ok(! pagespec_match("foo", "* !foo")); +ok(! pagespec_match("foo", "foo !foo")); +ok(! pagespec_match("foo.png", "* !*.*")); diff --git a/t/pagespec_merge.t b/t/pagespec_merge.t index c2860709b..cbb06219c 100755 --- a/t/pagespec_merge.t +++ b/t/pagespec_merge.t @@ -3,20 +3,20 @@ use warnings; use strict; use Test::More tests => 25; +BEGIN { use_ok("IkiWiki"); } + sub same { my $a=shift; my $b=shift; my $match=shift; - my $imatch=(IkiWiki::pagespec_match($match, $a) || - IkiWiki::pagespec_match($match, $b)); - my $cmatch=IkiWiki::pagespec_match($match, IkiWiki::pagespec_merge($a, $b)); + my $imatch=(pagespec_match($match, $a) || + pagespec_match($match, $b)); + my $cmatch=pagespec_match($match, IkiWiki::pagespec_merge($a, $b)); return $imatch == $cmatch; } -BEGIN { use_ok("IkiWiki"); } - ok(same("foo", "bar", "foo"), "basic match 1"); ok(same("foo", "bar", "bar"), "basic match 2"); ok(same("foo", "bar", "foobar"), "basic failed match"); @@ -36,7 +36,7 @@ ok(same("f?? !f??", "!bar", "bar"), "matching glob and matching inverted glob"); ok(same("b??", "!b?z", "bar"), "matching glob and non-matching inverted glob"); ok(same("f?? !f?z", "!bar", "bar"), "matching glob and non-matching inverted glob"); ok(same("!foo bar baz", "!bar", "bar"), "matching list and matching inversion"); -ok(IkiWiki::pagespec_match("foo/Discussion", +ok(pagespec_match("foo/Discussion", IkiWiki::pagespec_merge("* !*/Discussion", "*/Discussion")), "should match"); ok(same("* !*/Discussion", "*/Discussion", "foo/Discussion"), "Discussion merge 1"); ok(same("*/Discussion", "* !*/Discussion", "foo/Discussion"), "Discussion merge 2"); diff --git a/t/readfile.t b/t/readfile.t index 5332f4c35..bb1c6bae3 100755 --- a/t/readfile.t +++ b/t/readfile.t @@ -7,6 +7,6 @@ use Encode; BEGIN { use_ok("IkiWiki"); } # should read files as utf8 -ok(Encode::is_utf8(IkiWiki::readfile("t/test1.mdwn"), 1)); -is(IkiWiki::readfile("t/test1.mdwn"), +ok(Encode::is_utf8(readfile("t/test1.mdwn"), 1)); +is(readfile("t/test1.mdwn"), Encode::decode_utf8('![o](../images/o.jpg "ó")'."\n".'óóóóó'."\n")); |