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