Modified source files and compiled any and armel versions of packages
[pkg-perl] / deb-src / libperl-critic-perl / libperl-critic-perl-1.088 / xt / author / 40_criticize-code.t
1 #!perl
2
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) $
6 #   $Author: clonezone $
7 # $Revision: 2319 $
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 use Test::More;
19
20 use Perl::Critic::Utils qw{ :characters };
21 use Perl::Critic::TestUtils qw{ starting_points_including_examples };
22
23 # Note: "use PolicyFactory" *must* appear after "use TestUtils" for the
24 # -extra-test-policies option to work.
25 use Perl::Critic::PolicyFactory (
26     '-test' => 1,
27     '-extra-test-policies' => [ qw{ ErrorHandling::RequireUseOfExceptions } ],
28 );
29
30 #-----------------------------------------------------------------------------
31
32 eval { require Test::Perl::Critic; };
33 plan skip_all => 'Test::Perl::Critic required to criticise code' if $EVAL_ERROR;
34
35 #-----------------------------------------------------------------------------
36
37 eval { require Perl::Critic::Policy::ErrorHandling::RequireUseOfExceptions; };
38 plan skip_all =>
39     'ErrorHandling::RequireUseOfExceptions policy required to criticise code.'
40         . ' This policy is part of the Perl::Critic::More distribution.'
41     if $EVAL_ERROR;
42
43 #-----------------------------------------------------------------------------
44 # Set up PPI caching for speed (used primarily during development)
45
46 if ( $ENV{PERL_CRITIC_CACHE} ) {
47     require PPI::Cache;
48     my $cache_path =
49         File::Spec->catdir(
50             File::Spec->tmpdir,
51             "test-perl-critic-cache-$ENV{USER}",
52         );
53     if ( ! -d $cache_path) {
54         mkdir $cache_path, oct 700;
55     }
56     PPI::Cache->import( path => $cache_path );
57 }
58
59 #-----------------------------------------------------------------------------
60 # Strict object testing -- prevent direct hash key access
61
62 eval { require Devel::EnforceEncapsulation; };
63 if ( !$EVAL_ERROR ) {
64     for my $pkg ( $EMPTY, '::Config', '::Policy', '::Violation' ) {
65         Devel::EnforceEncapsulation->apply_to('Perl::Critic'.$pkg);
66     }
67 }
68 else {
69     diag($EMPTY);
70     diag(
71         'You should install Devel::EnforceEncapsulation, but other tests '
72             . 'will still run.'
73     );
74 }
75
76 #-----------------------------------------------------------------------------
77 # Run critic against all of our own files
78
79 my $rcfile = File::Spec->catfile( 'xt', 'author', '40_perlcriticrc-code' );
80 Test::Perl::Critic->import( -profile => $rcfile );
81
82 all_critic_ok( starting_points_including_examples() );
83
84 #-----------------------------------------------------------------------------
85
86 # Local Variables:
87 #   mode: cperl
88 #   cperl-indent-level: 4
89 #   fill-column: 78
90 #   indent-tabs-mode: nil
91 #   c-indentation-style: bsd
92 # End:
93 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :