xref: /openbsd-src/gnu/usr.bin/perl/t/porting/FindExt.t (revision 91f110e064cd7c194e59e019b83bb7496c1c84d4)
1#!../miniperl -w
2
3BEGIN {
4    @INC = qw(../win32 ../lib);
5    require './test.pl';
6    skip_all('FindExt not portable')
7	if $^O eq 'VMS';
8}
9use strict;
10use 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
18if ($^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
22unless (defined $Config{usedl}) {
23    skip_all "FindExt just plain broken for static perl.";
24}
25
26plan tests => 10;
27use FindExt;
28
29FindExt::apply_config(\%Config);
30FindExt::scan_ext('../cpan');
31FindExt::scan_ext('../dist');
32FindExt::scan_ext('../ext');
33FindExt::set_static_extensions(split ' ', $ENV{PERL_STATIC_EXT}) if $^O eq "MSWin32";
34FindExt::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
37my @config_built;
38my @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
48foreach (['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}
65