Subject: | Test::Perl::Critic configuration methods missing |
There's no configuration methods for Test::Perl::Critic available.
This makes writing a test file that works both in "make test" and when
run from within t/ harder than necessary.
This does not work:
use Test::Perl::Critic -profile => 't/perlcriticrc';
if (-d 't/') { # when run from make test
all_critic_ok();
}
else {
all_critic_ok('../lib');
}
Test::Perl::Critic complains that it can't find 't/perlcriticrc'. The
ugly workaround is to either chdir or call import later (to configure
the critic):
This does not work:
use Test::Perl::Critic -profile => 't/perlcriticrc';
if (-d 't/') { # when run from make test
all_critic_ok();
}
else {
chdir('..');
all_critic_ok('lib');
}
This does, too:
use Test::Perl::Critic;
if (-d 't/') { # when run from make test
import Test::Perl::Critic, -profile => 't/perlcriticrc';
all_critic_ok();
}
else {
import Test::Perl::Critic, -profile => 'perlcriticrc');
all_critic_ok('../lib');
}
Both workarounds are undesirable, because they rely on
Test::Perl::Critic internals: The first one relies on the late loading
of the perlcriticrc given (in fact it wouldn't work if import only
checked for the file's existance), the second one (possibly) calling
import() several times (one could of course "require
Test::Perl::Critic", but this disallows writing "critic_ok $file,
$comment" in the style most testing modules propose).
A easy fix would be the addition of a configuration method similar to
Test::More's plan(), which accepts the same configuration parameters as
import.