This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: [ID 20010423.006] Test failed in perl@9794
[perl5.git] / t / lib / 1_compile.t
CommitLineData
7200bc44
JH
1#!./perl
2
3BEGIN {
4 chdir '..' if -d '../pod' && -d '../t';
5 @INC = 'lib';
6}
7
8use strict;
9use warnings;
cdd2acaa 10use Config;
7200bc44 11
cdd2acaa
JH
12my %Core_Modules;
13
656b9f42
JH
14unless (open(MANIFEST, "MANIFEST")) {
15 die "$0: failed to open 'MANIFEST': $!\n";
16}
17
18sub add_by_name {
19 $Core_Modules{$_[0]}++;
20}
21
22while (<MANIFEST>) {
23 next unless m!^lib/(\S+?)\.pm!;
24 my $module = $1;
25 $module =~ s!/!::!g;
26 add_by_name($module);
27}
28
29close(MANIFEST);
cdd2acaa
JH
30
31# Delete stuff that can't be tested here.
32
656b9f42
JH
33sub delete_by_name {
34 delete $Core_Modules{$_[0]};
35}
36
37sub has_extension {
38 $Config{extensions} =~ /\b$_[0]\b/i;
39}
40
41sub delete_unless_has_extension {
42 delete $Core_Modules{$_[0]} unless has_extension($_[0]);
cdd2acaa
JH
43}
44
45foreach my $known_extension (split(' ', $Config{known_extensions})) {
656b9f42 46 delete_unless_has_extension($known_extension);
cdd2acaa
JH
47}
48
49sub delete_by_prefix {
656b9f42
JH
50 for my $match (grep { /^$_[0]/ } keys %Core_Modules) {
51 delete_by_name($match);
52 }
cdd2acaa
JH
53}
54
656b9f42 55delete_by_name('CGI::Fast'); # won't load without FCGI
cdd2acaa 56
656b9f42 57delete_by_name('Devel::DProf'); # needs to be run as -d:DProf
cdd2acaa
JH
58
59delete_by_prefix('ExtUtils::MM_'); # ExtUtils::MakeMaker's domain
60
61delete_by_prefix('File::Spec::'); # File::Spec's domain
656b9f42 62add_by_name('File::Spec::Functions'); # put this back
cdd2acaa 63
656b9f42
JH
64sub using_feature {
65 my $use = "use$_[0]";
66 exists $Config{$use} &&
67 defined $Config{$use} &&
68 $Config{$use} eq 'define';
69}
70
71unless (using_feature('threads') && has_extension('Thread')) {
72 delete_by_name('Thread');
290a1446 73 delete_by_prefix('Thread::');
eba8ff18 74}
cdd2acaa
JH
75
76delete_by_prefix('unicode::');
656b9f42 77add_by_name('unicode::distinct'); # put this back
cdd2acaa
JH
78
79# Okay, this is the list.
80
81my @Core_Modules = sort keys %Core_Modules;
7200bc44
JH
82
83print "1..".@Core_Modules."\n";
84
85my $test_num = 1;
cdd2acaa 86
7200bc44 87foreach my $module (@Core_Modules) {
cdd2acaa 88 print "# $module compile failed\nnot " unless compile_module($module);
7200bc44
JH
89 print "ok $test_num\n";
90 $test_num++;
91}
92
656b9f42
JH
93# We do this as a separate process else we'll blow the hell
94# out of our namespace.
7200bc44 95sub compile_module {
656b9f42 96 my ($module) = $_[0];
7200bc44 97
bdc55ba4 98 return scalar `$^X "-Ilib" t/lib/compmod.pl $module` =~ /^ok/;
7200bc44 99}