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