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