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