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