| 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 | |
| 15 | if ($^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 | |
| 19 | if ( $Config{usecrosscompile} ) { |
| 20 | skip_all( "Not all files are available during cross-compilation" ); |
| 21 | } |
| 22 | |
| 23 | require FindExt; |
| 24 | |
| 25 | FindExt::apply_config(\%Config); |
| 26 | FindExt::scan_ext("../$_") |
| 27 | foreach qw(cpan dist ext); |
| 28 | FindExt::set_static_extensions(split ' ', $^O eq 'MSWin32' |
| 29 | ? $ENV{PERL_STATIC_EXT} : $Config{static_ext}); |
| 30 | |
| 31 | sub compare { |
| 32 | my ($desc, $want, @have) = @_; |
| 33 | $want = [sort split ' ', $want] |
| 34 | unless ref $want eq 'ARRAY'; |
| 35 | local $::Level = $::Level + 1; |
| 36 | is(scalar @have, scalar @$want, "We find the same number of $desc"); |
| 37 | is("@have", "@$want", "We find the same list of $desc"); |
| 38 | } |
| 39 | |
| 40 | unless (join (' ', sort split ' ', $Config{extensions}) |
| 41 | eq join(' ', FindExt::extensions())) { |
| 42 | # There are various things that break our assumptions. |
| 43 | # If Encode is a static extension, then Configure has special case logic |
| 44 | # to add Encode/* as static extensions |
| 45 | # -Uusedl causes Encode to be a static extension, and drops building |
| 46 | # XS::APItest and XS::Typemap |
| 47 | # Any use of -Dnoextensions to choose not to build a extension |
| 48 | |
| 49 | plan(tests => 2); |
| 50 | note("configured extension list doesn't match, so only minimal testing is possible"); |
| 51 | compare('known_extensions', $Config{known_extensions}, |
| 52 | FindExt::known_extensions()); |
| 53 | } else { |
| 54 | # dynamic linking, and all possible extensions for this system were built, |
| 55 | # so can test everything. |
| 56 | plan(tests => 12); |
| 57 | |
| 58 | compare('known_extensions', $Config{known_extensions}, |
| 59 | FindExt::known_extensions()); |
| 60 | |
| 61 | # Config.pm and FindExt.pm make different choices about what should be built |
| 62 | my @config_built; |
| 63 | my @found_built; |
| 64 | |
| 65 | foreach my $type (qw(static dynamic nonxs)) { |
| 66 | my @this_found = eval "FindExt::${type}_ext()"; |
| 67 | push @found_built, @this_found; |
| 68 | push @config_built, split ' ', $Config{"${type}_ext"}; |
| 69 | compare("${type}_ext", $Config{"${type}_ext"}, @this_found); |
| 70 | } |
| 71 | |
| 72 | compare('"config" dynamic + static + nonxs', $Config{extensions}, |
| 73 | sort @config_built); |
| 74 | compare('"found" dynamic + static + nonxs', [FindExt::extensions()], |
| 75 | sort @found_built); |
| 76 | } |
| 77 | |
| 78 | # ex: set ts=8 sts=4 sw=4 et: |