diff options
author | Russ Allbery <rra@cpan.org> | 2021-09-10 22:12:43 -0700 |
---|---|---|
committer | Russ Allbery <rra@cpan.org> | 2021-09-10 22:12:43 -0700 |
commit | a761392460e78c8b16f675e8f244dba139f838c0 (patch) | |
tree | 55e0520658f3d734493a87cba17d3c0431ef22f8 | |
parent | 270d10db5354b63c0c605d9cb4291cb9114a84ab (diff) |
Supress Perl::Critic warning for older versions
The rename of Perl::Critic::Freenode to Perl::Critic::Community
requires a workaround in t/style/critic.t to exclude one of the
tags based on its new name if the new module is available.
-rw-r--r-- | t/data/perlcriticrc | 5 | ||||
-rwxr-xr-x | t/style/critic.t | 19 |
2 files changed, 20 insertions, 4 deletions
diff --git a/t/data/perlcriticrc b/t/data/perlcriticrc index e60d616..ff23461 100644 --- a/t/data/perlcriticrc +++ b/t/data/perlcriticrc @@ -68,7 +68,10 @@ allow = unless # Subroutines::RequireFinalReturn, and I prefer the brevity of the simple # return statement. I don't think the empty list versus undef behavior is # that confusing. -[-Community::EmptyReturn] +# +# This has been renamed to Community::EmptyReturn, but excluding it by that +# name produces a warning on systems that only have the older version of the +# package. This is handled in t/style/critic.t specially. [-Freenode::EmptyReturn] # The default of 9 is too small and forces weird code contortions. After some diff --git a/t/style/critic.t b/t/style/critic.t index 5126340..9794b39 100755 --- a/t/style/critic.t +++ b/t/style/critic.t @@ -7,7 +7,7 @@ # files, junk, and any files explicitly configured to be ignored. # # Written by Russ Allbery <eagle@eyrie.org> -# Copyright 2019-2020 Russ Allbery <eagle@eyrie.org> +# Copyright 2019-2021 Russ Allbery <eagle@eyrie.org> # Copyright 2013-2014 # The Board of Trustees of the Leland Stanford Junior University # @@ -53,8 +53,21 @@ use_prereq('Test::Perl::Critic'); # Force the embedded Perl::Tidy check to use the correct configuration. local $ENV{PERLTIDY} = 't/data/perltidyrc'; -# Import the configuration file and run Perl::Critic. -Test::Perl::Critic->import(-profile => 't/data/perlcriticrc'); +# Import the configuration file. +# +# Probe for whether Perl::Critic::Community is installed and use that to +# control whether to pass an exclusion to Perl::Critic. This is the new name +# of Perl::Critic::Freenode, and we have to customize one of our exclusions +# based on its name or we get a spurious warning. +eval { require Perl::Critic::Policy::Community::EmptyReturn }; +if ($@) { + Test::Perl::Critic->import(-profile => 't/data/perlcriticrc'); +} else { + Test::Perl::Critic->import( + -exclude => ['Community::EmptyReturn'], + -profile => 't/data/perlcriticrc', + ); +} # By default, Test::Perl::Critic only checks blib. We also want to check t, # Build.PL, and examples. |