use strict;
use warnings FATAL => 'all';
-our $VERSION = '1.001001'; # 1.1.1
+use constant _PERL_LT_5_8_4 => ($] < 5.008004) ? 1 : 0;
+
+our $VERSION = '1.004000'; # 1.4.0
sub VERSION {
for ($_[1]) {
shift->SUPER::VERSION(@_);
}
+my $extras_load_warned;
+
+our $Smells_Like_VCS = (-e '.git' || -e '.svn'
+ || (-e '../../dist.ini' && (-e '../../.git' || -e '../../.svn')));
+
sub import {
strict->import;
warnings->import(FATAL => 'all');
- my $do_indirect = do {
+
+ my $extra_tests = do {
if (exists $ENV{PERL_STRICTURES_EXTRA}) {
- $ENV{PERL_STRICTURES_EXTRA}
- } else {
- !!($0 =~ /^x?t\/.*(?:load|compile|coverage|use_ok).*\.t$/
- and (-e '.git' or -e '.svn'))
+ if (_PERL_LT_5_8_4 and $ENV{PERL_STRICTURES_EXTRA}) {
+ die 'PERL_STRICTURES_EXTRA checks are not available on perls older than 5.8.4: '
+ . "please unset \$ENV{PERL_STRICTURES_EXTRA}\n";
+ }
+ $ENV{PERL_STRICTURES_EXTRA};
+ } elsif (! _PERL_LT_5_8_4) {
+ !!((caller)[1] =~ /^(?:t|xt|lib|blib)/
+ and $Smells_Like_VCS)
}
};
- if ($do_indirect) {
+ if ($extra_tests) {
+ my @failed;
if (eval { require indirect; 1 }) {
indirect->unimport(':fatal');
} else {
- die "strictures.pm extra testing active but couldn't load indirect.pm
+ push @failed, 'indirect';
+ }
+ if (eval { require multidimensional; 1 }) {
+ multidimensional->unimport;
+ } else {
+ push @failed, 'multidimensional';
+ }
+ if (eval { require bareword::filehandles; 1 }) {
+ bareword::filehandles->unimport;
+ } else {
+ push @failed, 'bareword::filehandles';
+ }
+ if (@failed and not $extras_load_warned++) {
+ my $failed = join ' ', @failed;
+ warn <<EOE;
+strictures.pm extra testing active but couldn't load all modules. Missing were:
+
+ $failed
+
Extra testing is auto-enabled in checkouts only, so if you're the author
-of a strictures using module you should 'cpan indirect' but the module
-is not required by your users.
-Error loading indirect.pm was: $@";
+of a strictures using module you need to run:
+
+ cpan indirect multidimensional bareword::filehandles
+
+but these modules are not required by your users.
+EOE
}
}
}
use strict;
use warnings FATAL => 'all';
-except when called from a file where $0 matches:
+except when called from a file which matches:
- /^x?t\/.*(?:load|compile|coverage|use_ok).*\.t$/
+ (caller)[1] =~ /^(?:t|xt|lib|blib)/
and when either '.git' or '.svn' is present in the current directory (with
the intention of only forcing extra tests on the author side) - or when the
use strict;
use warnings FATAL => 'all';
no indirect 'fatal';
+ no multidimensional;
+ no bareword::filehandles;
Note that _EXTRA may at some point add even more tests, with only a minor
version increase, but any changes to the effect of 'use strictures' in
normal mode will involve a major version bump.
-Be aware: THIS MEANS INDIRECT IS REQUIRED FOR AUTHORS OF STRICTURES USING
-CODE - but not by end users thereof.
+If any of the extra testing modules are not present, strictures will
+complain loudly, once, via warn(), and then shut up. But you really
+should consider installing them, they're all great anti-footgun tools.
=head1 DESCRIPTION
as such) get caught, but not at the cost of an XS dependency and not at the
cost of blowing things up on another machine.
-Therefore, strictures turns on indirect checking only when it thinks it's
-running in a compilation (or pod coverage) test - though if this causes
-undesired behaviour this can be overriden by setting the
+Therefore, strictures turns on additional checking, but only when it thinks
+it's running in a test file in a VCS checkout - though if this causes
+undesired behaviour this can be overridden by setting the
PERL_STRICTURES_EXTRA environment variable.
If additional useful author side checks come to mind, I'll add them to the
=head1 AUTHOR
-Matt S. Trout <mst@shadowcat.co.uk>
+mst - Matt S. Trout (cpan:MSTROUT) <mst@shadowcat.co.uk>
=head1 CONTRIBUTORS