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