syntax_ok($file[,$text])
Run a syntax check on $file by running "perl -c $file" with an external perl interpreter. The external
perl interpreter path is stored in $Test::Strict::PERL which can be modified. You may prefer use_ok()
from Test::More to syntax test a module. For a module, the path (lib/My/Module.pm) or the name
(My::Module) can be both used.
strict_ok($file[,$text])
Check if $file contains a "use strict;" statement. "use Moose" and "use Mouse" are also considered
valid. use Modern::Perl is also accepted.
This is a pretty naive test which may be fooled in some edge cases. For a module, the path
(lib/My/Module.pm) or the name (My::Module) can be both used.
modules_enabling_strict
Experimental. Returning a list of modules and pragmata that enable strict. To modify this list, change
@Test::Strict::MODULES_ENABLING_STRICT.
List taken from Module::CPANTS::Kwalitee::Uses v95
modules_enabling_warnings
Experimental. Returning a list of modules and pragmata that enable warnings To modify this list, change
@Test::Strict::MODULES_ENABLING_WARNINGS.
List taken from Module::CPANTS::Kwalitee::Uses v95
warnings_ok($file[,$text])
Check if warnings have been turned on.
If $file is a module, check if it contains a "use warnings;" or "use warnings::..." or "use Moose" or
"use Mouse" statement. use Modern::Perl is also accepted. If the perl version is <= 5.6, this test is
skipped ("use warnings" appeared in perl 5.6).
If $file is a script, check if it starts with "#!...perl -w". If the -w is not found and perl is >= 5.6,
check for a "use warnings;" or "use warnings::..." or "use Moose" or "use Mouse" statement. use
Modern::Perl is also accepted.
This is a pretty naive test which may be fooled in some edge cases. For a module, the path
(lib/My/Module.pm) or the name (My::Module) can be both used.
all_perl_files_ok([@directories])
Applies strict_ok() and syntax_ok() to all perl files found in @directories (and sub directories). If no
<@directories> is given, the starting point is one level above the current running script, that should
cover all the files of a typical CPAN distribution. A perl file is *.pl or *.pm or *.t or a file
starting with "#!...perl"
If the test plan is defined:
use Test::Strict tests => 18;
all_perl_files_ok();
the total number of files tested must be specified.
You can control which tests are run on each perl site through:
$Test::Strict::TEST_SYNTAX (default = 1)
$Test::Strict::TEST_STRICT (default = 1)
$Test::Strict::TEST_WARNINGS (default = 0)
$Test::Strict::TEST_SKIP (default = []) "Trusted" files to skip
all_cover_ok([coverage_threshold[,@t_dirs]])
This will run all the tests in @t_dirs (or current script's directory if @t_dirs is undef) under
Devel::Cover and calculate the global test coverage of the code loaded by the tests. If the test
coverage is greater or equal than "coverage_threshold", it is a pass, otherwise it's a fail. The default
coverage threshold is 50 (meaning 50% of the code loaded has been covered by test).
The threshold can be modified through $Test::Strict::COVERAGE_THRESHOLD.
You may want to select which files are selected for code coverage through
$Test::Strict::DEVEL_COVER_OPTIONS, see Devel::Cover for the list of available options. The default is
'+ignore,"/Test/Strict\b"'.
The path to "cover" utility can be modified through $Test::Strict::COVER.
The 50% threshold is a completely arbitrary value, which should not be considered as a good enough
coverage.
The total coverage is the return value of all_cover_ok().