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