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