Re: Perl bug with "delete" on arrays
[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
1189d1e4 111 my $out = scalar `$^X "-Ilib" t/lib/compmod.pl $module`;
112 print "# $out";
113 return $out =~ /^ok/;
7200bc44 114}
6b40b044 115
20e80008 116# Add here modules that have their own test scripts and therefore
117# need not be test-compiled by 1_compile.t.
6b40b044 118__DATA__
119AnyDBM_File
dc6b6eef 120Attribute::Handlers
6b40b044 121AutoLoader
122B
123B::Debug
124B::Deparse
125B::ShowLex
126B::Stash
127Benchmark
128CGI
129CGI::Pretty
130CGI::Util
131Carp
20e80008 132Carp::Heavy
6b40b044 133Class::ISA
134Class::Struct
46700524 135CPAN
6b40b044 136Cwd
137DB_File
138Data::Dumper
139Devel::DProf
140Devel::Peek
7f4f6daf 141Devel::SelfStubber
6b40b044 142Digest
143Digest::MD5
144DirHandle
145Dumpvalue
146Encode
147English
148Env
149Errno
150Exporter
151Exporter::Heavy
20e80008 152ExtUtils::Constant
153ExtUtils::MakeMaker
6b40b044 154Fatal
155Fcntl
156File::Basename
157File::CheckTree
02c8fbd5 158File::Compare
6b40b044 159File::Copy
160File::DosGlob
161File::Find
162File::Glob
163File::Path
164File::Spec
165File::Spec::Functions
166File::Temp
f7a45afb 167File::stat
6b40b044 168FileCache
169FileHandle
7eade29f 170Filter::Simple
6b40b044 171Filter::Util::Call
172FindBin
173GDBM_File
174Getopt::Long
175Getopt::Std
d763e2de 176I18N::Langinfo
20e80008 177I18N::LangTags
0e6c72d5 178I18N::LangTags::List
20e80008 179I18N::Collate
6b40b044 180IO::Dir
181IO::File
182IO::Handle
183IO::Pipe
184IO::Poll
185IO::Seekable
186IO::Select
187IO::Socket
188IO::Socket::INET
189IO::Socket::UNIX
190IPC::Open2
191IPC::Open3
192IPC::SysV
193List::Util
194Locale::Constants
195Locale::Country
196Locale::Currency
197Locale::Language
20e80008 198Locale::Maketext
6b40b044 199MIME::Base64
200MIME::QuotedPrint
201Math::BigFloat
202Math::BigInt
0e6c72d5 203Math::BigInt::Calc
6b40b044 204Math::Complex
205Math::Trig
0e6c72d5 206Memoize
207Memoize::AnyDBM_File
208Memoize::Expire
209Memoize::ExpireFile
210Memoize::ExpireTest
211Memoize::NDBM_File
212Memoize::SDBM_File
213Memoize::Storable
6b40b044 214NDBM_File
7eade29f 215NEXT
6b40b044 216Net::hostent
cdbd8744 217Net::netent
6fa754df 218Net::protoent
219Net::servent
6b40b044 220ODBM_File
221Opcode
20e80008 222PerlIO
6b40b044 223POSIX
224Pod::Checker
225Pod::Find
226Pod::Text
227Pod::Usage
228SDBM_File
229Safe
230Scalar::Util
231Search::Dict
232SelectSaver
233SelfLoader
234Socket
235Storable
236Switch
237Symbol
238Sys::Hostname
239Sys::Syslog
240Term::ANSIColor
241Test
242Test::Harness
0e6c72d5 243Test::More
244Test::Simple
6b40b044 245Test::ParseWords
246Text::Abbrev
247Text::Balanced
248Text::ParseWords
249Text::Soundex
250Text::Tabs
251Text::Wrap
252Thread
253Tie::Array
254Tie::Handle
255Tie::Hash
256Tie::RefHash
257Tie::Scalar
258Tie::SubstrHash
259Time::HiRes
260Time::Local
261Time::Piece
2857d2f7 262Time::gmtime
263Time::localtime
264Time::tm
0e6c72d5 265UnicodeCD
6b40b044 266UNIVERSAL
6888c95f 267User::grent
c7506216 268User::pwent
6b40b044 269XS::Typemap
601f2d16 270attributes
6b40b044 271attrs
20e80008 272autouse
6b40b044 273base
274bytes
275charnames
276constant
277diagnostics
278fields
279integer
280locale
281ops
282overload
283strict
284subs
285utf8
6b40b044 286warnings
287warnings::register