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