This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
165ae1462154b4d12917ac60794bf08e2a6f7ef4
[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 # It's not possible to check the list of built dynamic extensions, as that
15 # varies based on which headers are present, and which options ./Configure was
16 # invoked with.
17
18 if ($^O eq "MSWin32" && !defined $ENV{PERL_STATIC_EXT}) {
19     skip_all "PERL_STATIC_EXT must be set to the list of static extensions";
20 }
21
22 unless (defined $Config{usedl}) {
23     skip_all "FindExt just plain broken for static perl.";
24 }
25
26 plan tests => 10;
27 use FindExt;
28
29 FindExt::apply_config(\%Config);
30 FindExt::scan_ext('../cpan');
31 FindExt::scan_ext('../dist');
32 FindExt::scan_ext('../ext');
33 FindExt::set_static_extensions(split ' ', $ENV{PERL_STATIC_EXT}) if $^O eq "MSWin32";
34 FindExt::set_static_extensions(split ' ', $Config{static_ext}) unless $^O eq "MSWin32";
35
36 # Config.pm and FindExt.pm make different choices about what should be built
37 my @config_built;
38 my @found_built;
39 {
40     foreach my $type (qw(static dynamic nonxs)) {
41         push @found_built, eval "FindExt::${type}_ext()";
42         push @config_built, split ' ', $Config{"${type}_ext"};
43     }
44 }
45 @config_built = sort @config_built;
46 @found_built = sort @found_built;
47
48 foreach (['static_ext',
49           [FindExt::static_ext()], $Config{static_ext}],
50          ['nonxs_ext',
51           [FindExt::nonxs_ext()], $Config{nonxs_ext}],
52          ['known_extensions',
53           [FindExt::known_extensions()], $Config{known_extensions}],
54          ['"config" dynamic + static + nonxs',
55           \@config_built, $Config{extensions}],
56          ['"found" dynamic + static + nonxs', 
57           \@found_built, join " ", FindExt::extensions()],
58         ) {
59     my ($type, $found, $config) = @$_;
60     my @config = sort split ' ', $config;
61     is (scalar @$found, scalar @config,
62         "We find the same number of $type");
63     is ("@$found", "@config", "We find the same list of $type");
64 }