Also ExtUtils.t had $^X assumptions.
[p5sagit/p5-mst-13.2.git] / t / lib / 1_compile.t
CommitLineData
7200bc44 1#!./perl
2
3BEGIN {
6469810f 4 if (-d '../pod' && -d '../t') {
5 require File::Spec;
6 my ($v,$d,$f) = File::Spec->splitpath($^X);
7 $^X = File::Spec->catfile(File::Spec->curdir, $f)
8 if $^X eq File::Spec->catfile(File::Spec->updir, $f);
9 chdir '..';
10 }
7200bc44 11 @INC = 'lib';
12}
13
14use strict;
15use warnings;
cdd2acaa 16use Config;
7200bc44 17
cdd2acaa 18my %Core_Modules;
4d0ed6f7 19my %Test;
cdd2acaa 20
656b9f42 21unless (open(MANIFEST, "MANIFEST")) {
22 die "$0: failed to open 'MANIFEST': $!\n";
23}
24
25sub add_by_name {
26 $Core_Modules{$_[0]}++;
27}
28
29while (<MANIFEST>) {
4d0ed6f7 30 if (m!^(lib)/(\S+?)\.pm\s!) {
31 # Collecting modules names from under ext/ would be
32 # rather painful since the mapping from filenames
33 # to module names is not 100%.
34 my ($dir, $module) = ($1, $2);
35 $module =~ s!/!::!g;
36 add_by_name($module);
37 } elsif (m!^(lib|ext)/(\S+?)(?:\.t|/test.pl)\s!) {
38 my ($dir, $test) = ($1, $2);
39 $test =~ s!(\w+)/\1$!$1! if $dir eq 'ext';
40 $test =~ s!/t/[^/]+$!!;
41 $test =~ s!/!::!g;
42 $Test{$test}++;
43 }
656b9f42 44}
45
46close(MANIFEST);
cdd2acaa 47
48# Delete stuff that can't be tested here.
49
656b9f42 50sub delete_by_name {
51 delete $Core_Modules{$_[0]};
52}
53
54sub has_extension {
55 $Config{extensions} =~ /\b$_[0]\b/i;
56}
57
58sub delete_unless_has_extension {
59 delete $Core_Modules{$_[0]} unless has_extension($_[0]);
cdd2acaa 60}
61
62foreach my $known_extension (split(' ', $Config{known_extensions})) {
656b9f42 63 delete_unless_has_extension($known_extension);
cdd2acaa 64}
65
66sub delete_by_prefix {
656b9f42 67 for my $match (grep { /^$_[0]/ } keys %Core_Modules) {
68 delete_by_name($match);
69 }
cdd2acaa 70}
71
656b9f42 72delete_by_name('CGI::Fast'); # won't load without FCGI
cdd2acaa 73
cdd2acaa 74delete_by_prefix('ExtUtils::MM_'); # ExtUtils::MakeMaker's domain
75
76delete_by_prefix('File::Spec::'); # File::Spec's domain
656b9f42 77add_by_name('File::Spec::Functions'); # put this back
cdd2acaa 78
04070b92 79delete_by_prefix('Attribute::Handlers');# we test this, and we have demos
80
656b9f42 81sub using_feature {
82 my $use = "use$_[0]";
83 exists $Config{$use} &&
84 defined $Config{$use} &&
85 $Config{$use} eq 'define';
86}
87
88unless (using_feature('threads') && has_extension('Thread')) {
89 delete_by_name('Thread');
290a1446 90 delete_by_prefix('Thread::');
eba8ff18 91}
cdd2acaa 92
a0cb3900 93unless (has_extension('NDBM_File')) {
94 delete_by_name('Memoize::NDBM_File');
95}
96
3de3f243 97if (ord('A') == 193) {
c8b7969b 98 delete_by_prefix('Net::') unless eval { require Convert::EBCDIC };
3de3f243 99}
100
04070b92 101# Delete all modules which have their own tests.
102# This makes this test a lot faster.
4d0ed6f7 103foreach my $mod (sort keys %Test) {
104 delete_by_name($mod);
105}
6b40b044 106foreach my $mod (<DATA>) {
107 chomp $mod;
0d0c1411 108 print "### $mod has a test but is in DATA of $0\n" if exists $Test{$mod};
6b40b044 109 delete_by_name($mod);
110}
111
cdd2acaa 112# Okay, this is the list.
113
114my @Core_Modules = sort keys %Core_Modules;
7200bc44 115
116print "1..".@Core_Modules."\n";
117
118my $test_num = 1;
cdd2acaa 119
7200bc44 120foreach my $module (@Core_Modules) {
17bcccd5 121 print "$module compile failed\nnot " unless compile_module($module);
7200bc44 122 print "ok $test_num\n";
123 $test_num++;
124}
125
656b9f42 126# We do this as a separate process else we'll blow the hell
127# out of our namespace.
7200bc44 128sub compile_module {
656b9f42 129 my ($module) = $_[0];
7200bc44 130
1189d1e4 131 my $out = scalar `$^X "-Ilib" t/lib/compmod.pl $module`;
132 print "# $out";
133 return $out =~ /^ok/;
7200bc44 134}
6b40b044 135
20e80008 136# Add here modules that have their own test scripts and therefore
137# need not be test-compiled by 1_compile.t.
6b40b044 138__DATA__
6b40b044 139B::ShowLex
79319589 140CGI::Apache
141CGI::Carp
142CGI::Cookie
143CGI::Form
6b40b044 144CGI::Pretty
0d0c1411 145CGI::Push
79319589 146CGI::Switch
6b40b044 147CGI::Util
20e80008 148Carp::Heavy
6ae1853a 149CPAN::Nox
6b40b044 150Exporter::Heavy
20e80008 151ExtUtils::Constant
152ExtUtils::MakeMaker
6b40b044 153Filter::Util::Call
6b40b044 154GDBM_File
0e6c72d5 155I18N::LangTags::List
6b40b044 156IO::Dir
157IO::File
158IO::Handle
159IO::Pipe
160IO::Poll
161IO::Seekable
162IO::Select
163IO::Socket
164IO::Socket::INET
165IO::Socket::UNIX
6b40b044 166Locale::Constants
167Locale::Country
168Locale::Currency
169Locale::Language
6b40b044 170MIME::QuotedPrint
171Math::BigFloat
0e6c72d5 172Math::BigInt::Calc
0e6c72d5 173Memoize::AnyDBM_File
174Memoize::Expire
175Memoize::ExpireFile
176Memoize::ExpireTest
177Memoize::NDBM_File
178Memoize::SDBM_File
179Memoize::Storable
6b40b044 180NDBM_File
6b40b044 181ODBM_File
6b40b044 182Pod::Checker
183Pod::Find
f56fdd80 184Pod::Html
fed96050 185Pod::LaTeX
f56fdd80 186Pod::Man
187Pod::ParseLink
fed96050 188Pod::ParseUtils
6b40b044 189Pod::Text
f56fdd80 190Pod::Text::Overstrike
191Pod::Text::Termcap
6b40b044 192Pod::Usage
193SDBM_File
194Safe
195Scalar::Util
6b40b044 196Sys::Syslog
0e6c72d5 197Test::More
6b40b044 198Test::ParseWords
6b40b044 199Text::Tabs
200Text::Wrap
201Thread
202Tie::Array
203Tie::Handle
204Tie::Hash
2857d2f7 205Time::tm
6b40b044 206UNIVERSAL
601f2d16 207attributes
6b40b044 208base
6b40b044 209ops
d99274ce 210warnings::register