3 ##############################################################################
4 # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/Perl-Critic/xt/author/40_criticize-code.t $
5 # $Date: 2008-05-04 17:25:51 -0500 (Sun, 04 May 2008) $
8 ##############################################################################
10 # Self-compliance tests
15 use English qw( -no_match_vars );
20 use Perl::Critic::Utils qw{ :characters };
21 use Perl::Critic::TestUtils qw{ starting_points_including_examples };
23 # Note: "use PolicyFactory" *must* appear after "use TestUtils" for the
24 # -extra-test-policies option to work.
25 use Perl::Critic::PolicyFactory (
27 '-extra-test-policies' => [ qw{ ErrorHandling::RequireUseOfExceptions } ],
30 #-----------------------------------------------------------------------------
32 eval { require Test::Perl::Critic; };
33 plan skip_all => 'Test::Perl::Critic required to criticise code' if $EVAL_ERROR;
35 #-----------------------------------------------------------------------------
37 eval { require Perl::Critic::Policy::ErrorHandling::RequireUseOfExceptions; };
39 'ErrorHandling::RequireUseOfExceptions policy required to criticise code.'
40 . ' This policy is part of the Perl::Critic::More distribution.'
43 #-----------------------------------------------------------------------------
44 # Set up PPI caching for speed (used primarily during development)
46 if ( $ENV{PERL_CRITIC_CACHE} ) {
51 "test-perl-critic-cache-$ENV{USER}",
53 if ( ! -d $cache_path) {
54 mkdir $cache_path, oct 700;
56 PPI::Cache->import( path => $cache_path );
59 #-----------------------------------------------------------------------------
60 # Strict object testing -- prevent direct hash key access
62 eval { require Devel::EnforceEncapsulation; };
64 for my $pkg ( $EMPTY, '::Config', '::Policy', '::Violation' ) {
65 Devel::EnforceEncapsulation->apply_to('Perl::Critic'.$pkg);
71 'You should install Devel::EnforceEncapsulation, but other tests '
76 #-----------------------------------------------------------------------------
77 # Run critic against all of our own files
79 my $rcfile = File::Spec->catfile( 'xt', 'author', '40_perlcriticrc-code' );
80 Test::Perl::Critic->import( -profile => $rcfile );
82 all_critic_ok( starting_points_including_examples() );
84 #-----------------------------------------------------------------------------
88 # cperl-indent-level: 4
90 # indent-tabs-mode: nil
91 # c-indentation-style: bsd
93 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :