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