[Koha-patches] [PATCH] Bug 5485: Add script to run Test::Perl::Critic

Colin Campbell colin.campbell at ptfs-europe.com
Mon Dec 13 12:28:20 CET 2010


Tests are run if TEST_QA environment variable is set
and Test::Perl::Critic is installed
e.g.
TEST_QA=1 prove =l t/00-testcritic.t
---
 t/00-testcritic.t |   37 +++++++++++++++++++++++++++++++++++++
 t/perlcriticrc    |    1 +
 2 files changed, 38 insertions(+), 0 deletions(-)
 create mode 100755 t/00-testcritic.t
 create mode 100644 t/perlcriticrc

diff --git a/t/00-testcritic.t b/t/00-testcritic.t
new file mode 100755
index 0000000..65f2288
--- /dev/null
+++ b/t/00-testcritic.t
@@ -0,0 +1,37 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+
+# This script can be used to run perlcritic on perl files in koha
+# It calls its own custom perlcriticrc
+# The script is purely optional requiring Test::Perl::Critic to be installed 
+# and the environment variable TEST_QA to be set
+# At present only the directories in @dirs will pass the tests in 'Gentle' mode
+
+use File::Spec;
+use Test::More;
+use English qw(-no_match_vars);
+
+my @all_koha_dirs = qw( acqui admin authorities basket C4 catalogue cataloguing circ debian errors
+labels members misc offline_circ opac patroncards reports reserve reviews rotating_collections
+serials sms suggestion t tags test tools virtualshelves);
+
+my @dirs = qw( basket circ debian errors offline_circ reserve reviews rotating_collections
+serials sms virtualshelves );
+
+if ( not $ENV{TEST_QA} ) {
+    my $msg = 'Author test. Set $ENV{TEST_QA} to a true value to run';
+    plan( skip_all => $msg );
+}
+
+eval { require Test::Perl::Critic; };
+
+if ( $EVAL_ERROR ) {
+    my $msg = 'Test::Perl::Critic required to criticise code,';
+    plan( skip_all => $msg );
+}
+
+my $rcfile = File::Spec->catfile( 't', 'perlcriticrc' );
+Test::Perl::Critic->import( -profile => $rcfile);
+all_critic_ok(@dirs);
+
diff --git a/t/perlcriticrc b/t/perlcriticrc
new file mode 100644
index 0000000..53a34a6
--- /dev/null
+++ b/t/perlcriticrc
@@ -0,0 +1 @@
+exclude = Miscellanea::RequireRcsKeywords
-- 
1.7.3.3



More information about the Koha-patches mailing list