This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
vars very much has a test.
[perl5.git] / t / lib / 1_compile.t
CommitLineData
7200bc44
JH
1#!./perl
2
3BEGIN {
4 chdir '..' if -d '../pod' && -d '../t';
5 @INC = 'lib';
6}
7
8use strict;
9use warnings;
cdd2acaa 10use Config;
7200bc44 11
cdd2acaa
JH
12my %Core_Modules;
13
656b9f42
JH
14unless (open(MANIFEST, "MANIFEST")) {
15 die "$0: failed to open 'MANIFEST': $!\n";
16}
17
18sub add_by_name {
19 $Core_Modules{$_[0]}++;
20}
21
22while (<MANIFEST>) {
23 next unless m!^lib/(\S+?)\.pm!;
24 my $module = $1;
25 $module =~ s!/!::!g;
26 add_by_name($module);
27}
28
29close(MANIFEST);
cdd2acaa
JH
30
31# Delete stuff that can't be tested here.
32
656b9f42
JH
33sub delete_by_name {
34 delete $Core_Modules{$_[0]};
35}
36
37sub has_extension {
38 $Config{extensions} =~ /\b$_[0]\b/i;
39}
40
41sub delete_unless_has_extension {
42 delete $Core_Modules{$_[0]} unless has_extension($_[0]);
cdd2acaa
JH
43}
44
45foreach my $known_extension (split(' ', $Config{known_extensions})) {
656b9f42 46 delete_unless_has_extension($known_extension);
cdd2acaa
JH
47}
48
49sub delete_by_prefix {
656b9f42
JH
50 for my $match (grep { /^$_[0]/ } keys %Core_Modules) {
51 delete_by_name($match);
52 }
cdd2acaa
JH
53}
54
656b9f42 55delete_by_name('CGI::Fast'); # won't load without FCGI
cdd2acaa 56
656b9f42 57delete_by_name('Devel::DProf'); # needs to be run as -d:DProf
cdd2acaa
JH
58
59delete_by_prefix('ExtUtils::MM_'); # ExtUtils::MakeMaker's domain
60
61delete_by_prefix('File::Spec::'); # File::Spec's domain
656b9f42 62add_by_name('File::Spec::Functions'); # put this back
cdd2acaa 63
04070b92
JH
64delete_by_prefix('Attribute::Handlers');# we test this, and we have demos
65
656b9f42
JH
66sub using_feature {
67 my $use = "use$_[0]";
68 exists $Config{$use} &&
69 defined $Config{$use} &&
70 $Config{$use} eq 'define';
71}
72
73unless (using_feature('threads') && has_extension('Thread')) {
74 delete_by_name('Thread');
290a1446 75 delete_by_prefix('Thread::');
eba8ff18 76}
cdd2acaa 77
a0cb3900
JH
78unless (has_extension('NDBM_File')) {
79 delete_by_name('Memoize::NDBM_File');
80}
81
cdd2acaa 82delete_by_prefix('unicode::');
cdd2acaa 83
04070b92
JH
84# Delete all modules which have their own tests.
85# This makes this test a lot faster.
6b40b044
MS
86foreach my $mod (<DATA>) {
87 chomp $mod;
88 delete_by_name($mod);
89}
90
cdd2acaa
JH
91# Okay, this is the list.
92
93my @Core_Modules = sort keys %Core_Modules;
7200bc44
JH
94
95print "1..".@Core_Modules."\n";
96
97my $test_num = 1;
cdd2acaa 98
7200bc44 99foreach my $module (@Core_Modules) {
17bcccd5 100 print "$module compile failed\nnot " unless compile_module($module);
7200bc44
JH
101 print "ok $test_num\n";
102 $test_num++;
103}
104
656b9f42
JH
105# We do this as a separate process else we'll blow the hell
106# out of our namespace.
7200bc44 107sub compile_module {
656b9f42 108 my ($module) = $_[0];
7200bc44 109
1189d1e4
JH
110 my $out = scalar `$^X "-Ilib" t/lib/compmod.pl $module`;
111 print "# $out";
112 return $out =~ /^ok/;
7200bc44 113}
6b40b044 114
20e80008
JH
115# Add here modules that have their own test scripts and therefore
116# need not be test-compiled by 1_compile.t.
6b40b044
MS
117__DATA__
118AnyDBM_File
dc6b6eef 119Attribute::Handlers
6b40b044
MS
120AutoLoader
121B
122B::Debug
123B::Deparse
124B::ShowLex
125B::Stash
126Benchmark
127CGI
79319589
JH
128CGI::Apache
129CGI::Carp
130CGI::Cookie
131CGI::Form
6b40b044 132CGI::Pretty
79319589 133CGI::Switch
6b40b044
MS
134CGI::Util
135Carp
20e80008 136Carp::Heavy
6b40b044
MS
137Class::ISA
138Class::Struct
46700524 139CPAN
6b40b044
MS
140Cwd
141DB_File
142Data::Dumper
143Devel::DProf
144Devel::Peek
7f4f6daf 145Devel::SelfStubber
6b40b044
MS
146Digest
147Digest::MD5
148DirHandle
149Dumpvalue
150Encode
151English
152Env
153Errno
154Exporter
155Exporter::Heavy
20e80008
JH
156ExtUtils::Constant
157ExtUtils::MakeMaker
6b40b044
MS
158Fatal
159Fcntl
160File::Basename
161File::CheckTree
02c8fbd5 162File::Compare
6b40b044
MS
163File::Copy
164File::DosGlob
165File::Find
166File::Glob
167File::Path
168File::Spec
169File::Spec::Functions
170File::Temp
f7a45afb 171File::stat
6b40b044
MS
172FileCache
173FileHandle
7eade29f 174Filter::Simple
6b40b044
MS
175Filter::Util::Call
176FindBin
177GDBM_File
178Getopt::Long
179Getopt::Std
d763e2de 180I18N::Langinfo
20e80008 181I18N::LangTags
0e6c72d5 182I18N::LangTags::List
20e80008 183I18N::Collate
6b40b044
MS
184IO::Dir
185IO::File
186IO::Handle
187IO::Pipe
188IO::Poll
189IO::Seekable
190IO::Select
191IO::Socket
192IO::Socket::INET
193IO::Socket::UNIX
194IPC::Open2
195IPC::Open3
196IPC::SysV
79319589 197Lingua::KO::Hangul::Util
6b40b044
MS
198List::Util
199Locale::Constants
200Locale::Country
201Locale::Currency
202Locale::Language
20e80008 203Locale::Maketext
6b40b044
MS
204MIME::Base64
205MIME::QuotedPrint
206Math::BigFloat
207Math::BigInt
0e6c72d5 208Math::BigInt::Calc
6b40b044
MS
209Math::Complex
210Math::Trig
0e6c72d5
JH
211Memoize
212Memoize::AnyDBM_File
213Memoize::Expire
214Memoize::ExpireFile
215Memoize::ExpireTest
216Memoize::NDBM_File
217Memoize::SDBM_File
218Memoize::Storable
6b40b044 219NDBM_File
7eade29f 220NEXT
6b40b044 221Net::hostent
cdbd8744 222Net::netent
6fa754df
JH
223Net::protoent
224Net::servent
6b40b044
MS
225ODBM_File
226Opcode
20e80008 227PerlIO
6b40b044
MS
228POSIX
229Pod::Checker
230Pod::Find
231Pod::Text
232Pod::Usage
233SDBM_File
234Safe
235Scalar::Util
236Search::Dict
237SelectSaver
238SelfLoader
79319589 239Shell
6b40b044
MS
240Socket
241Storable
242Switch
243Symbol
244Sys::Hostname
245Sys::Syslog
246Term::ANSIColor
247Test
248Test::Harness
0e6c72d5
JH
249Test::More
250Test::Simple
6b40b044
MS
251Test::ParseWords
252Text::Abbrev
253Text::Balanced
254Text::ParseWords
255Text::Soundex
256Text::Tabs
257Text::Wrap
258Thread
259Tie::Array
260Tie::Handle
261Tie::Hash
262Tie::RefHash
263Tie::Scalar
264Tie::SubstrHash
265Time::HiRes
266Time::Local
2857d2f7
JH
267Time::gmtime
268Time::localtime
269Time::tm
79319589
JH
270Unicode::Collate
271Unicode::Normalize
272Unicode::UCD
6b40b044 273UNIVERSAL
6888c95f 274User::grent
c7506216 275User::pwent
6b40b044 276XS::Typemap
601f2d16 277attributes
6b40b044 278attrs
20e80008 279autouse
6b40b044
MS
280base
281bytes
282charnames
283constant
284diagnostics
285fields
286integer
70a6dec2 287less
6b40b044
MS
288locale
289ops
290overload
291strict
292subs
293utf8
7f6172af 294vars
6b40b044
MS
295warnings
296warnings::register