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