This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Rebuild Configure from current metaconfig
[perl5.git] / t / porting / FindExt.t
index 7b95072..32c331e 100644 (file)
@@ -16,11 +16,10 @@ 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.";
+if ( $Config{usecrosscompile} ) {
+  skip_all( "Not all files are available during cross-compilation" );
 }
 
-plan tests => 12;
 require FindExt;
 
 FindExt::apply_config(\%Config);
@@ -29,41 +28,51 @@ FindExt::scan_ext("../$_")
 FindExt::set_static_extensions(split ' ', $^O eq 'MSWin32'
                                ? $ENV{PERL_STATIC_EXT} : $Config{static_ext});
 
-# Config.pm and FindExt.pm make different choices about what should be built
-my @config_built;
-my @found_built;
-{
+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");
+}
+
+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
+
+    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;
+
     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 (['dynamic_ext',
-          [FindExt::dynamic_ext()], $Config{dynamic_ext}],
-         ['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: