Re: [PATCH 5.6.1] test suite
[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     return scalar `$^X "-Ilib" t/lib/compmod.pl $module` =~ /^ok/;
112 }
113
114 # Add here modules that have their own test scripts and therefore
115 # need not be test-compiled by 1_compile.t.
116 __DATA__
117 AnyDBM_File
118 Attribute::Handlers
119 AutoLoader
120 B
121 B::Debug
122 B::Deparse
123 B::ShowLex
124 B::Stash
125 Benchmark
126 CGI
127 CGI::Pretty
128 CGI::Util
129 Carp
130 Carp::Heavy
131 Class::ISA
132 Class::Struct
133 CPAN
134 Cwd
135 DB_File
136 Data::Dumper
137 Devel::DProf
138 Devel::Peek
139 Devel::SelfStubber
140 Digest
141 Digest::MD5
142 DirHandle
143 Dumpvalue
144 Encode
145 English
146 Env
147 Errno
148 Exporter
149 Exporter::Heavy
150 ExtUtils::Constant
151 ExtUtils::MakeMaker
152 Fatal
153 Fcntl
154 File::Basename
155 File::CheckTree
156 File::Compare
157 File::Copy
158 File::DosGlob
159 File::Find
160 File::Glob
161 File::Path
162 File::Spec
163 File::Spec::Functions
164 File::Temp
165 File::stat
166 FileCache
167 FileHandle
168 Filter::Simple
169 Filter::Util::Call
170 FindBin
171 GDBM_File
172 Getopt::Long
173 Getopt::Std
174 I18N::LangTags
175 I18N::Collate
176 IO::Dir
177 IO::File
178 IO::Handle
179 IO::Pipe
180 IO::Poll
181 IO::Seekable
182 IO::Select
183 IO::Socket
184 IO::Socket::INET
185 IO::Socket::UNIX
186 IPC::Open2
187 IPC::Open3
188 IPC::SysV
189 List::Util
190 Locale::Constants
191 Locale::Country
192 Locale::Currency
193 Locale::Language
194 Locale::Maketext
195 MIME::Base64
196 MIME::QuotedPrint
197 Math::BigFloat
198 Math::BigInt
199 Math::Complex
200 Math::Trig
201 NDBM_File
202 NEXT
203 Net::hostent
204 Net::netent
205 Net::protoent
206 Net::servent
207 ODBM_File
208 Opcode
209 PerlIO
210 POSIX
211 Pod::Checker
212 Pod::Find
213 Pod::Text
214 Pod::Usage
215 SDBM_File
216 Safe
217 Scalar::Util
218 Search::Dict
219 SelectSaver
220 SelfLoader
221 Socket
222 Storable
223 Switch
224 Symbol
225 Sys::Hostname
226 Sys::Syslog
227 Term::ANSIColor
228 Test
229 Test::Harness
230 Test::ParseWords
231 Text::Abbrev
232 Text::Balanced
233 Text::ParseWords
234 Text::Soundex
235 Text::Tabs
236 Text::Wrap
237 Thread
238 Tie::Array
239 Tie::Handle
240 Tie::Hash
241 Tie::RefHash
242 Tie::Scalar
243 Tie::SubstrHash
244 Time::HiRes
245 Time::Local
246 Time::Piece
247 Time::gmtime
248 Time::localtime
249 Time::tm
250 UNIVERSAL
251 User::grent
252 User::pwent
253 XS::Typemap
254 attributes
255 attrs
256 autouse
257 base
258 bytes
259 charnames
260 constant
261 diagnostics
262 fields
263 integer
264 locale
265 ops
266 overload
267 strict
268 subs
269 utf8
270 warnings
271 warnings::register