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