diff options
author | Simon McVittie <smcv@debian.org> | 2018-03-09 11:24:41 +0000 |
---|---|---|
committer | Simon McVittie <smcv@debian.org> | 2018-03-09 11:24:41 +0000 |
commit | f17ed8b1be216e14e1ed38d63d6ea827c7fe198d (patch) | |
tree | 12ddb2e9bddb50c4c0a4117d5dfe0ef01af8077b /t | |
parent | 7edeed1f1a070caf5e5b15d46bf3730811d524b6 (diff) | |
download | ikiwiki-f17ed8b1be216e14e1ed38d63d6ea827c7fe198d.tar ikiwiki-f17ed8b1be216e14e1ed38d63d6ea827c7fe198d.tar.gz |
not-truncated.t: Work correctly as an installed-test
Signed-off-by: Simon McVittie <smcv@debian.org>
Diffstat (limited to 't')
-rwxr-xr-x | t/not-truncated.t | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/t/not-truncated.t b/t/not-truncated.t index 15450c267..dba97c8f3 100755 --- a/t/not-truncated.t +++ b/t/not-truncated.t @@ -6,10 +6,39 @@ # -rw-r--r-- root/root 0 2018-01-06 23:20 ./usr/share/perl5/IkiWiki/Plugin/wikitext.pm use warnings; use strict; +use Cwd qw(getcwd); +use File::Find qw(find); use Test::More; my @libs="IkiWiki.pm"; -push @libs, map { chomp; $_ } `find IkiWiki -type f -name \\*.pm`; + +if ($ENV{INSTALLED_TESTS}) { + foreach my $libdir (@INC) { + my $wanted = sub { + return unless /\.pm$/; + my $name = $File::Find::name; + if ($name =~ s{^\Q$libdir/\E}{}) { + push @libs, $name; + } + }; + + if (-e "$libdir/IkiWiki.pm" && -d "$libdir/IkiWiki") { + find($wanted, "$libdir/IkiWiki"); + last; + } + } +} +else { + my $cwd = getcwd; + my $wanted = sub { + return unless /\.pm$/; + my $name = $File::Find::name; + if ($name =~ s{^\Q$cwd/\E}{}) { + push @libs, $name; + } + }; + find($wanted, "$cwd/IkiWiki"); +} plan(tests => scalar @libs); |