X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/a812692a50de69215a8267c7b0b1d7bf62bdfa32..14909f1d51ddbcf7d14799e06b3c7908f40e9256:/t/trail.t diff --git a/t/trail.t b/t/trail.t index 17fe54310..cac64c366 100755 --- a/t/trail.t +++ b/t/trail.t @@ -1,17 +1,63 @@ #!/usr/bin/perl use warnings; use strict; -use Test::More 'no_plan'; +use Test::More; use IkiWiki; +sub check_trail { + my $file=shift; + my $expected=shift; + my $trailname=shift || qr/\w+/; + my $blob=readfile("t/tmp/out/$file"); + my ($trailline)=$blob=~/^trail=$trailname\s+(.*)$/m; + is($trailline, $expected, "expected $expected in $file"); +} + +sub check_no_trail { + my $file=shift; + my $trailname=shift || qr/\w+/; + my $blob=readfile("t/tmp/out/$file"); + my ($trailline)=$blob=~/^trail=$trailname\s+(.*)$/m; + $trailline="" unless defined $trailline; + ok($trailline !~ /^trail=$trailname\s+/, "no trail $trailname in $file"); +} + my $blob; ok(! system("rm -rf t/tmp")); ok(! system("mkdir t/tmp")); +my $installed = $ENV{INSTALLED_TESTS}; + +my @command; +if ($installed) { + @command = qw(ikiwiki); +} +else { + ok(! system("make -s ikiwiki.out")); + @command = qw(perl -I. ./ikiwiki.out + --underlaydir=underlays/basewiki + --set underlaydirbase=underlays + --templatedir=templates); +} + +push @command, qw(--set usedirs=0 --plugin trail --plugin inline + --url=http://example.com --cgiurl=http://example.com/ikiwiki.cgi + --rss --atom t/tmp/in t/tmp/out --verbose); + +# Write files with a date in the past, so that when we refresh, +# the update is detected. +sub write_old_file { + my $name = shift; + my $content = shift; + + writefile($name, "t/tmp/in", $content); + ok(utime(333333333, 333333333, "t/tmp/in/$name")); +} + # Use a rather stylized template to override the default rendering, to make # it easy to search for the desired results -writefile("templates/trails.tmpl", "t/tmp/in", <