This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
t/op/groups.t: Add missing "nok 1"
[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
3a73a075
BF
19if ( $Config{usecrosscompile} ) {
20 skip_all( "Not all files are available during cross-compilation" );
21}
22
adede1cd 23require FindExt;
0598b5ab 24
557ab4cb 25FindExt::apply_config(\%Config);
adede1cd
NC
26FindExt::scan_ext("../$_")
27 foreach qw(cpan dist ext);
28FindExt::set_static_extensions(split ' ', $^O eq 'MSWin32'
29 ? $ENV{PERL_STATIC_EXT} : $Config{static_ext});
0598b5ab 30
ef04dc3e
NC
31sub 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
e2988420
NC
40unless (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
0598b5ab 65 foreach my $type (qw(static dynamic nonxs)) {
e2988420
NC
66 my @this_found = eval "FindExt::${type}_ext()";
67 push @found_built, @this_found;
0598b5ab 68 push @config_built, split ' ', $Config{"${type}_ext"};
e2988420 69 compare("${type}_ext", $Config{"${type}_ext"}, @this_found);
0598b5ab 70 }
0598b5ab 71
e2988420
NC
72 compare('"config" dynamic + static + nonxs', $Config{extensions},
73 sort @config_built);
74 compare('"found" dynamic + static + nonxs', [FindExt::extensions()],
75 sort @found_built);
0598b5ab 76}
43ccc0db 77
43ccc0db 78# ex: set ts=8 sts=4 sw=4 et: