summaryrefslogtreecommitdiff
path: root/t/porting/dual-life.t
blob: 5d4c45eb12b6f17482fc2d35771742466c01c2fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/perl -w
use 5.010;
use strict;

# This tests properties of dual-life modules:
#
# * Are all dual-life programs being generated in utils/?

require './test.pl';

plan('no_plan');

use File::Basename;
use File::Find;
use File::Spec::Functions;

# Exceptions are found in dual-life bin dirs but aren't
# installed by default
my @not_installed = qw(
  ../cpan/Encode/bin/ucm2table
  ../cpan/Encode/bin/ucmlint
  ../cpan/Encode/bin/ucmsort
  ../cpan/Encode/bin/unidump
);

my %dist_dir_exe;

foreach (qw (podchecker podselect pod2usage)) {
    $dist_dir_exe{lc "$_.PL"} = "../cpan/Pod-Parser/$_";
};
foreach (qw (pod2man pod2text)) {
    $dist_dir_exe{lc "$_.PL"} = "../cpan/podlators/$_";
};
$dist_dir_exe{'pod2html.pl'} = '../ext/Pod-Html';

my @programs;

find(
  sub {
    my $name = $File::Find::name;
    return if $name =~ /blib/;
    return unless $name =~ m{/(?:bin|scripts?)/\S+\z};

    push @programs, $name;
  },
  qw( ../cpan ../dist ../ext ),
);

my $ext = $^O eq 'VMS' ? '.com' : '';

for my $f ( @programs ) {
  $f =~ s/\.\z// if $^O eq 'VMS';
  next if qr/(?i:$f)/ ~~ @not_installed;
  $f = basename($f);
  if(qr/\A(?i:$f)\z/ ~~ %dist_dir_exe) {
    ok( -f "$dist_dir_exe{lc $f}$ext", "$f$ext");
  } else {
    ok( -f catfile('..', 'utils', "$f$ext"), "$f$ext" );
  }
}