Login
Need to load extra RequireRcsKeywords policy for self-compliance tests.
[gknop/Perl-Critic.git] / xt / author / 40_criticize-code.t
CommitLineData
faa35de4
JRT
1#!perl
2
31924245 3##############################################################################
2f7dedab
CD
4# $URL$
5# $Date$
485f86d9
JRT
6# $Author$
7# $Revision$
31924245 8##############################################################################
485f86d9 9
e9a6dae8
CD
10# Self-compliance tests
11
485f86d9
JRT
12use strict;
13use warnings;
34cc6052 14
e9a6dae8 15use English qw( -no_match_vars );
ba2ec250 16
37960e14 17use File::Spec qw();
ba2ec250 18
ba2ec250 19use Perl::Critic::Utils qw{ :characters };
34cc6052 20use Perl::Critic::TestUtils qw{ starting_points_including_examples };
e9a6dae8 21
1cccaadd
ES
22# Note: "use PolicyFactory" *must* appear after "use TestUtils" for the
23# -extra-test-policies option to work.
24use Perl::Critic::PolicyFactory (
25 '-test' => 1,
a139189f
JRT
26 '-extra-test-policies' => [ qw{ ErrorHandling::RequireUseOfExceptions
27 Miscellanea::RequireRcsKeywords } ],
1cccaadd
ES
28);
29
b185fa17
ES
30use Test::More;
31
32#-----------------------------------------------------------------------------
33
7f30e919 34our $VERSION = '1.116';
b185fa17 35
1cccaadd
ES
36#-----------------------------------------------------------------------------
37
ecd1a86a 38use Test::Perl::Critic;
485f86d9 39
31924245 40#-----------------------------------------------------------------------------
1cccaadd 41
ecd1a86a
ES
42# Fall over if P::C::More isn't installed.
43use Perl::Critic::Policy::ErrorHandling::RequireUseOfExceptions;
1cccaadd
ES
44
45#-----------------------------------------------------------------------------
e9a6dae8 46# Set up PPI caching for speed (used primarily during development)
31924245 47
e9a6dae8 48if ( $ENV{PERL_CRITIC_CACHE} ) {
2f7dedab 49 require PPI::Cache;
30c14d21
ES
50 my $cache_path =
51 File::Spec->catdir(
52 File::Spec->tmpdir,
53 "test-perl-critic-cache-$ENV{USER}",
54 );
a168820a 55 if ( ! -d $cache_path) {
2f7dedab
CD
56 mkdir $cache_path, oct 700;
57 }
e9a6dae8 58 PPI::Cache->import( path => $cache_path );
2f7dedab
CD
59}
60
31924245 61#-----------------------------------------------------------------------------
e9a6dae8 62# Strict object testing -- prevent direct hash key access
31924245 63
ecd1a86a
ES
64use Devel::EnforceEncapsulation;
65foreach my $pkg ( $EMPTY, qw< ::Config ::Policy ::Violation> ) {
66 Devel::EnforceEncapsulation->apply_to('Perl::Critic'.$pkg);
ba2ec250 67}
e9a6dae8 68
31924245 69#-----------------------------------------------------------------------------
e9a6dae8 70# Run critic against all of our own files
31924245 71
30c14d21 72my $rcfile = File::Spec->catfile( 'xt', 'author', '40_perlcriticrc-code' );
ca3abae1 73Test::Perl::Critic->import( -profile => $rcfile );
ee0fa298
ES
74
75all_critic_ok( starting_points_including_examples() );
737d3b65 76
ca3abae1
JRT
77#-----------------------------------------------------------------------------
78
737d3b65
CD
79# Local Variables:
80# mode: cperl
81# cperl-indent-level: 4
82# fill-column: 78
83# indent-tabs-mode: nil
84# c-indentation-style: bsd
85# End:
96fed375 86# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :