|
Packit |
e6c7a3 |
# Configuration for Perl test cases.
|
|
Packit |
e6c7a3 |
#
|
|
Packit |
e6c7a3 |
# In order to reuse the same Perl test cases in multiple packages, I use a
|
|
Packit |
e6c7a3 |
# configuration file to store some package-specific data. This module loads
|
|
Packit |
e6c7a3 |
# that configuration and provides the namespace for the configuration
|
|
Packit |
e6c7a3 |
# settings.
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
package Test::RRA::Config;
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
use 5.006;
|
|
Packit |
e6c7a3 |
use strict;
|
|
Packit |
e6c7a3 |
use warnings;
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
# For Perl 5.006 compatibility.
|
|
Packit |
e6c7a3 |
## no critic (ClassHierarchies::ProhibitExplicitISA)
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
use Exporter;
|
|
Packit |
e6c7a3 |
use Test::More;
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
# Declare variables that should be set in BEGIN for robustness.
|
|
Packit |
e6c7a3 |
our (@EXPORT_OK, @ISA, $VERSION);
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
# Set $VERSION and everything export-related in a BEGIN block for robustness
|
|
Packit |
e6c7a3 |
# against circular module loading (not that we load any modules, but
|
|
Packit |
e6c7a3 |
# consistency is good).
|
|
Packit |
e6c7a3 |
BEGIN {
|
|
Packit |
e6c7a3 |
@ISA = qw(Exporter);
|
|
Packit |
e6c7a3 |
@EXPORT_OK = qw(
|
|
Packit |
e6c7a3 |
$COVERAGE_LEVEL @COVERAGE_SKIP_TESTS @CRITIC_IGNORE $LIBRARY_PATH
|
|
Packit |
e6c7a3 |
$MINIMUM_VERSION %MINIMUM_VERSION @MODULE_VERSION_IGNORE
|
|
Packit |
e6c7a3 |
@POD_COVERAGE_EXCLUDE @STRICT_IGNORE @STRICT_PREREQ
|
|
Packit |
e6c7a3 |
);
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
# This version should match the corresponding rra-c-util release, but with
|
|
Packit |
e6c7a3 |
# two digits for the minor version, including a leading zero if necessary,
|
|
Packit |
e6c7a3 |
# so that it will sort properly.
|
|
Packit |
e6c7a3 |
$VERSION = '6.02';
|
|
Packit |
e6c7a3 |
}
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
# If C_TAP_BUILD or C_TAP_SOURCE are set in the environment, look for
|
|
Packit |
e6c7a3 |
# data/perl.conf under those paths for a C Automake package. Otherwise, look
|
|
Packit |
e6c7a3 |
# in t/data/perl.conf for a standalone Perl module or tests/data/perl.conf for
|
|
Packit |
e6c7a3 |
# Perl tests embedded in a larger distribution. Don't use Test::RRA::Automake
|
|
Packit |
e6c7a3 |
# since it may not exist.
|
|
Packit |
e6c7a3 |
our $PATH;
|
|
Packit |
e6c7a3 |
for my $base ($ENV{C_TAP_BUILD}, $ENV{C_TAP_SOURCE}, './t', './tests') {
|
|
Packit |
e6c7a3 |
next if !defined($base);
|
|
Packit |
e6c7a3 |
my $path = "$base/data/perl.conf";
|
|
Packit |
e6c7a3 |
if (-r $path) {
|
|
Packit |
e6c7a3 |
$PATH = $path;
|
|
Packit |
e6c7a3 |
last;
|
|
Packit |
e6c7a3 |
}
|
|
Packit |
e6c7a3 |
}
|
|
Packit |
e6c7a3 |
if (!defined($PATH)) {
|
|
Packit |
e6c7a3 |
BAIL_OUT('cannot find data/perl.conf');
|
|
Packit |
e6c7a3 |
}
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
# Pre-declare all of our variables and set any defaults.
|
|
Packit |
e6c7a3 |
our $COVERAGE_LEVEL = 100;
|
|
Packit |
e6c7a3 |
our @COVERAGE_SKIP_TESTS;
|
|
Packit |
e6c7a3 |
our @CRITIC_IGNORE;
|
|
Packit |
e6c7a3 |
our $LIBRARY_PATH;
|
|
Packit |
e6c7a3 |
our $MINIMUM_VERSION = '5.008';
|
|
Packit |
e6c7a3 |
our %MINIMUM_VERSION;
|
|
Packit |
e6c7a3 |
our @MODULE_VERSION_IGNORE;
|
|
Packit |
e6c7a3 |
our @POD_COVERAGE_EXCLUDE;
|
|
Packit |
e6c7a3 |
our @STRICT_IGNORE;
|
|
Packit |
e6c7a3 |
our @STRICT_PREREQ;
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
# Load the configuration.
|
|
Packit |
e6c7a3 |
if (!do($PATH)) {
|
|
Packit |
e6c7a3 |
my $error = $@ || $! || 'loading file did not return true';
|
|
Packit |
e6c7a3 |
BAIL_OUT("cannot load $PATH: $error");
|
|
Packit |
e6c7a3 |
}
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
1;
|
|
Packit |
e6c7a3 |
__END__
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
=for stopwords
|
|
Packit |
e6c7a3 |
Allbery rra-c-util Automake perlcritic .libs namespace subdirectory sublicense
|
|
Packit |
e6c7a3 |
MERCHANTABILITY NONINFRINGEMENT regexes
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
=head1 NAME
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
Test::RRA::Config - Perl test configuration
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
=head1 SYNOPSIS
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
use Test::RRA::Config qw($MINIMUM_VERSION);
|
|
Packit |
e6c7a3 |
print "Required Perl version is $MINIMUM_VERSION\n";
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
=head1 DESCRIPTION
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
Test::RRA::Config encapsulates per-package configuration for generic Perl test
|
|
Packit |
e6c7a3 |
programs that are shared between multiple packages using the rra-c-util
|
|
Packit |
e6c7a3 |
infrastructure. It handles locating and loading the test configuration file
|
|
Packit |
e6c7a3 |
for both C Automake packages and stand-alone Perl modules.
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
Test::RRA::Config looks for a file named F<data/perl.conf> relative to the
|
|
Packit |
e6c7a3 |
root of the test directory. That root is taken from the environment variables
|
|
Packit |
e6c7a3 |
C_TAP_BUILD or C_TAP_SOURCE (in that order) if set, which will be the case for
|
|
Packit |
e6c7a3 |
C Automake packages using C TAP Harness. If neither is set, it expects the
|
|
Packit |
e6c7a3 |
root of the test directory to be a directory named F<t> relative to the
|
|
Packit |
e6c7a3 |
current directory, which will be the case for stand-alone Perl modules.
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
The following variables are supported:
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
=over 4
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
=item $COVERAGE_LEVEL
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
The coverage level achieved by the test suite for Perl test coverage testing
|
|
Packit |
e6c7a3 |
using Test::Strict, as a percentage. The test will fail if test coverage less
|
|
Packit |
e6c7a3 |
than this percentage is achieved. If not given, defaults to 100.
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
=item @COVERAGE_SKIP_TESTS
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
Directories under F<t> whose tests should be skipped when doing coverage
|
|
Packit |
e6c7a3 |
testing. This can be tests that won't contribute to coverage or tests that
|
|
Packit |
e6c7a3 |
don't run properly under Devel::Cover for some reason (such as ones that use
|
|
Packit |
e6c7a3 |
taint checking). F<docs> and F<style> will always be skipped regardless of
|
|
Packit |
e6c7a3 |
this setting.
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
=item @CRITIC_IGNORE
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
Additional directories to ignore when doing recursive perlcritic testing. The
|
|
Packit |
e6c7a3 |
contents of this directory must be either top-level directory names or
|
|
Packit |
e6c7a3 |
directory names starting with F<tests/>.
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
=item $LIBRARY_PATH
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
Add this directory (or a F<.libs> subdirectory) relative to the top of the
|
|
Packit |
e6c7a3 |
source tree to LD_LIBRARY_PATH when checking the syntax of Perl modules. This
|
|
Packit |
e6c7a3 |
may be required to pick up libraries that are used by in-tree Perl modules so
|
|
Packit |
e6c7a3 |
that Perl scripts can pass a syntax check.
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
=item $MINIMUM_VERSION
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
Default minimum version requirement for included Perl scripts. If not given,
|
|
Packit |
e6c7a3 |
defaults to 5.008.
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
=item %MINIMUM_VERSION
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
Minimum version exceptions for specific directories. The keys should be
|
|
Packit |
e6c7a3 |
minimum versions of Perl to enforce. The value for each key should be a
|
|
Packit |
e6c7a3 |
reference to an array of either top-level directory names or directory names
|
|
Packit |
e6c7a3 |
starting with F<tests/>. All files in those directories will have that
|
|
Packit |
e6c7a3 |
minimum Perl version constraint imposed instead of $MINIMUM_VERSION.
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
=item @MODULE_VERSION_IGNORE
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
File names to ignore when checking that all modules in a distribution have the
|
|
Packit |
e6c7a3 |
same version. Sometimes, some specific modules need separate, special version
|
|
Packit |
e6c7a3 |
handling, such as modules defining database schemata for DBIx::Class, and
|
|
Packit |
e6c7a3 |
can't follow the version of the larger package.
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
=item @POD_COVERAGE_EXCLUDE
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
Regexes that match method names that should be excluded from POD coverage
|
|
Packit |
e6c7a3 |
testing. Normally, all methods have to be documented in the POD for a Perl
|
|
Packit |
e6c7a3 |
module, but methods matching any of these regexes will be considered private
|
|
Packit |
e6c7a3 |
and won't require documentation.
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
=item @STRICT_IGNORE
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
Additional directories to ignore when doing recursive Test::Strict testing for
|
|
Packit |
e6c7a3 |
C<use strict> and C<use warnings>. The contents of this directory must be
|
|
Packit |
e6c7a3 |
either top-level directory names or directory names starting with F<tests/>.
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
=item @STRICT_PREREQ
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
A list of Perl modules that have to be available in order to do meaningful
|
|
Packit |
e6c7a3 |
Test::Strict testing. If any of the modules cannot be loaded via C<use>,
|
|
Packit |
e6c7a3 |
Test::Strict checking will be skipped. There is currently no way to require
|
|
Packit |
e6c7a3 |
specific versions of the modules.
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
=back
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
No variables are exported by default, but the variables can be imported into
|
|
Packit |
e6c7a3 |
the local namespace to avoid long variable names.
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
=head1 AUTHOR
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
Russ Allbery <eagle@eyrie.org>
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
=head1 COPYRIGHT AND LICENSE
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
Copyright 2015, 2016 Russ Allbery <eagle@eyrie.org>
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
Copyright 2013, 2014 The Board of Trustees of the Leland Stanford Junior
|
|
Packit |
e6c7a3 |
University
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
Packit |
e6c7a3 |
of this software and associated documentation files (the "Software"), to deal
|
|
Packit |
e6c7a3 |
in the Software without restriction, including without limitation the rights
|
|
Packit |
e6c7a3 |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
Packit |
e6c7a3 |
copies of the Software, and to permit persons to whom the Software is
|
|
Packit |
e6c7a3 |
furnished to do so, subject to the following conditions:
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
The above copyright notice and this permission notice shall be included in all
|
|
Packit |
e6c7a3 |
copies or substantial portions of the Software.
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
Packit |
e6c7a3 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
Packit |
e6c7a3 |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
Packit |
e6c7a3 |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
Packit |
e6c7a3 |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
Packit |
e6c7a3 |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
Packit |
e6c7a3 |
SOFTWARE.
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
=head1 SEE ALSO
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
perlcritic(1), Test::MinimumVersion(3), Test::RRA(3), Test::RRA::Automake(3),
|
|
Packit |
e6c7a3 |
Test::Strict(3)
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
This module is maintained in the rra-c-util package. The current version is
|
|
Packit |
e6c7a3 |
available from L<https://www.eyrie.org/~eagle/software/rra-c-util/>.
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
The C TAP Harness test driver and libraries for TAP-based C testing are
|
|
Packit |
e6c7a3 |
available from L<https://www.eyrie.org/~eagle/software/c-tap-harness/>.
|
|
Packit |
e6c7a3 |
|
|
Packit |
e6c7a3 |
=cut
|