Bug 39876: Apply module to other tests
We are ready to reuse Koha::Devel::Files in other places where
`git ls-files` is used.
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 48263039af)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
parent
32ccc7b61c
commit
655daf7b9e
|
|
@ -30,13 +30,58 @@ The module defines a set of exceptions for different file types and contexts. Th
|
|||
=cut
|
||||
|
||||
my $exceptions = {
|
||||
pl => { tidy => [qw(Koha/Schema/Result Koha/Schema.pm)] },
|
||||
pl => {
|
||||
tidy => [
|
||||
qw(
|
||||
Koha/Schema/Result
|
||||
Koha/Schema.pm
|
||||
)
|
||||
],
|
||||
valid => [
|
||||
qw(
|
||||
Koha/Account/Credit.pm
|
||||
Koha/Account/Debit.pm
|
||||
Koha/Old/Hold.pm
|
||||
misc/translator/TmplTokenizer.pm
|
||||
)
|
||||
],
|
||||
codespell => [
|
||||
qw(
|
||||
installer/data/mysql/updatedatabase.pl
|
||||
installer/data/mysql/update22to30.pl
|
||||
installer/data/mysql/db_revs/241200035.pl
|
||||
misc/cronjobs/build_browser_and_cloud.pl
|
||||
)
|
||||
],
|
||||
},
|
||||
js => {
|
||||
tidy => [
|
||||
qw(koha-tmpl/intranet-tmpl/lib koha-tmpl/intranet-tmpl/js/Gettext.js koha-tmpl/opac-tmpl/lib Koha/ILL/Backend/)
|
||||
]
|
||||
qw(
|
||||
koha-tmpl/intranet-tmpl/lib
|
||||
koha-tmpl/intranet-tmpl/js/Gettext.js
|
||||
koha-tmpl/opac-tmpl/lib
|
||||
Koha/ILL/Backend/
|
||||
)
|
||||
],
|
||||
codespell => [
|
||||
qw(
|
||||
koha-tmpl/intranet-tmpl/lib
|
||||
koha-tmpl/intranet-tmpl/js/Gettext.js
|
||||
koha-tmpl/opac-tmpl/lib
|
||||
koha-tmpl/opac-tmpl/bootstrap/js/Gettext.js
|
||||
)
|
||||
],
|
||||
},
|
||||
tt => {
|
||||
tidy => [
|
||||
qw(
|
||||
Koha/ILL/Backend/
|
||||
*doc-head-open.inc
|
||||
misc/cronjobs/rss
|
||||
)
|
||||
],
|
||||
codespell => [],
|
||||
},
|
||||
tt => { tidy => [qw(Koha/ILL/Backend/ *doc-head-open.inc misc/cronjobs/rss)] },
|
||||
};
|
||||
|
||||
=head1 METHODS
|
||||
|
|
|
|||
|
|
@ -3,24 +3,23 @@ use Modern::Perl;
|
|||
use Test::PerlTidy;
|
||||
use Test::More;
|
||||
|
||||
use Koha::Devel::Files;
|
||||
|
||||
my $codespell_version = qx{codespell --version};
|
||||
chomp $codespell_version;
|
||||
$codespell_version =~ s/-.*$//;
|
||||
if ( ( $codespell_version =~ s/\.//gr ) < 220 ) { # if codespell < 2.2.0
|
||||
plan skip_all => "codespell version $codespell_version too low, need at least 2.2.0";
|
||||
}
|
||||
my $dev_files = Koha::Devel::Files->new( { context => 'codespell' } );
|
||||
my @files;
|
||||
push @files,
|
||||
qx{git ls-files '*.pl' '*.PL' '*.pm' '*.t' ':(exclude)installer/data/mysql/updatedatabase.pl' ':(exclude)installer/data/mysql/update22to30.pl' ':(exclude)installer/data/mysql/db_revs/241200035.pl' ':(exclude)misc/cronjobs/build_browser_and_cloud.pl'};
|
||||
push @files, qx{git ls-files svc opac/svc}; # Files without extension
|
||||
push @files, qx{git ls-files '*.tt' '*.inc'};
|
||||
push @files,
|
||||
qx{git ls-files '*.js' '*.ts' '*.vue' ':(exclude)koha-tmpl/intranet-tmpl/lib' ':(exclude)koha-tmpl/intranet-tmpl/js/Gettext.js' ':(exclude)koha-tmpl/opac-tmpl/lib' ':(exclude)koha-tmpl/opac-tmpl/bootstrap/js/Gettext.js'};
|
||||
push @files, $dev_files->ls_perl_files;
|
||||
push @files, $dev_files->ls_tt_files;
|
||||
push @files, $dev_files->ls_js_files;
|
||||
|
||||
plan tests => scalar @files;
|
||||
|
||||
for my $file (@files) {
|
||||
chomp $file;
|
||||
my $output = qx{codespell -d --ignore-words .codespell-ignore $file};
|
||||
chomp $output;
|
||||
is( $output, q{} );
|
||||
|
|
|
|||
|
|
@ -4,11 +4,10 @@ use Modern::Perl;
|
|||
use Test::More;
|
||||
use Test::NoWarnings;
|
||||
use Pod::Checker;
|
||||
use Koha::Devel::Files;
|
||||
|
||||
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 $dev_files = Koha::Devel::Files->new;
|
||||
my @files = $dev_files->ls_perl_files;
|
||||
|
||||
plan tests => scalar @files + 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ use Modern::Perl;
|
|||
use Test::More;
|
||||
use Test::Pod;
|
||||
|
||||
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;
|
||||
use Koha::Devel::Files;
|
||||
|
||||
my $dev_files = Koha::Devel::Files->new;
|
||||
my @files = $dev_files->ls_perl_files;
|
||||
|
||||
all_pod_files_ok(@files);
|
||||
|
|
|
|||
|
|
@ -22,20 +22,15 @@ use Test::More tests => 2;
|
|||
use File::Slurp;
|
||||
use Data::Dumper;
|
||||
|
||||
my @files;
|
||||
use Koha::Devel::Files;
|
||||
|
||||
# OPAC
|
||||
push @files, `git ls-files 'koha-tmpl/opac-tmpl/bootstrap/en/*.tt'`;
|
||||
push @files, `git ls-files 'koha-tmpl/opac-tmpl/bootstrap/en/*.inc'`;
|
||||
my $dev_files = Koha::Devel::Files->new;
|
||||
my @files = $dev_files->ls_tt_files;
|
||||
|
||||
# Staff
|
||||
push @files, `git ls-files 'koha-tmpl/intranet-tmpl/prog/en/*.tt'`;
|
||||
push @files, `git ls-files 'koha-tmpl/intranet-tmpl/prog/en/*.inc'`;
|
||||
ok( @files > 0, 'We should test something' );
|
||||
|
||||
my @errors;
|
||||
for my $file (@files) {
|
||||
chomp $file;
|
||||
my @e = check_csrf_in_forms($file);
|
||||
push @errors, sprintf "%s:%s", $file, join( ",", @e ) if @e;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,21 +20,15 @@ use Test::More tests => 2;
|
|||
use File::Slurp qw( read_file );
|
||||
use Data::Dumper;
|
||||
use t::lib::QA::TemplateFilters;
|
||||
use Koha::Devel::Files;
|
||||
|
||||
my @files;
|
||||
my $dev_files = Koha::Devel::Files->new;
|
||||
my @files = $dev_files->ls_tt_files;
|
||||
|
||||
# OPAC
|
||||
push @files, `git ls-files 'koha-tmpl/opac-tmpl/bootstrap/en/*.tt'`;
|
||||
push @files, `git ls-files 'koha-tmpl/opac-tmpl/bootstrap/en/*.inc'`;
|
||||
|
||||
# Staff
|
||||
push @files, `git ls-files 'koha-tmpl/intranet-tmpl/prog/en/*.tt'`;
|
||||
push @files, `git ls-files 'koha-tmpl/intranet-tmpl/prog/en/*.inc'`;
|
||||
ok( @files > 0, 'We should test something' );
|
||||
|
||||
my @errors;
|
||||
for my $file (@files) {
|
||||
chomp $file;
|
||||
my $content = read_file($file);
|
||||
my @e = t::lib::QA::TemplateFilters::missing_filters($content);
|
||||
push @errors, { file => $file, errors => \@e } if @e;
|
||||
|
|
|
|||
|
|
@ -22,20 +22,14 @@ use Test::More tests => 2;
|
|||
use File::Slurp;
|
||||
use Data::Dumper;
|
||||
|
||||
my @files;
|
||||
use Koha::Devel::Files;
|
||||
|
||||
# OPAC
|
||||
push @files, `git ls-files 'koha-tmpl/opac-tmpl/bootstrap/en/*.tt'`;
|
||||
push @files, `git ls-files 'koha-tmpl/opac-tmpl/bootstrap/en/*.inc'`;
|
||||
|
||||
# Staff
|
||||
push @files, `git ls-files 'koha-tmpl/intranet-tmpl/prog/en/*.tt'`;
|
||||
push @files, `git ls-files 'koha-tmpl/intranet-tmpl/prog/en/*.inc'`;
|
||||
my $dev_files = Koha::Devel::Files->new;
|
||||
my @files = $dev_files->ls_perl_files;
|
||||
ok( @files > 0, 'We should test something' );
|
||||
|
||||
my @errors;
|
||||
for my $file (@files) {
|
||||
chomp $file;
|
||||
my @e = catch_missing_op($file);
|
||||
push @errors, sprintf "%s:%s", $file, join( ",", @e ) if @e;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@ use Modern::Perl;
|
|||
use Test::PerlTidy;
|
||||
use Test::More;
|
||||
|
||||
my @files;
|
||||
push @files, qx{git ls-files '*.pl' '*.PL' '*.pm' '*.t' ':(exclude)Koha/Schema/Result' ':(exclude)Koha/Schema.pm'};
|
||||
push @files, qx{git ls-files svc opac/svc}; # Files without extension
|
||||
use Koha::Devel::Files;
|
||||
|
||||
my $dev_files = Koha::Devel::Files->new( { context => 'tidy' } );
|
||||
my @files = $dev_files->ls_perl_files;
|
||||
|
||||
plan tests => scalar @files;
|
||||
|
||||
for my $file (@files) {
|
||||
chomp $file;
|
||||
ok( Test::PerlTidy::is_file_tidy($file) );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,17 +24,10 @@ 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;
|
||||
use Koha::Devel::Files;
|
||||
|
||||
my @exceptions = qw(
|
||||
Koha/Account/Credit.pm
|
||||
Koha/Account/Debit.pm
|
||||
Koha/Old/Hold.pm
|
||||
misc/translator/TmplTokenizer.pm
|
||||
);
|
||||
my $dev_files = Koha::Devel::Files->new( { context => 'valid' } );
|
||||
my @files = $dev_files->ls_perl_files;
|
||||
|
||||
my $ncpu;
|
||||
if ( $ENV{KOHA_PROVE_CPUS} ) {
|
||||
|
|
@ -48,10 +41,6 @@ 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;
|
||||
|
|
|
|||
|
|
@ -21,20 +21,15 @@ use Modern::Perl;
|
|||
use Test::More tests => 2;
|
||||
use File::Slurp qw( read_file );
|
||||
|
||||
my @files;
|
||||
use Koha::Devel::Files;
|
||||
|
||||
# OPAC
|
||||
push @files, `git ls-files 'koha-tmpl/opac-tmpl/bootstrap/en/*.tt'`;
|
||||
push @files, `git ls-files 'koha-tmpl/opac-tmpl/bootstrap/en/*.inc'`;
|
||||
my $dev_files = Koha::Devel::Files->new;
|
||||
my @files = $dev_files->ls_tt_files;
|
||||
|
||||
# Staff
|
||||
push @files, `git ls-files 'koha-tmpl/intranet-tmpl/prog/en/*.tt'`;
|
||||
push @files, `git ls-files 'koha-tmpl/intranet-tmpl/prog/en/*.inc'`;
|
||||
ok( @files > 0, 'We should test something' );
|
||||
|
||||
my @errors;
|
||||
for my $file (@files) {
|
||||
chomp $file;
|
||||
my @lines = sort grep /\_\(\'/, read_file($file);
|
||||
push @errors, { name => $file, lines => \@lines } if @lines;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,10 @@ use Test::Strict;
|
|||
use Parallel::ForkManager;
|
||||
use Sys::CPU;
|
||||
|
||||
my @tt_files = qx{git ls-files '*.tt' '*.inc'};
|
||||
use Koha::Devel::Files;
|
||||
|
||||
my $dev_files = Koha::Devel::Files->new( { context => 'tidy' } );
|
||||
my @tt_files = $dev_files->ls_perl_files;
|
||||
|
||||
$Test::Strict::TEST_STRICT = 0;
|
||||
|
||||
|
|
@ -39,7 +42,6 @@ my $pm = Parallel::ForkManager->new($ncpu);
|
|||
foreach my $filepath (@tt_files) {
|
||||
$pm->start and next;
|
||||
|
||||
chomp $filepath;
|
||||
my $tidy = qx{perl misc/devel/tidy.pl --silent --no-write $filepath};
|
||||
my $content = read_file $filepath;
|
||||
ok( $content eq $tidy, "$filepath should be kept tidy" );
|
||||
|
|
|
|||
Loading…
Reference in New Issue