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