From 42e471894382aca6af9af82d1f03814d7f49d9dc Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Wed, 26 Feb 2014 20:04:54 -0800 Subject: [PATCH] Skip Perl strictness testing if module prereqs are missing 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 | 8 ++++++++ tests/perl/strict-t | 10 ++++++++-- tests/tap/perl/Test/RRA/Config.pm | 11 ++++++++++- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/tests/data/perl.conf b/tests/data/perl.conf index 6d91bc9..43db7b4 100644 --- a/tests/data/perl.conf +++ b/tests/data/perl.conf @@ -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'; diff --git a/tests/perl/strict-t b/tests/perl/strict-t index 6bac75f..8085afa 100755 --- a/tests/perl/strict-t +++ b/tests/perl/strict-t @@ -12,7 +12,7 @@ # which can be found at . # # Written by Russ Allbery -# 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(); diff --git a/tests/tap/perl/Test/RRA/Config.pm b/tests/tap/perl/Test/RRA/Config.pm index 106cc6e..ce7b1f5 100644 --- a/tests/tap/perl/Test/RRA/Config.pm +++ b/tests/tap/perl/Test/RRA/Config.pm @@ -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 and C. The contents of this directory must be either top-level directory names or directory names starting with F. +=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, +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 =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 -- 2.39.2