#!/usr/bin/perl
use warnings;
use strict;
use Cwd qw(getcwd);
use Test::More;
use IkiWiki;
my $tmp = 't/tmp';
my $srcdir = "$tmp/in";
my $destdir = "$tmp/out";
my $installed = $ENV{INSTALLED_TESTS};
my @command;
if ($installed) {
@command = qw(ikiwiki);
}
else {
ok(! system("make -s ikiwiki.out"));
@command = ("perl", "-I".getcwd, qw(./ikiwiki.out
--underlaydir=underlays/basewiki
--set underlaydirbase=underlays
--templatedir=templates));
}
push @command, qw(--plugin meta --disable-plugin htmlscrubber);
push @command, $srcdir, $destdir;
sub write_build_read_compare {
my ($pagename, $input, $expected_output) = @_;
ok(! system("rm -rf $tmp"), q{setup});
ok(! system("mkdir -p $srcdir"), q{setup});
writefile("$pagename.mdwn", $srcdir, $input);
ok(! system(@command), q{build});
like(readfile("$destdir/$pagename/index.html"), $expected_output);
}
write_build_read_compare(
'title',
q{[[!meta title="a page about bar"]]},
qr{
a page about bar},
);
write_build_read_compare(
'description',
q{[[!meta description="a page about bar"]]},
qr{},
);
write_build_read_compare(
'guid',
q{[[!meta guid="12345"]]},
qr{},
);
write_build_read_compare(
'license',
q{[[!meta license="you get to keep both pieces"]]},
qr{