Test-Compile

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN


v2.4.1    2020-07-06
    - (mohawk2) Fix if perl is installed in a dir with a space in it's path
    - (mohawk2) Fix for Strawberry perl without Devel::CheckOS

v2.4.0    2020-03-29
    - RT-132153: Be more verbose when in verbose mode
    - Update copyright

v2.3.1    2019-10-23
    - RT-130694: all_pm_files_ok and all_pl_files_ok should return true/false

v2.3.0    2019-10-09
    - Search for perl files in blib first (Alexandr Ciornii <alexchorny@gmail.com>)
    - Improve tests, remove redundant code, 
    - Refactor POD, make the deprecation of the functional interface clearer

v2.2.2    2019-07-11
    - Fix cpan-test failures on mswin32

v2.2.1    2019-07-09

Changes  view on Meta::CPAN

v2.1.2    2019-07-03
    - More corrections to the POD
    - More tests, try specifying specific files to all_pX_files()
    - Use the correct method in all_pl_files_ok() (Noel Maddy)

v2.1.1    2019-07-01              (Evan Giles <egiles@cpan.org>)
    - Correct the POD

v2.1.0    2019-06-29              (Evan Giles <egiles@cpan.org>)
    - Update copyright
    - Add all_pm_files_ok() and all_pl_files_ok() methods to the internal class

v2.0.1    2019-06-18              (Evan Giles <egiles@cpan.org>)
    - Export most of the old functions (CPAN-RT 129888)

v2.0_0    2019-06-18
    Łukasz Hejnak <lehack@lehack.pl>
    - Replaced import() with Exporter usage.
    - Added all_files_ok to the procedural mode.
    - Added .git to list of directories ignored when looking for pm/pl files.
    - Added an else clause for pl_file_compiles so that it catches file not found errors.

lib/Test/Compile.pm  view on Meta::CPAN

    my $test = Test::Compile->new();
    $test->all_files_ok();
    $test->done_testing();

=cut

our @EXPORT = qw(
    pm_file_ok
    pl_file_ok

    all_pm_files_ok
    all_pl_files_ok

    all_pm_files
    all_pl_files
);
our @EXPORT_OK = qw(
    pm_file_ok
    pl_file_ok

    all_files_ok
    all_pm_files_ok
    all_pl_files_ok

    all_pm_files
    all_pl_files
);
our %EXPORT_TAGS = ('all' => \@EXPORT_OK);

=head1 METHODS

=over 4

lib/Test/Compile.pm  view on Meta::CPAN

The use of the following functions is deprecated and strongly discouraged.

Instead, you should use the object oriented interface described in the L</SYNOPSIS>
and in L<Test::Compile::Internal>.

They are automatically exported to your namespace,  which is
no longer considered best practise.  At some stage in the future, this will
stop and you'll have to import them explicitly to keep using them.

The object oriented methods also provide a more consistent interface. 
For example: C<all_pm_files_ok()> calls the C<plan()> function - so you can't call
multiple test functions in the same test file.

=over 4

=item C<all_pm_files_ok(@files)>

B<This function is deprecated>.  Please use
L<Test::Compile::Internal/all_pm_files_ok(@dirs)> instead.  It's pretty much the
same, except it doesn't call the C<plan()> function.

Checks all the perl module files it can find for compilation errors.

It uses C<all_pm_files(@files)> to find the perl module files.

It also calls the C<plan()> function for you (one test for each module), so
you can't have already called C<plan()>. Unfortunately, this also means
you can't use this function with C<all_pl_files_ok()>.  If this is a problem
you should really be using the object oriented interface.

Returns true if all Perl module files are ok, or false if any fail.

=cut

sub all_pm_files_ok {
    my @files = @_ ? @_ : all_pm_files();
    $Test->plan(tests => scalar @files);
    return $Test->all_pm_files_ok(@files);
}

=item C<all_pl_files_ok(@files)>

B<This function is deprecated>.  Please use
L<Test::Compile::Internal/all_pl_files_ok(@dirs)> instead.  It's pretty much the
same, except it doesn't call the C<plan()> function.

Checks all the perl script files it can find for compilation errors.

It uses C<all_pl_files(@files)> to find the perl script files.

It also calls the C<plan()> function for you (one test for each script), so
you can't have already called C<plan>. Unfortunately, this also means
you can't use this function with C<all_pm_files_ok()>.  If this is a problem
you should really be using the object oriented interface.

Returns true if all Perl script files are ok, or false if any fail.

=cut

sub all_pl_files_ok {
    my @files = @_ ? @_ : all_pl_files();
    $Test->skip_all("no pl files found") unless @files;
    $Test->plan(tests => scalar @files);
    $Test->all_pl_files_ok(@files);
}

=item C<pm_file_ok($filename, $testname)>

B<This function is deprecated>.  Please use
L<Test::Compile::Internal/all_pm_files_ok(@dirs)> instead.  It's pretty much the
same, except it won't allow you to specify a test name, and it can handle more than
one file at a time.

C<pm_file_ok()> will okay the test if $filename compiles as a perl module.

The optional second argument C<$testname> is the name of the test. If it is
omitted, C<pm_file_ok()> chooses a default test name C<Compile test for
$filename>.

=cut

lib/Test/Compile/Internal.pm  view on Meta::CPAN


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");
    }

t/100-internal-basic.t  view on Meta::CPAN

my $test = new_ok('Test::Compile::Internal');

# Run some of the basic meithods, with basic test conditions
# ..mostly just to ensure they get executed

my $result;

$result = $test->all_pl_files_ok('t/scripts/messWithLib.pl');
$test->ok($result, "all_pl_files_ok returns true value");

$result = $test->all_pm_files_ok('lib/');
$test->ok($result, "all_pm_files_ok returns true value");

$result = $test->all_files_ok();
$test->ok($result, "all_files_ok returns true value");

# Fin...
$test->done_testing();

t/200-all-pm-files-ok.t  view on Meta::CPAN

#!perl
use strict;
use warnings;
use Test::Compile;

# all_pm_files_ok() calls 'plan()' and 'ok()' as required
# so we can't call those things in this script...
# this file is mostly just to increase the coverage.
all_pm_files_ok();

t/200-import-check.t  view on Meta::CPAN

use Test::More;
use Test::Compile;

plan skip_all => "Test::Exception required for checking exceptions"
    unless eval "use Test::Exception; 1";

my @EXPORTED = qw(
    pm_file_ok
    pl_file_ok

    all_pm_files_ok
    all_pl_files_ok

    all_pm_files
    all_pl_files
);
my @NOTEXPORTED = qw(
    all_files_ok
);

# try to use the methods, despite not exporting them



( run in 0.340 second using v1.01-cache-2.11-cpan-4face438c0f )