Test::Compile(3pm) | User Contributed Perl Documentation | Test::Compile(3pm) |
Test::Compile - Check whether Perl files compile correctly.
# The OO way (recommended) use Test::Compile; my $test = Test::Compile->new(); $test->all_files_ok(); $test->done_testing(); # The procedural way (deprecated) use Test::Compile; all_pm_files_ok();
"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 locate your perl files and test that they all compile.
Module authors can (and probably should) include the following in a t/00-compile.t file and have "Test::Compile" automatically find and check all Perl files in a module distribution:
#!perl use strict; use warnings; use Test::Compile; my $test = Test::Compile->new(); $test->all_files_ok(); $test->done_testing();
If @dirs is defined then it is taken as an array of directories to be searched for perl files, otherwise it searches some default locations - see "all_pm_files()" and "all_pl_files()".
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.
If @dirs is undefined, it searches 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.
Verbose is set on by default.
"Test::Compile::Internal" encapsulates a "Test::Builder" object, and provides access to some of its methods.
Output will be indented and marked with a # so as not to interfere with test output. A newline will be put on the end if there isn't one already.
We encourage using this rather than calling print directly.
The use of the following functions is deprecated and strongly discouraged.
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.
Even then, you really should use the object oriented methods as they provide a more consistent interface.
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 the object oriented interface.
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();
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 the object oriented interface.
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();
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".
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".
The order of the files returned is machine-dependent. If you want them sorted, you'll have to sort them yourself.
If @dirs is undefined, it searches 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.
Sagar R. Shah "<srshah@cpan.org>", Marcel Gruenauer, "<marcel@cpan.org>", Evan Giles, "<egiles@cpan.org>"
Copyright 2007-2015 by the authors.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Test::Compile::Internal provides the object oriented interface to (and the inner workings for) the Test::Compile functionality.
Test::Strict provides functions to ensure your perl files compile, 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.
2015-10-06 | perl v5.20.2 |