# Test that Win32/FindExt.pm is consistent with Configure in determining the
# types of extensions.
-# It's not possible to check the list of built dynamic extensions, as that
-# varies based on which headers are present, and which options ./Configure was
-# invoked with.
if ($^O eq "MSWin32" && !defined $ENV{PERL_STATIC_EXT}) {
skip_all "PERL_STATIC_EXT must be set to the list of static extensions";
}
-unless (defined $Config{usedl}) {
- skip_all "FindExt just plain broken for static perl.";
+require FindExt;
+
+FindExt::apply_config(\%Config);
+FindExt::scan_ext("../$_")
+ foreach qw(cpan dist ext);
+FindExt::set_static_extensions(split ' ', $^O eq 'MSWin32'
+ ? $ENV{PERL_STATIC_EXT} : $Config{static_ext});
+
+sub compare {
+ my ($desc, $want, @have) = @_;
+ $want = [sort split ' ', $want]
+ unless ref $want eq 'ARRAY';
+ local $::Level = $::Level + 1;
+ is(scalar @have, scalar @$want, "We find the same number of $desc");
+ is("@have", "@$want", "We find the same list of $desc");
}
-plan tests => 10;
-use FindExt;
+unless (join (' ', sort split ' ', $Config{extensions})
+ eq join(' ', FindExt::extensions())) {
+ # There are various things that break our assumptions.
+ # If Encode is a static extension, then Configure has special case logic
+ # to add Encode/* as static extensions
+ # -Uusedl causes Encode to be a static extension, and drops building
+ # XS::APItest and XS::Typemap
+ # Any use of -Dnoextensions to choose not to build a extension
-FindExt::apply_config(\%Config);
-FindExt::scan_ext('../cpan');
-FindExt::scan_ext('../dist');
-FindExt::scan_ext('../ext');
-FindExt::set_static_extensions(split ' ', $ENV{PERL_STATIC_EXT}) if $^O eq "MSWin32";
-FindExt::set_static_extensions(split ' ', $Config{static_ext}) unless $^O eq "MSWin32";
+ plan(tests => 2);
+ note("configured extension list doesn't match, so only minimal testing is possible");
+ compare('known_extensions', $Config{known_extensions},
+ FindExt::known_extensions());
+} else {
+ # dynamic linking, and all possible extensions for this system were built,
+ # so can test everything.
+ plan(tests => 12);
+
+ compare('known_extensions', $Config{known_extensions},
+ FindExt::known_extensions());
+
+ # Config.pm and FindExt.pm make different choices about what should be built
+ my @config_built;
+ my @found_built;
-# Config.pm and FindExt.pm make different choices about what should be built
-my @config_built;
-my @found_built;
-{
foreach my $type (qw(static dynamic nonxs)) {
- push @found_built, eval "FindExt::${type}_ext()";
+ my @this_found = eval "FindExt::${type}_ext()";
+ push @found_built, @this_found;
push @config_built, split ' ', $Config{"${type}_ext"};
+ compare("${type}_ext", $Config{"${type}_ext"}, @this_found);
}
-}
-@config_built = sort @config_built;
-@found_built = sort @found_built;
-foreach (['static_ext',
- [FindExt::static_ext()], $Config{static_ext}],
- ['nonxs_ext',
- [FindExt::nonxs_ext()], $Config{nonxs_ext}],
- ['known_extensions',
- [FindExt::known_extensions()], $Config{known_extensions}],
- ['"config" dynamic + static + nonxs',
- \@config_built, $Config{extensions}],
- ['"found" dynamic + static + nonxs',
- \@found_built, join " ", FindExt::extensions()],
- ) {
- my ($type, $found, $config) = @$_;
- my @config = sort split ' ', $config;
- is (scalar @$found, scalar @config,
- "We find the same number of $type");
- is ("@$found", "@config", "We find the same list of $type");
+ compare('"config" dynamic + static + nonxs', $Config{extensions},
+ sort @config_built);
+ compare('"found" dynamic + static + nonxs', [FindExt::extensions()],
+ sort @found_built);
}
+
+# Local variables:
+# cperl-indent-level: 4
+# indent-tabs-mode: nil
+# End:
+#
+# ex: set ts=8 sts=4 sw=4 et:
# duplicates logic from Configure (mostly)
push @no, "DB_File" unless $config->{i_db};
push @no, "GDBM_File" unless $config->{i_gdbm};
- push @no, "I18N-Langinfo" unless $config->{i_langinfo} && $config->{i_nl_langinfo};
+ push @no, "I18N-Langinfo" unless $config->{i_langinfo} && $config->{d_nl_langinfo};
push @no, "IPC-SysV" unless $config->{d_msg} || $config->{d_sem} || $config->{d_shm};
push @no, "NDBM_File" unless $config->{d_ndbm};
push @no, "ODBM_File"
}
}
-sub scan_ext
-{
- my $dir = shift;
- find_ext("$dir/");
- extensions();
-}
-
sub _ext_eq {
my $key = shift;
sub {
*static_ext = _ext_eq('static');
*nonxs_ext = _ext_eq('nonxs');
-sub _ext_ne {
- my $key = shift;
- sub {
- sort grep $ext{$_} ne $key, keys %ext;
- }
+sub extensions {
+ sort grep $ext{$_} ne 'known', keys %ext;
}
-*extensions = _ext_ne('known');
-
sub known_extensions {
sort keys %ext;
}
}
# Function to find available extensions, ignoring DynaLoader
-sub find_ext
+sub scan_ext
{
my $ext_dir = shift;
opendir my $dh, "$ext_dir";
while (defined (my $item = readdir $dh)) {
next if $item =~ /^\.\.?$/;
next if $item eq "DynaLoader";
- next unless -d "$ext_dir$item";
+ next unless -d "$ext_dir/$item";
my $this_ext = $item;
my $leaf = $item;
# Temporary hack to cope with smokers that are not clearing directories:
next if $ext{$this_ext};
- if (has_xs_or_c("$ext_dir$item")) {
+ if (has_xs_or_c("$ext_dir/$item")) {
$ext{$this_ext} = $static{$this_ext} ? 'static' : 'dynamic';
} else {
$ext{$this_ext} = 'nonxs';
}
- $ext{$this_ext} = 'known' if $ext{$this_ext} && $item =~ $no;
+ $ext{$this_ext} = 'known' if $item =~ $no;
}
}