This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Minor refactors to FindExt's test, removing code duplication.
[perl5.git] / t / porting / FindExt.t
1 #!../miniperl -w
2
3 BEGIN {
4     @INC = qw(../win32 ../lib);
5     require './test.pl';
6     skip_all('FindExt not portable')
7         if $^O eq 'VMS';
8 }
9 use strict;
10 use Config;
11
12 # Test that Win32/FindExt.pm is consistent with Configure in determining the
13 # types of extensions.
14
15 if ($^O eq "MSWin32" && !defined $ENV{PERL_STATIC_EXT}) {
16     skip_all "PERL_STATIC_EXT must be set to the list of static extensions";
17 }
18
19 unless (defined $Config{usedl}) {
20     skip_all "FindExt just plain broken for static perl.";
21 }
22
23 plan tests => 12;
24 require FindExt;
25
26 FindExt::apply_config(\%Config);
27 FindExt::scan_ext("../$_")
28     foreach qw(cpan dist ext);
29 FindExt::set_static_extensions(split ' ', $^O eq 'MSWin32'
30                                ? $ENV{PERL_STATIC_EXT} : $Config{static_ext});
31
32 # Config.pm and FindExt.pm make different choices about what should be built
33 my @config_built;
34 my @found_built;
35 {
36     foreach my $type (qw(static dynamic nonxs)) {
37         push @found_built, eval "FindExt::${type}_ext()";
38         push @config_built, split ' ', $Config{"${type}_ext"};
39     }
40 }
41 @config_built = sort @config_built;
42 @found_built = sort @found_built;
43
44 foreach (['dynamic_ext',
45           [FindExt::dynamic_ext()], $Config{dynamic_ext}],
46          ['static_ext',
47           [FindExt::static_ext()], $Config{static_ext}],
48          ['nonxs_ext',
49           [FindExt::nonxs_ext()], $Config{nonxs_ext}],
50          ['known_extensions',
51           [FindExt::known_extensions()], $Config{known_extensions}],
52          ['"config" dynamic + static + nonxs',
53           \@config_built, $Config{extensions}],
54          ['"found" dynamic + static + nonxs', 
55           \@found_built, join " ", FindExt::extensions()],
56         ) {
57     my ($type, $found, $config) = @$_;
58     my @config = sort split ' ', $config;
59     is (scalar @$found, scalar @config,
60         "We find the same number of $type");
61     is ("@$found", "@config", "We find the same list of $type");
62 }
63
64 # Local variables:
65 # cperl-indent-level: 4
66 # indent-tabs-mode: nil
67 # End:
68 #
69 # ex: set ts=8 sts=4 sw=4 et: