Re: [PATCH] Tests for File::Compare
[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::Compare
151 File::Copy
152 File::DosGlob
153 File::Find
154 File::Glob
155 File::Path
156 File::Spec
157 File::Spec::Functions
158 File::Temp
159 File::stat
160 FileCache
161 FileHandle
162 Filter::Simple
163 Filter::Util::Call
164 FindBin
165 GDBM_File
166 Getopt::Long
167 Getopt::Std
168 I18N::LangTags
169 I18N::Collate
170 IO::Dir
171 IO::File
172 IO::Handle
173 IO::Pipe
174 IO::Poll
175 IO::Seekable
176 IO::Select
177 IO::Socket
178 IO::Socket::INET
179 IO::Socket::UNIX
180 IPC::Open2
181 IPC::Open3
182 IPC::SysV
183 List::Util
184 Locale::Constants
185 Locale::Country
186 Locale::Currency
187 Locale::Language
188 Locale::Maketext
189 MIME::Base64
190 MIME::QuotedPrint
191 Math::BigFloat
192 Math::BigInt
193 Math::Complex
194 Math::Trig
195 NDBM_File
196 NEXT
197 Net::hostent
198 Net::netent
199 Net::protoent
200 Net::servent
201 ODBM_File
202 Opcode
203 PerlIO
204 POSIX
205 Pod::Checker
206 Pod::Find
207 Pod::Text
208 Pod::Usage
209 SDBM_File
210 Safe
211 Scalar::Util
212 Search::Dict
213 SelectSaver
214 SelfLoader
215 Socket
216 Storable
217 Switch
218 Symbol
219 Sys::Hostname
220 Sys::Syslog
221 Term::ANSIColor
222 Test
223 Test::Harness
224 Test::ParseWords
225 Text::Abbrev
226 Text::Balanced
227 Text::ParseWords
228 Text::Soundex
229 Text::Tabs
230 Text::Wrap
231 Thread
232 Tie::Array
233 Tie::Handle
234 Tie::Hash
235 Tie::RefHash
236 Tie::Scalar
237 Tie::SubstrHash
238 Time::HiRes
239 Time::Local
240 Time::Piece
241 Time::gmtime
242 Time::localtime
243 Time::tm
244 UNIVERSAL
245 User::grent
246 User::pwent
247 XS::Typemap
248 attrs
249 autouse
250 base
251 bytes
252 charnames
253 constant
254 diagnostics
255 fields
256 integer
257 locale
258 ops
259 overload
260 strict
261 subs
262 utf8
263 warnings
264 warnings::register