Merge remote-tracking branch 'origin/master'
[ikiwiki] / t / not-truncated.t
1 #!/usr/bin/perl
2 # Regression test for a weird build issue where wikitext.pm was installed
3 # as an empty file, possibly caused by parallel builds. This was hopefully
4 # fixed by making the build steps more robust in 3.20180228.
5 # https://buildd.debian.org/status/fetch.php?pkg=ikiwiki&arch=all&ver=3.20180105-1&stamp=1515285462&raw=0
6 # -rw-r--r-- root/root         0 2018-01-06 23:20 ./usr/share/perl5/IkiWiki/Plugin/wikitext.pm
7 use warnings;
8 use strict;
9 use Cwd qw(getcwd);
10 use File::Find qw(find);
11 use Test::More;
12
13 my @libs="IkiWiki.pm";
14
15 if ($ENV{INSTALLED_TESTS}) {
16         foreach my $libdir (@INC) {
17                 my $wanted = sub {
18                         return unless /\.pm$/;
19                         my $name = $File::Find::name;
20                         if ($name =~ s{^\Q$libdir/\E}{}) {
21                                 push @libs, $name;
22                         }
23                 };
24
25                 if (-e "$libdir/IkiWiki.pm" && -d "$libdir/IkiWiki") {
26                         find($wanted, "$libdir/IkiWiki");
27                         last;
28                 }
29         }
30 }
31 else {
32         my $cwd = getcwd;
33         my $wanted = sub {
34                 return unless /\.pm$/;
35                 my $name = $File::Find::name;
36                 if ($name =~ s{^\Q$cwd/\E}{}) {
37                         push @libs, $name;
38                 }
39         };
40         find($wanted, "$cwd/IkiWiki");
41 }
42
43 plan(tests => scalar @libs);
44
45 FILE: foreach my $file (@libs) {
46         foreach my $libdir (@INC) {
47                 if (-e "$libdir/$file") {
48                         ok(-s "$libdir/$file", "$file available in $libdir and not truncated");
49                         next FILE;
50                 }
51         }
52         fail("$file not available in ".join(':', @INC));
53 }