8e546507eac3eb3f498ac7429e65c992eba903e6
[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 __DATA__
110 AnyDBM_File
111 AutoLoader
112 B
113 B::Debug
114 B::Deparse
115 B::ShowLex
116 B::Stash
117 Benchmark
118 CGI
119 CGI::Pretty
120 CGI::Util
121 Carp
122 Class::ISA
123 Class::Struct
124 CPAN
125 Cwd
126 DB_File
127 Data::Dumper
128 Devel::DProf
129 Devel::Peek
130 Devel::SelfStubber
131 Digest
132 Digest::MD5
133 DirHandle
134 Dumpvalue
135 Encode
136 English
137 Env
138 Errno
139 Exporter
140 Exporter::Heavy
141 Fatal
142 Fcntl
143 File::Basename
144 File::CheckTree
145 File::Copy
146 File::DosGlob
147 File::Find
148 File::Glob
149 File::Path
150 File::Spec
151 File::Spec::Functions
152 File::Temp
153 FileCache
154 FileHandle
155 Filter::Util::Call
156 FindBin
157 GDBM_File
158 Getopt::Long
159 Getopt::Std
160 IO::Dir
161 IO::File
162 IO::Handle
163 IO::Pipe
164 IO::Poll
165 IO::Seekable
166 IO::Select
167 IO::Socket
168 IO::Socket::INET
169 IO::Socket::UNIX
170 IPC::Open2
171 IPC::Open3
172 IPC::SysV
173 List::Util
174 Locale::Constants
175 Locale::Country
176 Locale::Currency
177 Locale::Language
178 MIME::Base64
179 MIME::QuotedPrint
180 Math::BigFloat
181 Math::BigInt
182 Math::Complex
183 Math::Trig
184 NDBM_File
185 Net::hostent
186 ODBM_File
187 Opcode
188 POSIX
189 Pod::Checker
190 Pod::Find
191 Pod::Text
192 Pod::Usage
193 SDBM_File
194 Safe
195 Scalar::Util
196 Search::Dict
197 SelectSaver
198 SelfLoader
199 Socket
200 Storable
201 Switch
202 Symbol
203 Sys::Hostname
204 Sys::Syslog
205 Term::ANSIColor
206 Test
207 Test::Harness
208 Test::ParseWords
209 Text::Abbrev
210 Text::Balanced
211 Text::ParseWords
212 Text::Soundex
213 Text::Tabs
214 Text::Wrap
215 Thread
216 Tie::Array
217 Tie::Handle
218 Tie::Hash
219 Tie::RefHash
220 Tie::Scalar
221 Tie::SubstrHash
222 Time::HiRes
223 Time::Local
224 Time::Piece
225 UNIVERSAL
226 XS::Typemap
227 attrs
228 base
229 bytes
230 charnames
231 constant
232 diagnostics
233 fields
234 integer
235 locale
236 ops
237 overload
238 strict
239 subs
240 utf8
241 vars
242 warnings
243 warnings::register