Bug 40444: Add a test to ensure all Perl test files use Test::NoWarnings

This patch adds a new xt test (xt/use-test-no-warnings.t) to make sure
all our Perl test files will use Test::NoWarnings.

It also adds Test::NoWarnings to some files that were missing it and
that didn't need any other changes.

However we still have 7 non-trivial tests that we will consider
exception for now, until they are fixed.

Test plan:
  prove xt/use-test-no-warnings.t
should return green.
And all other tests modified by this patch (the qa script will do that
for you)

You can also test the 2 selenium tests:
1. DROP and CREATE the DB
  DROP DATABASE koha_kohadev;
  CREATE DATABASE koha_kohadev;
  restart_all
2. KOHA_TESTING=1 prove t/db_dependent/selenium/00-onboarding.t
3. Repeat 1
2. KOHA_TESTING=1 prove t/db_dependent/selenium/01-installation.t

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2025-07-18 11:57:57 +02:00 committed by Lucas Gass
parent 64b78fe3c4
commit 63eb2e1f4a
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
20 changed files with 91 additions and 19 deletions

View File

@ -17,7 +17,8 @@
use Modern::Perl;
use Test::More tests => 2;
use Test::More tests => 3;
use Test::NoWarnings;
use Template;
subtest 'test scrubbing using default scrubber' => sub {

View File

@ -1,7 +1,8 @@
#!/usr/bin/perl
use Modern::Perl;
use Test::More tests => 17;
use Test::More tests => 18;
use Test::NoWarnings;
use Test::Exception;
use Try::Tiny;

View File

@ -18,7 +18,8 @@
use Modern::Perl;
use utf8;
use Test::More tests => 8;
use Test::More tests => 9;
use Test::NoWarnings;
use t::lib::TestBuilder;

View File

@ -1,7 +1,8 @@
#!/usr/bin/perl
use Modern::Perl;
use Test::More tests => 3;
use Test::More tests => 4;
use Test::NoWarnings;
use Test::Exception;
use Test::MockModule;

View File

@ -19,7 +19,8 @@
use Modern::Perl;
use Test::More tests => 1;
use Test::More tests => 2;
use Test::NoWarnings;
use C4::AuthoritiesMarc;
use Koha::Authorities;

View File

@ -19,7 +19,8 @@ use Modern::Perl;
use utf8;
use Encode;
use Test::More tests => 6;
use Test::More tests => 7;
use Test::NoWarnings;
use Test::MockModule;
use Test::Exception;
use Test::Warn;

View File

@ -1,6 +1,7 @@
use Modern::Perl;
use Test::More tests => 2;
use Test::More tests => 3;
use Test::NoWarnings;
use Test::Exception;
use t::lib::Mocks;
use Koha::Encryption;

View File

@ -17,7 +17,8 @@
use Modern::Perl;
use Test::More tests => 5;
use Test::More tests => 6;
use Test::NoWarnings;
use Test::MockModule;
use Test::MockObject;

View File

@ -17,7 +17,8 @@
use Modern::Perl;
use Test::More tests => 2;
use Test::More tests => 3;
use Test::NoWarnings;
use Test::MockModule;
use Test::MockObject;

View File

@ -16,7 +16,8 @@
use Modern::Perl;
use File::Basename;
use Test::More tests => 4;
use Test::More tests => 5;
use Test::NoWarnings;
use t::lib::Mocks;
use t::lib::TestBuilder;

View File

@ -16,7 +16,8 @@
use Modern::Perl;
use Test::More tests => 8;
use Test::More tests => 9;
use Test::NoWarnings;
use Test::Warn;
use C4::Overdues qw(CalcFine);

View File

@ -19,7 +19,8 @@
use Modern::Perl;
use Test::More tests => 3;
use Test::More tests => 4;
use Test::NoWarnings;
use Test::Warn;
use Try::Tiny;

View File

@ -71,7 +71,8 @@ post '/public_guarantor' => sub {
}
};
use Test::More tests => 2;
use Test::More tests => 3;
use Test::NoWarnings;
use Test::Mojo;
use t::lib::Mocks;

View File

@ -16,7 +16,8 @@
use Modern::Perl;
use Test::More tests => 32;
use Test::More tests => 33;
use Test::NoWarnings;
use Test::MockModule;
use Test::Warn;

View File

@ -6,7 +6,8 @@ use File::Slurp;
use File::Temp qw(tempdir);
use FindBin qw($Bin);
use Locale::PO;
use Test::More tests => 20;
use Test::More tests => 21;
use Test::NoWarnings;
my $tempdir = tempdir( CLEANUP => 1 );

View File

@ -2,7 +2,8 @@
use Modern::Perl;
use Test::More tests => 2;
use Test::More tests => 3;
use Test::NoWarnings;
use Test::Mojo;
use Koha::Database;

View File

@ -22,7 +22,8 @@
use Modern::Perl;
use Test::More tests => 2;
use Test::More tests => 3;
use Test::NoWarnings;
use t::lib::Selenium;
use C4::Context;

View File

@ -22,7 +22,8 @@
use Modern::Perl;
use Test::More tests => 2;
use Test::More tests => 3;
use Test::NoWarnings;
use t::lib::Selenium;
use C4::Context;

View File

@ -16,7 +16,8 @@
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use Test::More tests => 1;
use Test::More tests => 2;
use Test::NoWarnings;
use C4::Biblio qw(DelBiblio);

53
xt/use-test-no-warnings.t Executable file
View File

@ -0,0 +1,53 @@
#/usr/bin/perl
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use Test::More tests => 2;
use Test::NoWarnings;
use Array::Utils qw( array_minus );
my @t_files = qx{git grep --files-without-match "Test::NoWarnings" 't/*.t'};
chomp for @t_files;
my @exceptions = (
# Cannot be removed
"t/00-testcritic.t",
# bug 40386
"t/Edifact.t",
# bug 40387
"t/db_dependent/Koha/EDI.t",
# bug 40382
"t/db_dependent/Koha/CoverImages.t",
# bug 40442
"t/db_dependent/Koha/MarcOrder.t",
# bug 40375
"t/db_dependent/XISBN.t",
# bug 40443
"t/db_dependent/cronjobs/advance_notices_digest.t",
);
@t_files = array_minus( @t_files, @exceptions );
is( scalar(@t_files), 0, "All Perl test files should contain Test::NoWarnings" )
or diag( sprintf "The following test files should use Test::NoWarnings:\n\t%s", join "\n\t", @t_files );