Test-Compile
view release on metacpan or search on metacpan
lib/Test/Compile/Internal.pm view on Meta::CPAN
use warnings;
use strict;
use version; our $VERSION = version->declare("v3.3.3");
use File::Find;
use File::Spec;
use Test::Builder;
use IPC::Open3 ();
=head1 NAME
Test::Compile::Internal - Assert that your Perl files compile OK.
=head1 SYNOPSIS
use Test::Compile::Internal;
my $test = Test::Compile::Internal->new();
$test->all_files_ok();
$test->done_testing();
=head1 DESCRIPTION
C<Test::Compile::Internal> is an object oriented tool for testing whether your
perl files compile.
It is primarily to provide the inner workings of C<Test::Compile>, but it can
also be used directly to test a CPAN distribution.
=head1 METHODS
=over 4
=item C<new()>
A basic constructor, nothing special.
=cut
sub new {
my ($class, %self) = @_;
my $self = \%self;
$self->{test} = Test::Builder->new();
bless ($self, $class);
return $self;
}
=item C<all_files_ok(@search)>
Looks for perl files and tests them all for compilation errors.
If C<@search> is defined then it is taken as an array of files or
directories to be searched for perl files, otherwise it searches the default
locations you'd expect to find perl files in a perl module - see
L</all_pm_files> and L</all_pl_files> for details.
=cut
sub all_files_ok {
my ($self, @search) = @_;
my $pm_ok = $self->all_pm_files_ok(@search);
my $pl_ok = $self->all_pl_files_ok(@search);
return ( $pm_ok && $pl_ok );
}
=item C<all_pm_files_ok(@search)>
Checks all the perl module files it can find for compilation errors.
If C<@search> is defined then it is taken as an array of files or
directories to be searched for perl files, otherwise it searches the default
locations you'd expect to find perl files in a perl module - see
L</all_pm_files> for details.
=cut
sub all_pm_files_ok {
my ($self, @search) = @_;
my $test = $self->{test};
my $ok = 1;
for my $file ( $self->all_pm_files(@search) ) {
my $testok = $self->pm_file_compiles($file);
$ok = $testok ? $ok : 0;
$test->ok($testok, "$file compiles");
}
return $ok;
}
=item C<all_pl_files_ok(@search)>
Checks all the perl program files it can find for compilation errors.
If C<@search> is defined then it is taken as an array of directories to
be searched for perl files, otherwise it searches some default locations
- see L</all_pl_files>.
=cut
sub all_pl_files_ok {
my ($self, @search) = @_;
my $test = $self->{test};
my $ok = 1;
for my $file ( $self->all_pl_files(@search) ) {
my $testok = $self->pl_file_compiles($file);
$ok = $testok ? $ok : 0;
$test->ok($testok, "$file compiles");
}
return $ok;
}
=item C<verbose($verbose)>
An accessor to get/set the verbosity. The default value (undef) will suppress output
unless the compilation fails. This is probably what you want.
If C<verbose> is set to true, you'll get the output from 'perl -c'. If it's set to
false, all diagnostic output is suppressed.
=cut
sub verbose {
my ($self, $verbose) = @_;
if ( @_ eq 2 ) {
$self->{_verbose} = $verbose;
}
return $self->{_verbose};
}
=item C<all_pm_files(@search)>
( run in 2.311 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )