Evan Giles > Test-Compile-0.24 > Test::Compile

Download:
Test-Compile-0.24.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.24   Source   Latest Release: Test-Compile-v1.2.0

NAME ^

Test::Compile - Check whether Perl files compile correctly.

SYNOPSIS ^

    use Test::Compile;
    all_pm_files_ok();

DESCRIPTION ^

Test::Compile lets you check the whether your perl modules and scripts compile properly, and report its results in standard Test::Simple fashion.

The basic usage - as shown above, will find all pm files and test that they all compile.

You can explicitly specify the list of directories to check, using the all_pm_files() function supplied:

    my @pmdirs = qw(blib script);
    all_pm_files_ok(all_pm_files(@pmdirs));

FUNCTIONS ^

all_pm_files_ok(@files)

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

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

It also calls the plan() function for you (one test for each module), so you can't have already called plan. Unfortunately, this also means you can't use this function with all_pl_files_ok(). If this is a problem you should really be using Test::Compile::Internal.

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

Module authors can include the following in a t/00_compile.t file and have Test::Compile automatically find and check all Perl module files in a module distribution:

    #!perl -w
    use strict;
    use warnings;
    use Test::More;
    eval "use Test::Compile";
    Test::More->builder->BAIL_OUT(
        "Test::Compile required for testing compilation") if $@;
    all_pm_files_ok();
all_pl_files_ok(@files)

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

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

It also calls the plan() function for you (one test for each script), so you can't have already called plan. Unfortunately, this also means you can't use this function with all_pm_files_ok(). If this is a problem you should really be using Test::Compile::Internal.

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

Module authors can include the following in a t/00_compile_scripts.t file and have Test::Compile automatically find and check all Perl script files in a module distribution:

    #!perl -w
    use strict;
    use warnings;
    use Test::More;
    eval "use Test::Compile";
    plan skip_all => "Test::Compile required for testing compilation"
      if $@;
    all_pl_files_ok();
pm_file_ok($filename,$testname)

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

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

pl_file_ok($filename,$testname)

pl_file_ok() will okay the test if $filename compiles as a perl script. You need to give the path to the script relative to this distribution's base directory. So if you put your scripts in a 'top-level' directory called script the argument would be script/filename.

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

all_pm_files(@dirs)

Returns a list of all the perl module files - that is, files ending in .pm - in @dirs and in directories below. If no directories are passed, it defaults to blib if blib exists, or else lib if not. Skips any files in CVS or .svn directories.

The order of the files returned is machine-dependent. If you want them sorted, you'll have to sort them yourself.

all_pl_files(@dirs)

Returns a list of all the perl script files - that is, files ending in .pl or with no extension. Directory arguments are searched recursively . If @dirs is undefined, it defaults to script if script exists, or else bin if bin exists. Skips any files in CVS or .svn directories.

The order of the files returned is machine-dependent. If you want them sorted, you'll have to sort them yourself.

AUTHORS ^

Sagar R. Shah <srshah@cpan.org>, Marcel Grünauer, <marcel@cpan.org>, Evan Giles, <egiles@cpan.org>

COPYRIGHT AND LICENSE ^

Copyright 2007-2013 by the authors.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO ^

Test::Compile::Internal provides an object oriented interface to the Test::Compile functionality.

Test::Strict proveds functions to ensure your perl files comnpile, with added bonus that it will check you have used strict in all your files. Test::LoadAllModules just handles modules, not script files, but has more fine-grained control.

syntax highlighting: