This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
allow buildtoc to find libraries after chdir into pod/
[perl5.git] / t / porting / dual-life.t
1 #!/perl -w
2 use 5.010;
3 use strict;
4
5 # This tests properties of dual-life modules:
6 #
7 # * Are all dual-life programs being generated in utils/?
8
9 require './test.pl';
10
11 plan('no_plan');
12
13 use File::Basename;
14 use File::Find;
15 use File::Spec::Functions;
16
17 # Exceptions are found in dual-life bin dirs but aren't
18 # installed by default
19 my @not_installed = qw(
20   ../cpan/Encode/bin/ucm2table
21   ../cpan/Encode/bin/ucmlint
22   ../cpan/Encode/bin/ucmsort
23   ../cpan/Encode/bin/unidump
24 );
25
26 my %dist_dir_exe;
27
28 foreach (qw (podchecker podselect pod2usage)) {
29     $dist_dir_exe{lc "$_.PL"} = "../cpan/Pod-Parser/$_";
30 };
31 foreach (qw (pod2man pod2text)) {
32     $dist_dir_exe{lc "$_.PL"} = "../cpan/podlators/$_";
33 };
34 $dist_dir_exe{'pod2html.pl'} = '../ext/Pod-Html';
35
36 my @programs;
37
38 find(
39   sub {
40     my $name = $File::Find::name;
41     return if $name =~ /blib/;
42     return unless $name =~ m{/(?:bin|scripts?)/\S+\z};
43
44     push @programs, $name;
45   },
46   qw( ../cpan ../dist ../ext ),
47 );
48
49 my $ext = $^O eq 'VMS' ? '.com' : '';
50
51 for my $f ( @programs ) {
52   $f =~ s/\.\z// if $^O eq 'VMS';
53   next if qr/(?i:$f)/ ~~ @not_installed;
54   $f = basename($f);
55   if(qr/\A(?i:$f)\z/ ~~ %dist_dir_exe) {
56     ok( -f "$dist_dir_exe{lc $f}$ext", "$f$ext");
57   } else {
58     ok( -f catfile('..', 'utils', "$f$ext"), "$f$ext" );
59   }
60 }
61