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