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