This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add a test for PerlIO.
[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
656b9f42
JH
64sub using_feature {
65 my $use = "use$_[0]";
66 exists $Config{$use} &&
67 defined $Config{$use} &&
68 $Config{$use} eq 'define';
69}
70
71unless (using_feature('threads') && has_extension('Thread')) {
72 delete_by_name('Thread');
290a1446 73 delete_by_prefix('Thread::');
eba8ff18 74}
cdd2acaa
JH
75
76delete_by_prefix('unicode::');
656b9f42 77add_by_name('unicode::distinct'); # put this back
cdd2acaa 78
6b40b044
MS
79
80# Delete all modules which have their own tests. This makes
46700524 81# this test a lot faster.
6b40b044
MS
82foreach my $mod (<DATA>) {
83 chomp $mod;
84 delete_by_name($mod);
85}
86
cdd2acaa
JH
87# Okay, this is the list.
88
89my @Core_Modules = sort keys %Core_Modules;
7200bc44
JH
90
91print "1..".@Core_Modules."\n";
92
93my $test_num = 1;
cdd2acaa 94
7200bc44 95foreach my $module (@Core_Modules) {
cdd2acaa 96 print "# $module compile failed\nnot " unless compile_module($module);
7200bc44
JH
97 print "ok $test_num\n";
98 $test_num++;
99}
100
656b9f42
JH
101# We do this as a separate process else we'll blow the hell
102# out of our namespace.
7200bc44 103sub compile_module {
656b9f42 104 my ($module) = $_[0];
7200bc44 105
bdc55ba4 106 return scalar `$^X "-Ilib" t/lib/compmod.pl $module` =~ /^ok/;
7200bc44 107}
6b40b044 108
6b40b044
MS
109__DATA__
110AnyDBM_File
111AutoLoader
112B
113B::Debug
114B::Deparse
115B::ShowLex
116B::Stash
117Benchmark
118CGI
119CGI::Pretty
120CGI::Util
121Carp
122Class::ISA
123Class::Struct
46700524 124CPAN
6b40b044
MS
125Cwd
126DB_File
127Data::Dumper
128Devel::DProf
129Devel::Peek
7f4f6daf 130Devel::SelfStubber
6b40b044
MS
131Digest
132Digest::MD5
133DirHandle
134Dumpvalue
135Encode
136English
137Env
138Errno
139Exporter
140Exporter::Heavy
141Fatal
142Fcntl
143File::Basename
144File::CheckTree
145File::Copy
146File::DosGlob
147File::Find
148File::Glob
149File::Path
150File::Spec
151File::Spec::Functions
152File::Temp
153FileCache
154FileHandle
7eade29f 155Filter::Simple
6b40b044
MS
156Filter::Util::Call
157FindBin
158GDBM_File
159Getopt::Long
160Getopt::Std
532e0e8e 161I18N:Collate
6b40b044
MS
162IO::Dir
163IO::File
164IO::Handle
165IO::Pipe
166IO::Poll
167IO::Seekable
168IO::Select
169IO::Socket
170IO::Socket::INET
171IO::Socket::UNIX
172IPC::Open2
173IPC::Open3
174IPC::SysV
175List::Util
176Locale::Constants
177Locale::Country
178Locale::Currency
179Locale::Language
180MIME::Base64
181MIME::QuotedPrint
182Math::BigFloat
183Math::BigInt
184Math::Complex
185Math::Trig
186NDBM_File
7eade29f 187NEXT
6b40b044
MS
188Net::hostent
189ODBM_File
190Opcode
191POSIX
192Pod::Checker
193Pod::Find
194Pod::Text
195Pod::Usage
196SDBM_File
197Safe
198Scalar::Util
199Search::Dict
200SelectSaver
201SelfLoader
202Socket
203Storable
204Switch
205Symbol
206Sys::Hostname
207Sys::Syslog
208Term::ANSIColor
209Test
210Test::Harness
211Test::ParseWords
212Text::Abbrev
213Text::Balanced
214Text::ParseWords
215Text::Soundex
216Text::Tabs
217Text::Wrap
218Thread
219Tie::Array
220Tie::Handle
221Tie::Hash
222Tie::RefHash
223Tie::Scalar
224Tie::SubstrHash
225Time::HiRes
226Time::Local
227Time::Piece
228UNIVERSAL
229XS::Typemap
230attrs
231base
232bytes
233charnames
234constant
235diagnostics
236fields
237integer
238locale
239ops
240overload
241strict
242subs
243utf8
6b40b044
MS
244warnings
245warnings::register