| File: | t/00-testcritic.t |
| Coverage: | 70.3% |
| line | stmt | bran | cond | sub | time | code |
|---|---|---|---|---|---|---|
| 1 | #!/usr/bin/env perl | |||||
| 2 | 1 1 1 | 1.33283514705018e+15 2 26 | use strict; | |||
| 3 | 1 1 1 | 5 1 36 | use warnings; | |||
| 4 | ||||||
| 5 | # This script can be used to run perlcritic on perl files in koha | |||||
| 6 | # It calls its own custom perlcriticrc | |||||
| 7 | # The script is purely optional requiring Test::Perl::Critic to be installed | |||||
| 8 | # and the environment variable TEST_QA to be set | |||||
| 9 | # At present only the directories in @dirs will pass the tests in 'Gentle' mode | |||||
| 10 | ||||||
| 11 | 1 1 1 | 4 2 17 | use File::Spec; | |||
| 12 | 1 1 1 | 60984 450960 13 | use Test::More; | |||
| 13 | 1 1 1 | 93545 78585 11 | use English qw(-no_match_vars); | |||
| 14 | ||||||
| 15 | 1 | 210577 | my @all_koha_dirs = qw( acqui admin authorities basket C4 catalogue cataloguing circ debian errors | |||
| 16 | labels members misc offline_circ opac patroncards reports reserve reviews rotating_collections | |||||
| 17 | serials sms suggestion t tags test tools virtualshelves Koha); | |||||
| 18 | ||||||
| 19 | 1 | 9 | my @dirs = qw( acqui admin authorities basket catalogue cataloguing circ debian errors labels | |||
| 20 | offline_circ reserve reviews rotating_collections serials sms virtualshelves Koha); | |||||
| 21 | ||||||
| 22 | 1 | 8 | if ( not $ENV{TEST_QA} ) { | |||
| 23 | 1 | 2 | my $msg = 'Author test. Set $ENV{TEST_QA} to a true value to run'; | |||
| 24 | 1 | 7 | plan( skip_all => $msg ); | |||
| 25 | } | |||||
| 26 | ||||||
| 27 | 0 0 | 0 0 | eval { require Test::Perl::Critic; }; | |||
| 28 | ||||||
| 29 | 0 | 0 | if ( $EVAL_ERROR ) { | |||
| 30 | 0 | 0 | my $msg = 'Test::Perl::Critic required to criticise code,'; | |||
| 31 | 0 | 0 | plan( skip_all => $msg ); | |||
| 32 | } | |||||
| 33 | ||||||
| 34 | 0 | 0 | my $rcfile = File::Spec->catfile( 't', 'perlcriticrc' ); | |||
| 35 | 0 | 0 | Test::Perl::Critic->import( -profile => $rcfile); | |||
| 36 | 0 | 0 | all_critic_ok(@dirs); | |||
| 37 | ||||||