Bug 33743: Make xt/find-missing-filters.t and xt/single_quotes.t check directories in git index only
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
f1b75d49bb
commit
09c0c2c876
2 changed files with 27 additions and 55 deletions
|
@ -17,40 +17,23 @@
|
|||
|
||||
use Modern::Perl;
|
||||
use Test::More tests => 1;
|
||||
use File::Find;
|
||||
use File::Slurp;
|
||||
use File::Slurp qw( read_file );
|
||||
use Data::Dumper;
|
||||
use t::lib::QA::TemplateFilters;
|
||||
|
||||
my @themes;
|
||||
|
||||
# OPAC themes
|
||||
my $opac_dir = 'koha-tmpl/opac-tmpl';
|
||||
opendir ( my $dh, $opac_dir ) or die "can't opendir $opac_dir: $!";
|
||||
for my $theme ( grep { not /^\.|lib|js|xslt/ } readdir($dh) ) {
|
||||
push @themes, "$opac_dir/$theme/en";
|
||||
}
|
||||
close $dh;
|
||||
|
||||
# STAFF themes
|
||||
my $staff_dir = 'koha-tmpl/intranet-tmpl';
|
||||
opendir ( $dh, $staff_dir ) or die "can't opendir $staff_dir: $!";
|
||||
for my $theme ( grep { not /^\.|lib|js/ } readdir($dh) ) {
|
||||
push @themes, "$staff_dir/$theme/en";
|
||||
}
|
||||
close $dh;
|
||||
|
||||
my @files;
|
||||
sub wanted {
|
||||
my $name = $File::Find::name;
|
||||
push @files, $name
|
||||
if $name =~ m[\.(tt|inc)$] and -f $name;
|
||||
}
|
||||
|
||||
find({ wanted => \&wanted, no_chdir => 1 }, @themes );
|
||||
# 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 @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;
|
||||
|
|
|
@ -19,39 +19,28 @@
|
|||
|
||||
use Modern::Perl;
|
||||
use Test::More tests => 1;
|
||||
use File::Find;
|
||||
|
||||
my @themes;
|
||||
|
||||
# OPAC themes
|
||||
my $opac_dir = 'koha-tmpl/opac-tmpl';
|
||||
opendir ( my $dh, $opac_dir ) or die "can't opendir $opac_dir: $!";
|
||||
for my $theme ( grep { not /^\.|lib|js|xslt/ } readdir($dh) ) {
|
||||
push @themes, "$opac_dir/$theme/en";
|
||||
}
|
||||
close $dh;
|
||||
|
||||
# STAFF themes
|
||||
my $staff_dir = 'koha-tmpl/intranet-tmpl';
|
||||
opendir ( $dh, $staff_dir ) or die "can't opendir $staff_dir: $!";
|
||||
for my $theme ( grep { not /^\.|lib|js/ } readdir($dh) ) {
|
||||
push @themes, "$staff_dir/$theme/en";
|
||||
}
|
||||
close $dh;
|
||||
use File::Slurp qw( read_file );
|
||||
|
||||
my @files;
|
||||
find(
|
||||
sub {
|
||||
open my $fh, '<', $_ or die "Could not open $_: $!";
|
||||
my @lines = sort grep /\_\(\'/, <$fh>;
|
||||
push @files, { name => "$_", lines => \@lines } if @lines;
|
||||
},
|
||||
@themes
|
||||
);
|
||||
|
||||
ok( !@files, "Files do not contain single quotes _(' " )
|
||||
# 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 @errors;
|
||||
for my $file ( @files ) {
|
||||
chomp $file;
|
||||
my @lines = sort grep /\_\(\'/, read_file($file);
|
||||
push @errors, { name => $file, lines => \@lines } if @lines;
|
||||
}
|
||||
|
||||
ok( !@errors, "Files do not contain single quotes _(' " )
|
||||
or diag(
|
||||
"Files list: \n",
|
||||
join( "\n",
|
||||
map { $_->{name} . ': ' . join( ', ', @{ $_->{lines} } ) } @files )
|
||||
map { $_->{name} . ': ' . join( ', ', @{ $_->{lines} } ) } @errors )
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue