Bug 39365: Add tests
We exclude (for now) some files that needs additional work: 1. Koha/Account/Credit.pm, Koha/Account/Debit.pm and Koha/Old/Hold.pm "Inconsistent hierarchy during C3 merge of class" 2. misc/translator/TmplTokenizer.pm Can't locate VerboseWarnings.pm in @INC We also ignore some known warnings. Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov> Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
ff14f582de
commit
eca3591d74
1 changed files with 83 additions and 0 deletions
83
xt/pl_valid.t
Executable file
83
xt/pl_valid.t
Executable file
|
@ -0,0 +1,83 @@
|
|||
#!/usr/bin/env 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 threads; # used for parallel
|
||||
use Test::More;
|
||||
use Test::NoWarnings;
|
||||
use Pod::Checker;
|
||||
|
||||
use Parallel::ForkManager;
|
||||
use Sys::CPU;
|
||||
|
||||
my @files;
|
||||
push @files, qx{git ls-files '*.pl' '*.PL' '*.pm' '*.t'};
|
||||
push @files, qx{git ls-files svc opac/svc}; # Files without extension
|
||||
chomp for @files;
|
||||
|
||||
my @exceptions = qw(
|
||||
Koha/Account/Credit.pm
|
||||
Koha/Account/Debit.pm
|
||||
Koha/Old/Hold.pm
|
||||
misc/translator/TmplTokenizer.pm
|
||||
);
|
||||
|
||||
my $ncpu;
|
||||
if ( $ENV{KOHA_PROVE_CPUS} ) {
|
||||
$ncpu = $ENV{KOHA_PROVE_CPUS};
|
||||
} else {
|
||||
$ncpu = Sys::CPU::cpu_count();
|
||||
}
|
||||
|
||||
my $pm = Parallel::ForkManager->new($ncpu);
|
||||
|
||||
plan tests => scalar(@files) + 1;
|
||||
|
||||
for my $file (@files) {
|
||||
if ( grep { $file eq $_ } @exceptions ) {
|
||||
pass("$file is skipped - exception");
|
||||
next;
|
||||
}
|
||||
$pm->start and next;
|
||||
my $output = `perl -cw '$file' 2>&1`;
|
||||
chomp $output;
|
||||
if ($?) {
|
||||
fail("$file has syntax errors");
|
||||
diag($output);
|
||||
} elsif ( $output =~ /^$file syntax OK$/ ) {
|
||||
pass("$file passed syntax check");
|
||||
} else {
|
||||
my @fails;
|
||||
for my $line ( split "\n", $output ) {
|
||||
next if $line =~ m{^$file syntax OK$};
|
||||
next if $line =~ m{^Subroutine .* redefined at};
|
||||
next if $line =~ m{^Constant subroutine .* redefined at};
|
||||
|
||||
next if $line =~ m{Name "Lingua::Ispell::path" used only once: possible typo at C4/Tags.pm};
|
||||
push @fails, $line;
|
||||
}
|
||||
if (@fails) {
|
||||
fail("$file has syntax warnings.");
|
||||
diag( join "\n", @fails );
|
||||
} else {
|
||||
pass("$file passed syntax check");
|
||||
}
|
||||
}
|
||||
$pm->finish;
|
||||
}
|
||||
|
||||
$pm->wait_all_children;
|
Loading…
Reference in a new issue