X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/4e54fa1144065b7ff99e88e6c61ff1fdcf6175c9..d7d93c4047fda7d528b8ba3618d1d6b05ed49828:/t/trail.t diff --git a/t/trail.t b/t/trail.t index 0cf50ddc1..53c5efb0b 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; + my $blob=readfile("t/tmp/out/$file"); + my ($trailline)=$blob=~/^trail=$trailname\s+(.*)$/m; + $trailline="" unless defined $trailline; + ok($trailline !~ /^trail=$trailname\s+/, "no $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", <