[RESEND] [PATCH] Mac OS lib patches for bleadperl
[p5sagit/p5-mst-13.2.git] / t / lib / 1_compile.t
1 #!./perl
2
3 BEGIN {
4     chdir '..' if -d '../pod' && -d '../t';
5     @INC = 'lib';
6 }
7
8 use strict;
9 use warnings;
10 use Config;
11
12 my %Core_Modules;
13
14 unless (open(MANIFEST, "MANIFEST")) {
15     die "$0: failed to open 'MANIFEST': $!\n";
16 }
17
18 sub add_by_name {
19     $Core_Modules{$_[0]}++;
20 }
21
22 while (<MANIFEST>) {
23     next unless m!^lib/(\S+?)\.pm!;
24     my $module = $1;
25     $module =~ s!/!::!g;
26     add_by_name($module);
27 }
28
29 close(MANIFEST);
30
31 # Delete stuff that can't be tested here.
32
33 sub delete_by_name {
34     delete $Core_Modules{$_[0]};
35 }
36
37 sub has_extension {
38     $Config{extensions} =~ /\b$_[0]\b/i;
39 }
40
41 sub delete_unless_has_extension {
42     delete $Core_Modules{$_[0]} unless has_extension($_[0]);
43 }
44
45 foreach my $known_extension (split(' ', $Config{known_extensions})) {
46     delete_unless_has_extension($known_extension);
47 }
48
49 sub delete_by_prefix {
50     for my $match (grep { /^$_[0]/ } keys %Core_Modules) {
51         delete_by_name($match);
52     }
53 }
54
55 delete_by_name('CGI::Fast');            # won't load without FCGI
56
57 delete_by_name('Devel::DProf');         # needs to be run as -d:DProf
58
59 delete_by_prefix('ExtUtils::MM_');      # ExtUtils::MakeMaker's domain
60
61 delete_by_prefix('File::Spec::');       # File::Spec's domain
62 add_by_name('File::Spec::Functions');   # put this back
63
64 delete_by_prefix('Attribute::Handlers');# we test this, and we have demos
65
66 sub using_feature {
67     my $use = "use$_[0]";
68     exists $Config{$use} &&
69         defined $Config{$use} &&
70         $Config{$use} eq 'define';
71 }
72
73 unless (using_feature('threads') && has_extension('Thread')) {
74     delete_by_name('Thread');
75     delete_by_prefix('Thread::');
76 }
77
78 delete_by_prefix('unicode::');
79 add_by_name('unicode::distinct');       # put this back
80
81 # Delete all modules which have their own tests.
82 # This makes this test a lot faster.
83 foreach my $mod (<DATA>) {
84     chomp $mod;
85     delete_by_name($mod);
86 }
87
88 # Okay, this is the list.
89
90 my @Core_Modules = sort keys %Core_Modules;
91
92 print "1..".@Core_Modules."\n";
93
94 my $test_num = 1;
95
96 foreach my $module (@Core_Modules) {
97     print "# $module compile failed\nnot " unless compile_module($module);
98     print "ok $test_num\n";
99     $test_num++;
100 }
101
102 # We do this as a separate process else we'll blow the hell
103 # out of our namespace.
104 sub compile_module {
105     my ($module) = $_[0];
106     
107     return scalar `$^X "-Ilib" t/lib/compmod.pl $module` =~ /^ok/;
108 }
109
110 # Add here modules that have their own test scripts and therefore
111 # need not be test-compiled by 1_compile.t.
112 __DATA__
113 AnyDBM_File
114 Attribute::Handlers
115 AutoLoader
116 B
117 B::Debug
118 B::Deparse
119 B::ShowLex
120 B::Stash
121 Benchmark
122 CGI
123 CGI::Pretty
124 CGI::Util
125 Carp
126 Carp::Heavy
127 Class::ISA
128 Class::Struct
129 CPAN
130 Cwd
131 DB_File
132 Data::Dumper
133 Devel::DProf
134 Devel::Peek
135 Devel::SelfStubber
136 Digest
137 Digest::MD5
138 DirHandle
139 Dumpvalue
140 Encode
141 English
142 Env
143 Errno
144 Exporter
145 Exporter::Heavy
146 ExtUtils::Constant
147 ExtUtils::MakeMaker
148 Fatal
149 Fcntl
150 File::Basename
151 File::CheckTree
152 File::Compare
153 File::Copy
154 File::DosGlob
155 File::Find
156 File::Glob
157 File::Path
158 File::Spec
159 File::Spec::Functions
160 File::Temp
161 File::stat
162 FileCache
163 FileHandle
164 Filter::Simple
165 Filter::Util::Call
166 FindBin
167 GDBM_File
168 Getopt::Long
169 Getopt::Std
170 I18N::LangTags
171 I18N::Collate
172 IO::Dir
173 IO::File
174 IO::Handle
175 IO::Pipe
176 IO::Poll
177 IO::Seekable
178 IO::Select
179 IO::Socket
180 IO::Socket::INET
181 IO::Socket::UNIX
182 IPC::Open2
183 IPC::Open3
184 IPC::SysV
185 List::Util
186 Locale::Constants
187 Locale::Country
188 Locale::Currency
189 Locale::Language
190 Locale::Maketext
191 MIME::Base64
192 MIME::QuotedPrint
193 Math::BigFloat
194 Math::BigInt
195 Math::Complex
196 Math::Trig
197 NDBM_File
198 NEXT
199 Net::hostent
200 Net::netent
201 Net::protoent
202 Net::servent
203 ODBM_File
204 Opcode
205 PerlIO
206 POSIX
207 Pod::Checker
208 Pod::Find
209 Pod::Text
210 Pod::Usage
211 SDBM_File
212 Safe
213 Scalar::Util
214 Search::Dict
215 SelectSaver
216 SelfLoader
217 Socket
218 Storable
219 Switch
220 Symbol
221 Sys::Hostname
222 Sys::Syslog
223 Term::ANSIColor
224 Test
225 Test::Harness
226 Test::ParseWords
227 Text::Abbrev
228 Text::Balanced
229 Text::ParseWords
230 Text::Soundex
231 Text::Tabs
232 Text::Wrap
233 Thread
234 Tie::Array
235 Tie::Handle
236 Tie::Hash
237 Tie::RefHash
238 Tie::Scalar
239 Tie::SubstrHash
240 Time::HiRes
241 Time::Local
242 Time::Piece
243 Time::gmtime
244 Time::localtime
245 Time::tm
246 UNIVERSAL
247 User::grent
248 User::pwent
249 XS::Typemap
250 attrs
251 autouse
252 base
253 bytes
254 charnames
255 constant
256 diagnostics
257 fields
258 integer
259 locale
260 ops
261 overload
262 strict
263 subs
264 utf8
265 warnings
266 warnings::register