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