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 files in
@files
for compilation. It runs "all_pm_files()" on each file/directory, and calls theplan()
function for you (one test for each module), so you can't have already calledplan
.If
@files
is empty or not passed, the function finds all Perl module files in the blib directory if it exists, or the lib directory if not. A Perl module file is one that ends with .pm.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 files in
@files
for compilation. It runs pl_file_ok() on each file, and calls theplan()
function for you (one test for each script), so you can't have already calledplan
.If
@files
is empty or not passed, the function uses all_pl_files() to find scripts to test.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_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 nameCompile 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 bescript/filename
.The optional second argument
$testname
is the name of the test. If it is omitted,pl_file_ok()
chooses a default test nameCompile 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.