]> eyrie.org Git - kerberos/krb5-strength.git/commitdiff
Skip Perl strictness testing if module prereqs are missing
authorRuss Allbery <eagle@eyrie.org>
Thu, 27 Feb 2014 04:04:54 +0000 (20:04 -0800)
committerRuss Allbery <eagle@eyrie.org>
Thu, 27 Feb 2014 04:04:54 +0000 (20:04 -0800)
Modify the standard Perl strictness test, which also checks Perl
scripts for syntax errors, to support a list of prerequisite
modules.  Skip the test if any of those modules can't be loaded,
since they'll otherwise cause failures.  This makes the testing
more robust given that we have some scripts that require a bunch
of Perl modules not needed by the main package.

tests/data/perl.conf
tests/perl/strict-t
tests/tap/perl/Test/RRA/Config.pm

index 6d91bc937e075bbb2614b215ede0da72ab102811..43db7b482701dd64ee9ec8367e23d1a6d94c3ccb 100644 (file)
@@ -5,6 +5,14 @@
 @CRITIC_IGNORE = qw(cracklib);
 @STRICT_IGNORE = qw(cracklib);
 
+# The Heimdal history implementation uses a bunch of modules, but may not be
+# of interest to all users.  Skip strict testing if its prerequisites aren't
+# installed.
+@STRICT_PREREQ = qw(
+  DB_File::Lock Crypt::PBKDF2 Getopt::Long::Descriptive IPC::Run JSON
+  Readonly
+);
+
 # Default minimum version requirement for included Perl scripts.
 $MINIMUM_VERSION = '5.010';
 
index 6bac75f71c51b375582f362eb8524d7856a0ee7c..8085afadf08b39fcc707260b545afe517a9248ff 100755 (executable)
@@ -12,7 +12,7 @@
 # which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
 #
 # Written by Russ Allbery <eagle@eyrie.org>
-# Copyright 2012, 2013
+# Copyright 2012, 2013, 2014
 #     The Board of Trustees of the Leland Stanford Junior University
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
@@ -42,11 +42,17 @@ use lib "$ENV{SOURCE}/tap/perl";
 use Test::More;
 use Test::RRA qw(use_prereq);
 use Test::RRA::Automake qw(automake_setup perl_dirs);
-use Test::RRA::Config qw(@STRICT_IGNORE);
+use Test::RRA::Config qw(@STRICT_IGNORE @STRICT_PREREQ);
 
 # Load prerequisite modules.
 use_prereq('Test::Strict');
 
+# Check whether all prerequisites are available, and skip the test if any of
+# them are not.
+for my $module (@STRICT_PREREQ) {
+    use_prereq($module);
+}
+
 # Set up Automake testing.  This must be done after loading Test::Strict,
 # since it wants to use FindBin to locate this script.
 automake_setup();
index 106cc6eed3e21361fe52389c8ed1929cba3a14d7..ce7b1f5bf0608041067b692ba8f0331f93dc422e 100644 (file)
@@ -31,6 +31,7 @@ BEGIN {
     @EXPORT_OK = qw(
       $COVERAGE_LEVEL @COVERAGE_SKIP_TESTS @CRITIC_IGNORE $LIBRARY_PATH
       $MINIMUM_VERSION %MINIMUM_VERSION @POD_COVERAGE_EXCLUDE @STRICT_IGNORE
+      @STRICT_PREREQ
     );
 
     # This version should match the corresponding rra-c-util release, but with
@@ -65,6 +66,7 @@ our $MINIMUM_VERSION = '5.008';
 our %MINIMUM_VERSION;
 our @POD_COVERAGE_EXCLUDE;
 our @STRICT_IGNORE;
+our @STRICT_PREREQ;
 
 # Load the configuration.
 if (!do($PATH)) {
@@ -163,6 +165,13 @@ for C<use strict> and C<use warnings>.  The contents of this directory
 must be either top-level directory names or directory names starting with
 F<tests/>.
 
+=item @STRICT_PREREQ
+
+A list of Perl modules that have to be available in order to do meaningful
+Test::Strict testing.  If any of the modules cannot be loaded via C<use>,
+Test::Strict checking will be skipped.  There is currently no way to
+require specific versions of the modules.
+
 =back
 
 No variables are exported by default, but the variables can be imported
@@ -174,7 +183,7 @@ Russ Allbery <eagle@eyrie.org>
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2013 The Board of Trustees of the Leland Stanford Junior
+Copyright 2013, 2014 The Board of Trustees of the Leland Stanford Junior
 University
 
 Permission is hereby granted, free of charge, to any person obtaining a