2 # Copyright (C) 2008-2010, Parrot Foundation.
7 t/codingstd/perlcritic.t - use perlcritic for perl coding stds.
12 % prove t/codingstd/perlcritic.t
14 % perl t/codingstd/perlcritic.t [--theme=sometheme]
17 % perl t/codingstd/perlcritic.t src/foo.pl lib/parrot/bar.pm
21 By default, tests all perl source files for some very specific perl coding
24 This test uses a standard perlcriticrc file, located in
25 F<tools/dev/perlcritic.conf>
27 If you wish to run a specific policy, the easiest way to do so is to
28 temporarily add a custom theme to the configuration file and then specify
29 that on the command line to this script.
35 use lib qw( lib ../lib ../../lib );
39 use Parrot::Config qw(%PConfig);
40 use Parrot::Distribution;
43 # There's no point in continuing if we're missing some certain modules, or
44 # if the developer doesn't want to.
46 if (exists $ENV{'PARROT_TEST_NO_PERLCRITIC'}) {
47 give_up('absence of PARROT_TEST_NO_PERLCRITIC environment variable');
50 eval { require Test::Perl::Critic };
52 give_up('Test::Perl::Critic');
55 my $minimum_version = 1.090;
56 if ($Perl::Critic::VERSION < $minimum_version) {
57 give_up("Perl::Critic version $minimum_version");
65 my $config = File::Spec->catfile( $PConfig{build_dir}, qw{tools dev perlcritic.conf} );
67 Test::Perl::Critic->import(
72 my $dist = Parrot::Distribution->new();
77 # We want to skip any language's perl files except those which have declared
78 # they wish to be tested.
79 # As languages are leaving the Parrot repository, there are currently no
80 # languages that want to be tested in the root 'make codetest'.
82 my $languages_dir = File::Spec->catdir( $PConfig{build_dir}, 'languages');
83 my $filter_languages = qr/^\Q$languages_dir$PConfig{slash}\E(?!dummy)/x;
85 @files = grep {! m/$filter_languages/}
87 grep { $_->read !~ m/use v6;/ }
88 grep { $_->read !~ m/#! nqp/ }
89 $dist->get_perl_language_files();
95 plan(tests => scalar(@files));
96 critic_ok($_) foreach @files;
100 plan(skip_all => "$excuse required to criticize code.");
106 # cperl-indent-level: 4
109 # vim: expandtab shiftwidth=4: