This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Don’t write beyond the stack with scalar \()
[perl5.git] / t / porting / dual-life.t
CommitLineData
ef9dbfd8 1#!/perl -w
52143fbb 2use 5.010;
ef9dbfd8
DG
3use strict;
4
5# This tests properties of dual-life modules:
6#
7# * Are all dual-life programs being generated in utils/?
8
abaa36d4 9chdir 't';
5e515724
DG
10require './test.pl';
11
3a73a075
BF
12use Config;
13if ( $Config{usecrosscompile} ) {
14 skip_all( "Not all files are available during cross-compilation" );
15}
16
5e515724
DG
17plan('no_plan');
18
ef9dbfd8
DG
19use File::Basename;
20use File::Find;
21use File::Spec::Functions;
ef9dbfd8 22
7af59249
FC
23# Exceptions that are found in dual-life bin dirs but aren't
24# installed by default; some occur only during testing:
25my $not_installed = qr{^(?:
26 \.\./cpan/Encode/bin/u(?:cm(?:2table|lint|sort)|nidump)
27 |
8c806578
FC
28 \.\./cpan/Module-(?:Metadata|Build)
29 /MB-[\w\d]+/Simple/(?:test_install/)?bin/.*
7af59249 30)\z}ix;
52143fbb 31
cde5101a
NC
32my %dist_dir_exe;
33
0c501878
CBW
34$dist_dir_exe{lc "podselect.PL"} = "../cpan/Pod-Parser/podselect";
35$dist_dir_exe{lc "podchecker.PL"} = "../cpan/Pod-Checker/podchecker";
36$dist_dir_exe{lc "pod2usage.PL"} = "../cpan/Pod-Usage/pod2usage";
37
bab7aada 38foreach (qw (pod2man pod2text)) {
2419ffa9 39 $dist_dir_exe{lc "$_.PL"} = "../cpan/podlators/$_";
bab7aada 40};
33c64ab2 41$dist_dir_exe{'pod2html.pl'} = '../ext/Pod-Html';
cde5101a 42
ef9dbfd8
DG
43my @programs;
44
45find(
233a4069 46 { no_chdir => 1, wanted => sub {
ef9dbfd8
DG
47 my $name = $File::Find::name;
48 return if $name =~ /blib/;
b4836cca 49 return unless $name =~ m{/(?:bin|scripts?)/\S+\z} && $name !~ m{/t/};
ef9dbfd8
DG
50
51 push @programs, $name;
6ec233a9 52 }},
ef9dbfd8
DG
53 qw( ../cpan ../dist ../ext ),
54);
55
cde5101a
NC
56my $ext = $^O eq 'VMS' ? '.com' : '';
57
ef9dbfd8 58for my $f ( @programs ) {
01604df2 59 $f =~ s/\.\z// if $^O eq 'VMS';
7af59249 60 next if $f =~ $not_installed;
abace7e5 61 my $bn = basename($f);
629deb58 62 if(grep { /\A(?i:$bn)\z/ } keys %dist_dir_exe) {
abace7e5 63 ok( -f "$dist_dir_exe{lc $bn}$ext", "$f$ext");
cde5101a 64 } else {
abace7e5 65 ok( -f catfile('..', 'utils', "$bn$ext"), "$f$ext" );
cde5101a 66 }
ef9dbfd8
DG
67}
68