| 1 | #!perl |
| 2 | |
| 3 | # Extra self-compliance tests for Policy classes. This just checks for |
| 4 | # additional POD sections that we want in every Policy module. See the |
| 5 | # 41_perlcriticrc-policies file for the precise configuration. |
| 6 | |
| 7 | use strictscip-perl cpan Perl-Critic 1.156 strict/; |
| 8 | use warningsscip-perl cpan Perl-Critic 1.156 warnings/; |
| 9 | |
| 10 | use File::Specscip-perl cpan Perl-Critic 1.156 File/Spec/ qw<>; |
| 11 | |
| 12 | use Perl::Critic::PolicyFactoryscip-perl cpan Perl-Critic 1.156 Perl/Critic/PolicyFactory/ ( '-test' => 1 ); |
| 13 | |
| 14 | use Test::Morescip-perl cpan Perl-Critic 1.156 Test/More/; |
| 15 | |
| 16 | our $VERSIONscip-perl cpan Perl-Critic 1.156 main/$VERSION. = '1.156'; |
| 17 | |
| 18 | use Perl::Critic::TestUtilsscip-perl cpan Perl-Critic 1.156 Perl/Critic/TestUtils/; |
| 19 | Perl::Critic::TestUtils::assert_versionscip-perl cpan Perl-Critic 1.156 Perl/Critic/TestUtils/assert_version().( $VERSIONscip-perl cpan Perl-Critic 1.156 main/$VERSION. ); |
| 20 | |
| 21 | #----------------------------------------------------------------------------- |
| 22 | |
| 23 | eval 'use Test::Perl::Critic; 1;' |
| 24 | or planscip-perl cpan Perl-Critic 1.156 main/plan(). skip_all => 'Test::Perl::Critic required to test Perl::Critic itself'; |
| 25 | |
| 26 | #----------------------------------------------------------------------------- |
| 27 | |
| 28 | # Set up PPI caching for speed (used primarily during development) |
| 29 | |
| 30 | if ( $ENVscip-perl cpan Perl-Critic 1.156 main/`%ENV`.{PERL_CRITIC_CACHE} ) { |
| 31 | requirescip-perl cpan Perl-Critic 1.156 main/require(). PPI::Cache; |
| 32 | my $cache_path = |
| 33 | File::Spec->catdirscip-perl cpan Perl-Critic 1.156 File/Spec/catdir().( |
| 34 | File::Spec->tmpdirscip-perl cpan Perl-Critic 1.156 File/Spec/tmpdir().(), |
| 35 | "test-perl-critic-cache-$ENV{USER}" |
| 36 | ); |
| 37 | if ( ! -d $cache_path) { |
| 38 | mkdirscip-perl cpan Perl-Critic 1.156 main/mkdir(). $cache_path, octscip-perl cpan Perl-Critic 1.156 main/oct(). 700; |
| 39 | } |
| 40 | PPI::Cache->importscip-perl cpan Perl-Critic 1.156 PPI/Cache/import().( path => $cache_path ); |
| 41 | } |
| 42 | |
| 43 | #----------------------------------------------------------------------------- |
| 44 | # Run critic against all of our own files |
| 45 | |
| 46 | my $rcfile = File::Spec->catfilescip-perl cpan Perl-Critic 1.156 File/Spec/catfile().( qw< xt 41_perlcriticrc-policies > ); |
| 47 | Test::Perl::Critic->importscip-perl cpan Perl-Critic 1.156 Test/Perl/Critic/import().( -profile => $rcfile ); |
| 48 | |
| 49 | my $path = |
| 50 | File::Spec->catfilescip-perl cpan Perl-Critic 1.156 File/Spec/catfile().( |
| 51 | -e 'blib' ? 'blib/lib' : 'lib', |
| 52 | qw< Perl Critic Policy >, |
| 53 | ); |
| 54 | all_critic_okscip-perl cpan Perl-Critic 1.156 main/all_critic_ok().( $path ); |
| 55 | |
| 56 | #----------------------------------------------------------------------------- |
| 57 | |
| 58 | # Local Variables: |
| 59 | # mode: cperl |
| 60 | # cperl-indent-level: 4 |
| 61 | # fill-column: 78 |
| 62 | # indent-tabs-mode: nil |
| 63 | # c-indentation-style: bsd |
| 64 | # End: |
| 65 | # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : |