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