You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by si...@apache.org on 2024/08/13 07:29:31 UTC

svn commit: r1919846 - in /spamassassin/trunk: Makefile.PL t/perlcritic.pl

Author: sidney
Date: Tue Aug 13 07:29:31 2024
New Revision: 1919846

URL: http://svn.apache.org/viewvc?rev=1919846&view=rev
Log:
bug 8251 - make Perl::Critic an optional module for testing

Modified:
    spamassassin/trunk/Makefile.PL
    spamassassin/trunk/t/perlcritic.pl

Modified: spamassassin/trunk/Makefile.PL
URL: http://svn.apache.org/viewvc/spamassassin/trunk/Makefile.PL?rev=1919846&r1=1919845&r2=1919846&view=diff
==============================================================================
--- spamassassin/trunk/Makefile.PL (original)
+++ spamassassin/trunk/Makefile.PL Tue Aug 13 07:29:31 2024
@@ -112,7 +112,6 @@ my %makefile = (
     'PREREQ_PM' => {
         'File::Spec'           => 0.8,           # older versions lack some routines we need
         'File::Copy'           => 2.02,          # this version is shipped with 5.005_03, the oldest version known to work
-        'File::Temp'           => 0,             # core module, dependency not needed, here for testing purposes, see bug 8089
         'Pod::Usage'           => 1.10,          # all versions prior to this do seem to be buggy
         'HTML::Parser'         => 3.43,          # the HTML code is based on this parser, older versions have utf-8 bugs
         'Archive::Tar'         => 1.23,          # for sa-update
@@ -139,8 +138,6 @@ my %makefile = (
     # The modules that are not core or that require a minimum version that are used in default tests
     'TEST_REQUIRES' => {
         'Test::Simple' => 1.302067,
-        'Perl::Critic::Policy::TestingAndDebugging::ProhibitNoStrict' => 0,
-        'Perl::Critic::Policy::Perlsecret' => 0,
     },
 
     'LICENSE' => 'apache_2_0',

Modified: spamassassin/trunk/t/perlcritic.pl
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/perlcritic.pl?rev=1919846&r1=1919845&r2=1919846&view=diff
==============================================================================
--- spamassassin/trunk/t/perlcritic.pl (original)
+++ spamassassin/trunk/t/perlcritic.pl Tue Aug 13 07:29:31 2024
@@ -11,22 +11,31 @@ use English qw(-no_match_vars);
 plan skip_all => "This test requires Test::Perl::Critic" unless (eval { require Test::Perl::Critic; 1} );
 plan skip_all => "PerlCritic test cannot run in Taint mode" if (${^TAINT});
 
-open RC, ">../t/log/perlcritic.rc"  or die "cannot create t/log/perlcritic.rc";
+# An exclude entry does not cause a problem if a module it lists is not installed, as it just says to ignore it if it is
+# An explicit section for a module, which is needed for allow entries, will die if the module is not found, so
+# the modules not bundled with Perl::Critic are included in the configuration file conditionally.
 
-# we should remove some of these excludes if/when we feel like fixing 'em!
-print RC q{
+# we should remove some of these excludes/allows if/when we feel like fixing 'em!
 
+my $criticoptions = q{
   severity = 5
   verbose = 9
   exclude = ValuesAndExpressions::ProhibitLeadingZeros InputOutput::ProhibitBarewordDirHandles InputOutput::ProhibitBarewordFileHandles InputOutput::ProhibitTwoArgOpen BuiltinFunctions::ProhibitStringyEval InputOutput::ProhibitInteractiveTest Bangs::ProhibitBitwiseOperators Bangs::ProhibitDebuggingModules Compatibility::ProhibitThreeArgumentOpen Lax::ProhibitStringyEval::ExceptForRequire Lax::ProhibitLeadingZeros::ExceptChmod ValuesAndExpressions::PreventSQLInjection ControlStructures::ProhibitReturnInDoBlock ValuesAndExpressions::ProhibitAccessOfPrivateData Policy::OTRS::
 
   [TestingAndDebugging::ProhibitNoStrict]
   allow = refs
+};
+
+# Conditionally add allow exceptions for Policy modules that are not bundled with Perl::Critic itself
+
+$criticoptions .= q{
 
   [Perlsecret]
   allow_secrets = Venus
+} if (eval { require Perl::Critic::Policy::Perlsecret; 1} );
 
-}  or die "cannot write t/log/perlcritic.rc";
+open RC, ">../t/log/perlcritic.rc"  or die "cannot create t/log/perlcritic.rc";
+print RC $criticoptions or die "cannot write t/log/perlcritic.rc";
 close RC  or die "cannot close t/log/perlcritic.rc";
 
 Test::Perl::Critic->import( -profile => "../t/log/perlcritic.rc" );