This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
In FindExt.t, move the main loop's comparison logic into a subroutine.
[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
d6fb8979
TC
19unless (defined $Config{usedl}) {
20 skip_all "FindExt just plain broken for static perl.";
21}
22
43ccc0db 23plan tests => 12;
adede1cd 24require FindExt;
0598b5ab 25
557ab4cb 26FindExt::apply_config(\%Config);
adede1cd
NC
27FindExt::scan_ext("../$_")
28 foreach qw(cpan dist ext);
29FindExt::set_static_extensions(split ' ', $^O eq 'MSWin32'
30 ? $ENV{PERL_STATIC_EXT} : $Config{static_ext});
0598b5ab 31
ef04dc3e
NC
32sub compare {
33 my ($desc, $want, @have) = @_;
34 $want = [sort split ' ', $want]
35 unless ref $want eq 'ARRAY';
36 local $::Level = $::Level + 1;
37 is(scalar @have, scalar @$want, "We find the same number of $desc");
38 is("@have", "@$want", "We find the same list of $desc");
39}
40
0598b5ab
NC
41# Config.pm and FindExt.pm make different choices about what should be built
42my @config_built;
43my @found_built;
44{
45 foreach my $type (qw(static dynamic nonxs)) {
46 push @found_built, eval "FindExt::${type}_ext()";
47 push @config_built, split ' ', $Config{"${type}_ext"};
48 }
49}
50@config_built = sort @config_built;
51@found_built = sort @found_built;
52
43ccc0db
NC
53foreach (['dynamic_ext',
54 [FindExt::dynamic_ext()], $Config{dynamic_ext}],
55 ['static_ext',
0598b5ab
NC
56 [FindExt::static_ext()], $Config{static_ext}],
57 ['nonxs_ext',
58 [FindExt::nonxs_ext()], $Config{nonxs_ext}],
59 ['known_extensions',
60 [FindExt::known_extensions()], $Config{known_extensions}],
61 ['"config" dynamic + static + nonxs',
62 \@config_built, $Config{extensions}],
63 ['"found" dynamic + static + nonxs',
ef04dc3e 64 \@found_built, [FindExt::extensions()]],
0598b5ab
NC
65 ) {
66 my ($type, $found, $config) = @$_;
ef04dc3e 67 compare($type, $config, @$found);
0598b5ab 68}
43ccc0db
NC
69
70# Local variables:
71# cperl-indent-level: 4
72# indent-tabs-mode: nil
73# End:
74#
75# ex: set ts=8 sts=4 sw=4 et: