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