xref: /openbsd-src/gnu/usr.bin/perl/t/porting/dual-life.t (revision f2da64fbbbf1b03f09f390ab01267c93dfd77c4c)
1#!/perl -w
2use 5.010;
3use strict;
4
5# This tests properties of dual-life modules:
6#
7# * Are all dual-life programs being generated in utils/?
8
9chdir 't';
10require './test.pl';
11
12use Config;
13if ( $Config{usecrosscompile} ) {
14  skip_all( "Not all files are available during cross-compilation" );
15}
16
17plan('no_plan');
18
19use File::Basename;
20use File::Find;
21use File::Spec::Functions;
22
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/Archive-Tar/bin/ptar.*
27   |
28  \.\./cpan/JSON-PP/bin/json_pp
29   |
30  \.\./cpan/IO-Compress/bin/zipdetails
31   |
32  \.\./cpan/Encode/bin/u(?:cm(?:2table|lint|sort)|nidump)
33   |
34  \.\./cpan/Module-(?:Metadata|Build)
35                               /MB-[\w\d]+/Simple/(?:test_install/)?bin/.*
36)\z}ix;
37
38my %dist_dir_exe;
39
40$dist_dir_exe{lc "podselect.PL"} = "../cpan/Pod-Parser/podselect";
41$dist_dir_exe{lc "podchecker.PL"} = "../cpan/Pod-Checker/podchecker";
42$dist_dir_exe{lc "pod2usage.PL"} = "../cpan/Pod-Usage/pod2usage";
43
44foreach (qw (pod2man pod2text)) {
45    $dist_dir_exe{lc "$_.PL"} = "../cpan/podlators/$_";
46};
47$dist_dir_exe{'pod2html.pl'} = '../ext/Pod-Html';
48
49my @programs;
50
51find(
52  { no_chidr => 1, wanted => sub {
53    my $name = $File::Find::name;
54    return if $name =~ /blib/;
55    return unless $name =~ m{/(?:bin|scripts?)/\S+\z} && $name !~ m{/t/};
56
57    push @programs, $name;
58  }},
59  qw( ../cpan ../dist ../ext ),
60);
61
62my $ext = $^O eq 'VMS' ? '.com' : '';
63
64for my $f ( @programs ) {
65  $f =~ s/\.\z// if $^O eq 'VMS';
66  next if $f =~ $not_installed;
67  my $bn = basename($f);
68  if(grep { /\A(?i:$bn)\z/ } keys %dist_dir_exe) {
69    ok( -f "$dist_dir_exe{lc $bn}$ext", "$f$ext");
70  } else {
71    ok( -f catfile('..', 'utils', "$bn$ext"), "$f$ext" );
72  }
73}
74
75