Bug 39877: Apply to other slow tests
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
7869584c98
commit
cc58dabe3d
|
|
@ -129,7 +129,7 @@ sub get_files_to_test {
|
|||
@koha_commit_history;
|
||||
if ($last_build_commit) {
|
||||
@files = @{ from_json( read_file("$self->{git_repo_dir}/$self->{test_name}/$last_build_commit") ) };
|
||||
push @files, $dev_files->ls_perl_files("$last_build_commit HEAD");
|
||||
push @files, $dev_files->ls_files( $filetype, "$last_build_commit HEAD" );
|
||||
} else {
|
||||
|
||||
# In case we run on a branch that does not have ancestor commits in the history
|
||||
|
|
@ -140,7 +140,7 @@ sub get_files_to_test {
|
|||
$no_history = 1;
|
||||
}
|
||||
}
|
||||
@files = $dev_files->ls_perl_files if !$self->{incremental_run} || $no_history;
|
||||
@files = $dev_files->ls_files($filetype) if !$self->{incremental_run} || $no_history;
|
||||
|
||||
return @files;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -146,6 +146,44 @@ sub build_git_exclude {
|
|||
return $exclude_list;
|
||||
}
|
||||
|
||||
=head2 ls_files
|
||||
|
||||
my @files = $file_manager->ls_files($filetype, $git_range);
|
||||
|
||||
Lists files that have been modified within a specified Git range. If no range is provided, it lists all Perl files, excluding those specified in the exceptions.
|
||||
|
||||
=cut
|
||||
|
||||
sub ls_files {
|
||||
my ( $self, $filetype, $git_range ) = @_;
|
||||
my @files;
|
||||
if ($git_range) {
|
||||
$git_range =~ s|\.\.| |;
|
||||
my @modified_files = qx{git diff --name-only $git_range};
|
||||
chomp @modified_files;
|
||||
if ( $filetype eq 'pl' ) {
|
||||
push @files, grep { -e && /\.(pl|PL|pm|t)$/ } @modified_files;
|
||||
push @files, grep { -e && /^(svc|opac\/svc)/ } @modified_files;
|
||||
} elsif ( $filetype eq 'js' ) {
|
||||
push @files, grep { -e && /\.(js|ts|vue)$/ } @modified_files;
|
||||
} elsif ( $filetype eq 'tt' ) {
|
||||
push @files, grep { -e && /\.(tt|inc)$/ } @modified_files;
|
||||
}
|
||||
|
||||
my @exception_files = $exceptions->{$filetype}->{ $self->{context} };
|
||||
@files = array_minus( @files, @exception_files );
|
||||
} else {
|
||||
if ( $filetype eq 'pl' ) {
|
||||
@files = $self->ls_perl_files;
|
||||
} elsif ( $filetype eq 'js' ) {
|
||||
@files = $self->ls_js_files;
|
||||
} elsif ( $filetype eq 'tt' ) {
|
||||
@files = $self->ls_tt_files;
|
||||
}
|
||||
}
|
||||
return @files;
|
||||
}
|
||||
|
||||
=head2 ls_perl_files
|
||||
|
||||
my @perl_files = $file_manager->ls_perl_files($git_range);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use Test::PerlTidy;
|
|||
use Test::More;
|
||||
use Test::NoWarnings;
|
||||
|
||||
use Koha::Devel::Files;
|
||||
use Koha::Devel::CI::IncrementalRuns;
|
||||
|
||||
my $codespell_version = qx{codespell --version};
|
||||
chomp $codespell_version;
|
||||
|
|
@ -12,16 +12,20 @@ $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 $ci = Koha::Devel::CI::IncrementalRuns->new( { context => 'codespell' } );
|
||||
my @files;
|
||||
push @files, $dev_files->ls_perl_files;
|
||||
push @files, $dev_files->ls_tt_files;
|
||||
push @files, $dev_files->ls_js_files;
|
||||
push @files, $ci->get_files_to_test('pl');
|
||||
push @files, $ci->get_files_to_test('tt');
|
||||
push @files, $ci->get_files_to_test('js');
|
||||
|
||||
plan tests => scalar(@files) + 1;
|
||||
|
||||
my %results;
|
||||
for my $file (@files) {
|
||||
my $output = qx{codespell -d --ignore-words .codespell-ignore $file};
|
||||
chomp $output;
|
||||
is( $output, q{} );
|
||||
is( $output, q{} ) or $results{$file} = 1;
|
||||
}
|
||||
|
||||
$ci->report_results( \%results );
|
||||
|
|
|
|||
|
|
@ -4,13 +4,16 @@ use Test::PerlTidy;
|
|||
use Test::More;
|
||||
use Test::NoWarnings;
|
||||
|
||||
use Koha::Devel::Files;
|
||||
use Koha::Devel::CI::IncrementalRuns;
|
||||
|
||||
my $dev_files = Koha::Devel::Files->new( { context => 'tidy' } );
|
||||
my @files = $dev_files->ls_perl_files;
|
||||
my $ci = Koha::Devel::CI::IncrementalRuns->new( { context => 'tidy' } );
|
||||
my @files = $ci->get_files_to_test('pl');
|
||||
|
||||
plan tests => scalar(@files) + 1;
|
||||
|
||||
my %results;
|
||||
for my $file (@files) {
|
||||
ok( Test::PerlTidy::is_file_tidy($file) );
|
||||
ok( Test::PerlTidy::is_file_tidy($file) ) or $results{$file} = 1;
|
||||
}
|
||||
|
||||
$ci->report_results( \%results );
|
||||
|
|
|
|||
Loading…
Reference in New Issue