From ebd8e4f1692b95bbd0224bf60343219db9b4ce09 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 18 Mar 2026 12:18:13 +0100 Subject: [PATCH] Bug 42126: Make 00-strict.t run strict on all Perl files The current implementation is wrong: * we list explicitly the directories to process and it's not kept up-to-date (eg. booking and Koha are missing). * we should process the files that are in the git repository, and use Koha::Devel::Files to list them. This patch suggests to use git ls-files (through Koha::Devel::Files) and process them one by one. Also only call strict_ok instead of all_perl_files_ok. all_perl_files_ok was doing strict_ok and syntax_ok, but syntax_ok is doing a `perl -c` that is done in xt/pl_valid.t already We can ignore xt and t: the tests are... run by the test suite. On main: Files=1, Tests=1360, 287 wallclock secs ( 0.05 usr 0.02 sys + 1677.26 cusr 268.46 csys = 1945.79 CPU) real 4m46.741 all_perl_files_ok with t and xt: Files=1, Tests=3488, 884 wallclock secs ( 0.10 usr 0.01 sys + 3820.09 cusr 720.63 csys = 4540.83 CPU) real 14m44.086s all_perl_files_ok without t and xt: Files=1, Tests=2666, 586 wallclock secs ( 0.08 usr 0.03 sys + 2261.22 cusr 447.02 csys = 2708.35 CPU) 9m46.519s With this patch (syntax_ok without t and xt): Files=1, Tests=2663, 337 wallclock secs ( 0.09 usr 0.01 sys + 76.18 cusr 70.32 csys = 146.60 CPU) real 5m36.870s Note that Koha/Account/Credit.pm, Koha/Account/Debit.pm and Koha/Old/Hold.pm are failing strict_ok, we ignore them for now: Inconsistent hierarchy during C3 merge of class 'Koha::Account::Credit': current merge results [ Koha::Account::Credit, ] merging failed on 'Koha::Account::Line' at /usr/lib/x86_64-linux-gnu/perl-base/base.pm line 186. BEGIN failed--compilation aborted at Koha/Account/Credit.pm line 22. Signed-off-by: Baptiste Wojtkowski Signed-off-by: Lucas Gass --- Koha/Devel/Files.pm | 9 +++++++++ t/db_dependent/00-strict.t | 33 ++++++++------------------------- 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/Koha/Devel/Files.pm b/Koha/Devel/Files.pm index 3d6911d906..51e81e1cbc 100644 --- a/Koha/Devel/Files.pm +++ b/Koha/Devel/Files.pm @@ -46,6 +46,15 @@ my $exceptions = { misc/translator/TmplTokenizer.pm ) ], + strict => [ + qw( + Koha/Account/Credit.pm + Koha/Account/Debit.pm + Koha/Old/Hold.pm + t + xt + ) + ], codespell => [ qw( installer/data/mysql/updatedatabase.pl diff --git a/t/db_dependent/00-strict.t b/t/db_dependent/00-strict.t index 5a1e47100f..a9127b414b 100755 --- a/t/db_dependent/00-strict.t +++ b/t/db_dependent/00-strict.t @@ -4,34 +4,20 @@ use Modern::Perl; use threads; # used for parallel -use Test::NoWarnings qw( had_no_warnings ); +use Test::NoWarnings; use Test::More; use Test::Strict; use Parallel::ForkManager; use Sys::CPU; +use Koha::Devel::Files; + use lib("misc/translator"); use lib("installer"); -my @dirs = ( - 'acqui', 'admin', - 'authorities', 'basket', - 'catalogue', 'cataloguing', - 'changelanguage.pl', 'circ', - 'debian', 'docs', - 'errors', 'fix-perl-path.PL', 'help.pl', - 'installer', 'kohaversion.pl', 'labels', - 'mainpage.pl', 'Makefile.PL', - 'members', 'misc', - 'offline_circ', 'opac', - 'patroncards', 'reports', - 'reserve', 'reviews', - 'rewrite-config.PL', 'rotating_collections', - 'serials', 'services', - 'skel', 'suggestion', - 'svc', 'tags', - 'tools', 'virtualshelves' -); +my $dev_files = Koha::Devel::Files->new( { context => 'strict' } ); +my @files = $dev_files->ls_perl_files; +plan tests => scalar @files + 1; $Test::Strict::TEST_STRICT = 0; @@ -44,15 +30,12 @@ if ( $ENV{KOHA_PROVE_CPUS} ) { my $pm = Parallel::ForkManager->new($ncpu); -foreach my $d (@dirs) { +foreach my $f (@files) { $pm->start and next; # do the fork - all_perl_files_ok($d); + strict_ok($f); $pm->finish; # do the exit in the child process } $pm->wait_all_children; - -had_no_warnings; -done_testing();