not-truncated.t: Work correctly as an installed-test
[ikiwiki] / t / wellformed.t
1 #!/usr/bin/perl
2 use warnings;
3 use strict;
4 use Cwd qw();
5 use File::Find;
6 use Test::More;
7
8 plan(skip_all => 'running installed') if $ENV{INSTALLED_TESTS};
9
10 plan(skip_all => "XML::Parser not available")
11         unless eval q{use XML::Parser (); 1;};
12
13 use IkiWiki;
14
15 ok(system("make docwiki >/dev/null") == 0);
16
17 chdir("html") || die "chdir: $!";
18
19 sub wanted {
20         my $file = $_;
21         return if -d $file;
22         $file =~ s{^\./}{};
23         return if $file !~ m/\.html$/;
24         if (eval {
25                 XML::Parser->new()->parsefile($file);
26                 1;
27         }) {
28                 pass($file);
29         }
30         elsif ($file =~ m{^(?:
31                         # user-contributed, contains explicit <br>
32                         plugins/contrib/gallery |
33                         # use templatebody when branchable.com has been upgraded
34                         templates/ |
35                         # malformed content in <pre> not escaped by discount
36                         tips/convert_mediawiki_to_ikiwiki
37                         # user-contributed, content is anyone's guess
38                         users/ |
39                         )}x) {
40                 TODO: {
41                         local $TODO = $@;
42                         fail($file);
43                 }
44         }
45 }
46
47 find({
48         no_chdir => 1,
49         wanted => \&wanted,
50 }, '.');
51
52 done_testing;