This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Integrate mainline
[perl5.git] / t / lib / 1_compile.t
CommitLineData
7200bc44
JH
1#!./perl
2
3BEGIN {
8338e367 4 chdir '..' if -d '../pod' && -d '../t';
7200bc44
JH
5 @INC = 'lib';
6}
7
8use strict;
9use warnings;
cdd2acaa 10use Config;
7200bc44 11
cdd2acaa 12my %Core_Modules;
4d0ed6f7 13my %Test;
cdd2acaa 14
656b9f42
JH
15unless (open(MANIFEST, "MANIFEST")) {
16 die "$0: failed to open 'MANIFEST': $!\n";
17}
18
19sub add_by_name {
20 $Core_Modules{$_[0]}++;
21}
22
23while (<MANIFEST>) {
f9fcf43f 24 s/_pm\.PL/.pm/; # Don't forget the extracted modules
4d0ed6f7
JH
25 if (m!^(lib)/(\S+?)\.pm\s!) {
26 # Collecting modules names from under ext/ would be
27 # rather painful since the mapping from filenames
28 # to module names is not 100%.
29 my ($dir, $module) = ($1, $2);
30 $module =~ s!/!::!g;
31 add_by_name($module);
32 } elsif (m!^(lib|ext)/(\S+?)(?:\.t|/test.pl)\s!) {
33 my ($dir, $test) = ($1, $2);
34 $test =~ s!(\w+)/\1$!$1! if $dir eq 'ext';
35 $test =~ s!/t/[^/]+$!!;
36 $test =~ s!/!::!g;
37 $Test{$test}++;
38 }
656b9f42
JH
39}
40
41close(MANIFEST);
cdd2acaa
JH
42
43# Delete stuff that can't be tested here.
44
656b9f42
JH
45sub delete_by_name {
46 delete $Core_Modules{$_[0]};
47}
48
49sub has_extension {
50 $Config{extensions} =~ /\b$_[0]\b/i;
51}
52
53sub delete_unless_has_extension {
54 delete $Core_Modules{$_[0]} unless has_extension($_[0]);
cdd2acaa
JH
55}
56
57foreach my $known_extension (split(' ', $Config{known_extensions})) {
656b9f42 58 delete_unless_has_extension($known_extension);
cdd2acaa
JH
59}
60
61sub delete_by_prefix {
656b9f42
JH
62 for my $match (grep { /^$_[0]/ } keys %Core_Modules) {
63 delete_by_name($match);
64 }
cdd2acaa
JH
65}
66
656b9f42 67delete_by_name('CGI::Fast'); # won't load without FCGI
cdd2acaa 68
cdd2acaa
JH
69delete_by_prefix('ExtUtils::MM_'); # ExtUtils::MakeMaker's domain
70
71delete_by_prefix('File::Spec::'); # File::Spec's domain
656b9f42 72add_by_name('File::Spec::Functions'); # put this back
cdd2acaa 73
04070b92
JH
74delete_by_prefix('Attribute::Handlers');# we test this, and we have demos
75
ab05f9a3
JH
76delete_by_prefix('Net::FTP::'); # Net::FTP is tested.
77
78# In this case we could rely on the fake Socket layer the libnet tests
79# use but frankly I think in this case we might as well let it be.
5655ed86
JH
80delete_by_prefix('Net::') unless has_extension('Socket');
81
656b9f42
JH
82sub using_feature {
83 my $use = "use$_[0]";
84 exists $Config{$use} &&
85 defined $Config{$use} &&
86 $Config{$use} eq 'define';
87}
88
89unless (using_feature('threads') && has_extension('Thread')) {
90 delete_by_name('Thread');
290a1446 91 delete_by_prefix('Thread::');
eba8ff18 92}
cdd2acaa 93
a0cb3900
JH
94unless (has_extension('NDBM_File')) {
95 delete_by_name('Memoize::NDBM_File');
96}
97
3de3f243 98if (ord('A') == 193) {
c8b7969b 99 delete_by_prefix('Net::') unless eval { require Convert::EBCDIC };
3de3f243
JH
100}
101
04070b92
JH
102# Delete all modules which have their own tests.
103# This makes this test a lot faster.
4d0ed6f7
JH
104foreach my $mod (sort keys %Test) {
105 delete_by_name($mod);
106}
6b40b044
MS
107foreach my $mod (<DATA>) {
108 chomp $mod;
0d0c1411 109 print "### $mod has a test but is in DATA of $0\n" if exists $Test{$mod};
6b40b044
MS
110 delete_by_name($mod);
111}
112
cdd2acaa
JH
113# Okay, this is the list.
114
115my @Core_Modules = sort keys %Core_Modules;
7200bc44
JH
116
117print "1..".@Core_Modules."\n";
118
119my $test_num = 1;
cdd2acaa 120
7200bc44 121foreach my $module (@Core_Modules) {
17bcccd5 122 print "$module compile failed\nnot " unless compile_module($module);
7200bc44
JH
123 print "ok $test_num\n";
124 $test_num++;
125}
126
656b9f42
JH
127# We do this as a separate process else we'll blow the hell
128# out of our namespace.
7200bc44 129sub compile_module {
656b9f42 130 my ($module) = $_[0];
7200bc44 131
1189d1e4
JH
132 my $out = scalar `$^X "-Ilib" t/lib/compmod.pl $module`;
133 print "# $out";
134 return $out =~ /^ok/;
7200bc44 135}
6b40b044 136
20e80008
JH
137# Add here modules that have their own test scripts and therefore
138# need not be test-compiled by 1_compile.t.
6b40b044 139__DATA__
6b40b044 140B::ShowLex
79319589
JH
141CGI::Apache
142CGI::Carp
143CGI::Cookie
144CGI::Form
6b40b044 145CGI::Pretty
0d0c1411 146CGI::Push
79319589 147CGI::Switch
6b40b044 148CGI::Util
20e80008 149Carp::Heavy
6ae1853a 150CPAN::Nox
6b40b044 151Exporter::Heavy
20e80008
JH
152ExtUtils::Constant
153ExtUtils::MakeMaker
6b40b044 154Filter::Util::Call
6b40b044 155GDBM_File
0e6c72d5 156I18N::LangTags::List
6b40b044
MS
157IO::Dir
158IO::File
159IO::Handle
160IO::Pipe
161IO::Poll
162IO::Seekable
163IO::Select
164IO::Socket
165IO::Socket::INET
166IO::Socket::UNIX
6b40b044
MS
167Locale::Constants
168Locale::Country
169Locale::Currency
170Locale::Language
6b40b044
MS
171MIME::QuotedPrint
172Math::BigFloat
0e6c72d5 173Math::BigInt::Calc
0e6c72d5
JH
174Memoize::AnyDBM_File
175Memoize::Expire
176Memoize::ExpireFile
177Memoize::ExpireTest
178Memoize::NDBM_File
179Memoize::SDBM_File
180Memoize::Storable
6b40b044 181NDBM_File
ab05f9a3
JH
182Net::Config
183Net::FTP
184Net::Netrc
185Net::NNTP
186Net::SMTP
187Net::Time
6b40b044 188ODBM_File
6b40b044
MS
189Pod::Checker
190Pod::Find
f56fdd80 191Pod::Html
fed96050 192Pod::LaTeX
f56fdd80
JH
193Pod::Man
194Pod::ParseLink
fed96050 195Pod::ParseUtils
6b40b044 196Pod::Text
f56fdd80
JH
197Pod::Text::Overstrike
198Pod::Text::Termcap
6b40b044
MS
199Pod::Usage
200SDBM_File
201Safe
202Scalar::Util
6b40b044 203Sys::Syslog
0e6c72d5 204Test::More
6b40b044 205Test::ParseWords
6b40b044
MS
206Text::Tabs
207Text::Wrap
208Thread
209Tie::Array
210Tie::Handle
211Tie::Hash
2857d2f7 212Time::tm
6b40b044 213UNIVERSAL
601f2d16 214attributes
6b40b044 215base
6b40b044 216ops
d99274ce 217warnings::register