]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - t/basewiki_brokenlinks.t
describe simplified solution for simplified scenario.
[git.ikiwiki.info.git] / t / basewiki_brokenlinks.t
1 #!/usr/bin/perl
2 use warnings;
3 use strict;
4 use Cwd qw(getcwd);
5 use Test::More;
7 my $installed = $ENV{INSTALLED_TESTS};
9 ok(! system("rm -rf t/tmp; mkdir t/tmp"));
11 my @command;
12 if ($installed) {
13         @command = qw(env LC_ALL=C ikiwiki);
14 }
15 else {
16         ok(! system("make -s ikiwiki.out"));
17         ok(! system("make underlay_install DESTDIR=`pwd`/t/tmp/install PREFIX=/usr >/dev/null"));
18         @command = (qw(env LC_ALL=C perl), "-I".getcwd, qw(./ikiwiki.out
19                 --underlaydir=t/tmp/install/usr/share/ikiwiki/basewiki
20                 --set underlaydirbase=t/tmp/install/usr/share/ikiwiki
21                 --templatedir=templates));
22 }
24 foreach my $plugin ("", "listdirectives") {
25         ok(! system(@command, qw(--rebuild --plugin brokenlinks),
26                         # always enabled because pages link to it conditionally,
27                         # which brokenlinks cannot handle properly
28                         qw(--plugin smiley),
29                         ($plugin ? ("--plugin", $plugin) : ()),
30                         qw(t/basewiki_brokenlinks t/tmp/out)));
31         my $result=`grep 'no broken links' t/tmp/out/index.html`;
32         ok(length($result));
33         if (! length $result) {
34                 print STDERR "\n\nbroken links found".($plugin ? " (with $plugin)" : "")."\n";
35                 system("grep '<li>' t/tmp/out/index.html >&2");
36                 print STDERR "\n\n";
37         }
38         ok(-e "t/tmp/out/style.css"); # linked to..
39         ok(! system("rm -rf t/tmp/out t/basewiki_brokenlinks/.ikiwiki"));
40 }
42 done_testing();