Add test for Net::protoent.
[p5sagit/p5-mst-13.2.git] / t / lib / 1_compile.t
CommitLineData
7200bc44 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 12my %Core_Modules;
13
656b9f42 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 30
31# Delete stuff that can't be tested here.
32
656b9f42 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 43}
44
45foreach my $known_extension (split(' ', $Config{known_extensions})) {
656b9f42 46 delete_unless_has_extension($known_extension);
cdd2acaa 47}
48
49sub delete_by_prefix {
656b9f42 50 for my $match (grep { /^$_[0]/ } keys %Core_Modules) {
51 delete_by_name($match);
52 }
cdd2acaa 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 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 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 75
76delete_by_prefix('unicode::');
656b9f42 77add_by_name('unicode::distinct'); # put this back
cdd2acaa 78
6b40b044 79
80# Delete all modules which have their own tests. This makes
46700524 81# this test a lot faster.
6b40b044 82foreach my $mod (<DATA>) {
83 chomp $mod;
84 delete_by_name($mod);
85}
86
cdd2acaa 87# Okay, this is the list.
88
89my @Core_Modules = sort keys %Core_Modules;
7200bc44 90
91print "1..".@Core_Modules."\n";
92
93my $test_num = 1;
cdd2acaa 94
7200bc44 95foreach my $module (@Core_Modules) {
cdd2acaa 96 print "# $module compile failed\nnot " unless compile_module($module);
7200bc44 97 print "ok $test_num\n";
98 $test_num++;
99}
100
656b9f42 101# We do this as a separate process else we'll blow the hell
102# out of our namespace.
7200bc44 103sub compile_module {
656b9f42 104 my ($module) = $_[0];
7200bc44 105
bdc55ba4 106 return scalar `$^X "-Ilib" t/lib/compmod.pl $module` =~ /^ok/;
7200bc44 107}
6b40b044 108
20e80008 109# Add here modules that have their own test scripts and therefore
110# need not be test-compiled by 1_compile.t.
6b40b044 111__DATA__
112AnyDBM_File
113AutoLoader
114B
115B::Debug
116B::Deparse
117B::ShowLex
118B::Stash
119Benchmark
120CGI
121CGI::Pretty
122CGI::Util
123Carp
20e80008 124Carp::Heavy
6b40b044 125Class::ISA
126Class::Struct
46700524 127CPAN
6b40b044 128Cwd
129DB_File
130Data::Dumper
131Devel::DProf
132Devel::Peek
7f4f6daf 133Devel::SelfStubber
6b40b044 134Digest
135Digest::MD5
136DirHandle
137Dumpvalue
138Encode
139English
140Env
141Errno
142Exporter
143Exporter::Heavy
20e80008 144ExtUtils::Constant
145ExtUtils::MakeMaker
6b40b044 146Fatal
147Fcntl
148File::Basename
149File::CheckTree
150File::Copy
151File::DosGlob
152File::Find
153File::Glob
154File::Path
155File::Spec
156File::Spec::Functions
157File::Temp
158FileCache
159FileHandle
7eade29f 160Filter::Simple
6b40b044 161Filter::Util::Call
162FindBin
163GDBM_File
164Getopt::Long
165Getopt::Std
20e80008 166I18N::LangTags
167I18N::Collate
6b40b044 168IO::Dir
169IO::File
170IO::Handle
171IO::Pipe
172IO::Poll
173IO::Seekable
174IO::Select
175IO::Socket
176IO::Socket::INET
177IO::Socket::UNIX
178IPC::Open2
179IPC::Open3
180IPC::SysV
181List::Util
182Locale::Constants
183Locale::Country
184Locale::Currency
185Locale::Language
20e80008 186Locale::Maketext
6b40b044 187MIME::Base64
188MIME::QuotedPrint
189Math::BigFloat
190Math::BigInt
191Math::Complex
192Math::Trig
193NDBM_File
7eade29f 194NEXT
6b40b044 195Net::hostent
cdbd8744 196Net::netent
6b40b044 197ODBM_File
198Opcode
20e80008 199PerlIO
6b40b044 200POSIX
201Pod::Checker
202Pod::Find
203Pod::Text
204Pod::Usage
205SDBM_File
206Safe
207Scalar::Util
208Search::Dict
209SelectSaver
210SelfLoader
211Socket
212Storable
213Switch
214Symbol
215Sys::Hostname
216Sys::Syslog
217Term::ANSIColor
218Test
219Test::Harness
220Test::ParseWords
221Text::Abbrev
222Text::Balanced
223Text::ParseWords
224Text::Soundex
225Text::Tabs
226Text::Wrap
227Thread
228Tie::Array
229Tie::Handle
230Tie::Hash
231Tie::RefHash
232Tie::Scalar
233Tie::SubstrHash
234Time::HiRes
235Time::Local
236Time::Piece
237UNIVERSAL
6888c95f 238User::grent
c7506216 239User::pwent
6b40b044 240XS::Typemap
241attrs
20e80008 242autouse
6b40b044 243base
244bytes
245charnames
246constant
247diagnostics
248fields
249integer
250locale
251ops
252overload
253strict
254subs
255utf8
6b40b044 256warnings
257warnings::register