Convert op/read.t to use test.pl and make it stricture compliant.
[p5sagit/p5-mst-13.2.git] / t / lib / 1_compile.t
1 #!./perl
2
3 # Modules should have their own tests.  For historical reasons, some
4 # do not.  This does basic compile tests on modules that have no tests
5 # of their own.
6
7 BEGIN {
8     chdir 't';
9     @INC = '../lib';
10 }
11
12 use strict;
13 use warnings;
14 use File::Spec::Functions;
15
16 # Okay, this is the list.
17
18 my @Core_Modules = grep /\S/, <DATA>;
19 chomp @Core_Modules;
20
21 if (eval { require Socket }) {
22   push @Core_Modules, qw(Net::Domain);
23   # Two Net:: modules need the Convert::EBCDIC if in EBDCIC.
24   if (ord("A") != 193 || eval { require Convert::EBCDIC }) {
25       push @Core_Modules, qw(Net::Cmd Net::POP3);
26   }
27 }
28 if(eval { require B }) {
29   push @Core_Modules, qw(B::C B::CC B::Stackobj);
30 }
31
32 @Core_Modules = sort @Core_Modules;
33
34 print "1..".(1+@Core_Modules)."\n";
35
36 my $message
37   = "ok 1 - All modules should have tests # TODO Make Schwern Poorer\n";
38 if (@Core_Modules) {
39   print "not $message";
40 } else {
41   print $message;
42 }
43
44 my $test_num = 2;
45
46 foreach my $module (@Core_Modules) {
47     my $todo = '';
48     $todo = "# TODO $module needs porting on $^O" if $module eq 'ByteLoader' && $^O eq 'VMS';
49     print "# $module compile failed\nnot " unless compile_module($module);
50     print "ok $test_num $todo\n";
51     $test_num++;
52 }
53
54 # We do this as a separate process else we'll blow the hell
55 # out of our namespace.
56 sub compile_module {
57     my ($module) = $_[0];
58
59     my $compmod = catfile(curdir(), 'lib', 'compmod.pl');
60     my $lib     = '-I' . catdir(updir(), 'lib');
61
62     my $out = scalar `$^X $lib $compmod $module`;
63     print "# $out";
64     return $out =~ /^ok/;
65 }
66
67 # These modules have no tests of their own.
68 # Keep up to date with
69 # http://www.pobox.com/~schwern/cgi-bin/perl-qa-wiki.cgi?UntestedModules
70 # and vice-versa.  The list should only shrink.
71 __DATA__
72 CPAN::FirstTime
73 DynaLoader
74 Pod::Plainer