Bugzilla – Attachment 166561 Details for
Bug 34978
Add --include and --exclude options to install_plugins.pl to choose the plugins to install
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34978: (QA follow-up) Fix rebase issues
Bug-34978-QA-follow-up-Fix-rebase-issues.patch (text/plain), 7.45 KB, created by
Tomás Cohen Arazi (tcohen)
on 2024-05-10 13:32:29 UTC
(
hide
)
Description:
Bug 34978: (QA follow-up) Fix rebase issues
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2024-05-10 13:32:29 UTC
Size:
7.45 KB
patch
obsolete
>From fc363dbc24ac4e46ec845c1a65ffbb2bd5715f36 Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Fri, 22 Dec 2023 13:29:27 +0000 >Subject: [PATCH] Bug 34978: (QA follow-up) Fix rebase issues > >- Rebased tests patch (62->51) >- tidy >- spelling ( paramater -> parameter ) > >Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Plugins.pm | 18 ++++++++----- > misc/devel/install_plugins.pl | 4 +-- > t/db_dependent/Koha/Plugins/Plugins.t | 38 +++++++++++++-------------- > 3 files changed, 33 insertions(+), 27 deletions(-) > >diff --git a/Koha/Plugins.pm b/Koha/Plugins.pm >index 6669da3702f..f7efc14d386 100644 >--- a/Koha/Plugins.pm >+++ b/Koha/Plugins.pm >@@ -277,19 +277,21 @@ sub InstallPlugins { > my $verbose = $params->{verbose} // $self->_verbose; > > my @plugin_classes = $self->plugins(); >- my (@plugins, @classes_filters); >+ my ( @plugins, @classes_filters ); > >- my $has_filters = defined($params->{include}) || defined($params->{exclude}); >+ my $has_filters = defined( $params->{include} ) || defined( $params->{exclude} ); > > # Warn user if the specified classes doesn't exist and return nothing > if ($has_filters) { >- @classes_filters = defined($params->{include}) ? @{$params->{include}} : @{$params->{exclude}}; >+ @classes_filters = defined( $params->{include} ) ? @{ $params->{include} } : @{ $params->{exclude} }; > > foreach my $classes_filter (@classes_filters) { > my $is_found = 0; > > foreach my $plugin_class (@plugin_classes) { >- $is_found = 1 if $plugin_class =~ ":$classes_filter\$|^$classes_filter\$" || ($classes_filter =~ "^::" && $plugin_class =~ "$classes_filter\$"); >+ $is_found = 1 >+ if $plugin_class =~ ":$classes_filter\$|^$classes_filter\$" >+ || ( $classes_filter =~ "^::" && $plugin_class =~ "$classes_filter\$" ); > } > unless ($is_found) { > warn "$classes_filter have not been found, try a different name"; >@@ -306,9 +308,13 @@ sub InstallPlugins { > if ($has_filters) { > my $is_found = 0; > foreach my $classes_filter (@classes_filters) { >- $is_found = 1 if $plugin_class =~ ":$classes_filter\$|^$classes_filter\$" || ($classes_filter =~ "^::" && $plugin_class =~ "$classes_filter\$"); >+ $is_found = 1 >+ if $plugin_class =~ ":$classes_filter\$|^$classes_filter\$" >+ || ( $classes_filter =~ "^::" && $plugin_class =~ "$classes_filter\$" ); > } >- next if (defined($params->{include}) && !$is_found) || (defined($params->{exclude}) && $is_found); >+ next >+ if ( defined( $params->{include} ) && !$is_found ) >+ || ( defined( $params->{exclude} ) && $is_found ); > } > > my $plugin; >diff --git a/misc/devel/install_plugins.pl b/misc/devel/install_plugins.pl >index 02c96474cfe..99ecdec65f9 100755 >--- a/misc/devel/install_plugins.pl >+++ b/misc/devel/install_plugins.pl >@@ -26,10 +26,10 @@ use Koha::Script; > use C4::Context; > use Koha::Plugins; > >-my ($help, @include, @exclude); >+my ( $help, @include, @exclude ); > > GetOptions( >- 'help|?' => \$help, >+ 'help|?' => \$help, > 'include=s' => \@include, > 'exclude=s' => \@exclude, > ) or die "Installation aborted\n"; >diff --git a/t/db_dependent/Koha/Plugins/Plugins.t b/t/db_dependent/Koha/Plugins/Plugins.t >index 7fdebf55a1e..1db51568c40 100755 >--- a/t/db_dependent/Koha/Plugins/Plugins.t >+++ b/t/db_dependent/Koha/Plugins/Plugins.t >@@ -24,7 +24,7 @@ use File::Temp qw( tempdir tempfile ); > use FindBin qw($Bin); > use Module::Load::Conditional qw(can_load); > use Test::MockModule; >-use Test::More tests => 30; >+use Test::More tests => 19; > use Test::Warn; > > use C4::Context; >@@ -195,23 +195,23 @@ subtest 'InstallPlugins() tests' => sub { > Koha::Plugins::Methods->delete; > $schema->resultset('PluginData')->delete; > >- # Tests for the exclude paramater >+ # Tests for the exclude parameter > # Test the returned plugins of the InstallPlugins subroutine >- my $plugins = Koha::Plugins->new({ enable_plugins => 1 }); >- my @installed_plugins = $plugins->InstallPlugins({ exclude => ["Test", "Koha::Plugin::MarcFieldValues"] }); >- my $plugin_classes = join(" ", map{$_->{class}} @installed_plugins); >+ my $plugins = Koha::Plugins->new( { enable_plugins => 1 } ); >+ my @installed_plugins = $plugins->InstallPlugins( { exclude => [ "Test", "Koha::Plugin::MarcFieldValues" ] } ); >+ my $plugin_classes = join( " ", map { $_->{class} } @installed_plugins ); > >- my $result = grep { $plugin_classes !~ $_ } [":Test |:Test\$", ":MarcFieldValues |:MarcFieldValues\$"] >+ my $result = grep { $plugin_classes !~ $_ } [ ":Test |:Test\$", ":MarcFieldValues |:MarcFieldValues\$" ] > && $plugin_classes =~ ":TestItemBarcodeTransform |:TestItemBarcodeTransform\$"; >- ok($result, "Excluded plugins are not returned"); >+ ok( $result, "Excluded plugins are not returned" ); > > # Test the plugins in the database >- my @plugins = $plugins->GetPlugins({ all => 1, error => 1 }); >- $plugin_classes = join(" ", map{$_->{class}} @plugins); >+ my @plugins = $plugins->GetPlugins( { all => 1, error => 1 } ); >+ $plugin_classes = join( " ", map { $_->{class} } @plugins ); > >- $result = grep { $plugin_classes !~ $_ } [":Test |:Test\$", ":MarcFieldValues |:MarcFieldValues\$"] >+ $result = grep { $plugin_classes !~ $_ } [ ":Test |:Test\$", ":MarcFieldValues |:MarcFieldValues\$" ] > && $plugin_classes =~ ":TestItemBarcodeTransform |:TestItemBarcodeTransform\$"; >- ok($result, "Excluded plugins are not installed"); >+ ok( $result, "Excluded plugins are not installed" ); > > # Remove installed plugins data > Koha::Plugins::Methods->delete; >@@ -219,22 +219,22 @@ subtest 'InstallPlugins() tests' => sub { > > # Tests for the include parameter > # Test the returned plugins of the InstallPlugins subroutine >- @installed_plugins = $plugins->InstallPlugins({ include => ["Test", "Koha::Plugin::MarcFieldValues"]}); >+ @installed_plugins = $plugins->InstallPlugins( { include => [ "Test", "Koha::Plugin::MarcFieldValues" ] } ); > > $result = 1; >- foreach my $plugin_class ( map{ $_->{class} } @installed_plugins ) { >- $result = 0 unless("$plugin_class" =~ ":Test\$" || "$plugin_class" =~ ":MarcFieldValues\$"); >+ foreach my $plugin_class ( map { $_->{class} } @installed_plugins ) { >+ $result = 0 unless ( "$plugin_class" =~ ":Test\$" || "$plugin_class" =~ ":MarcFieldValues\$" ); > } >- ok($result, "Only included plugins are returned"); >+ ok( $result, "Only included plugins are returned" ); > > # Test the plugins in the database >- @plugins = $plugins->GetPlugins({ all => 1, error => 1}); >+ @plugins = $plugins->GetPlugins( { all => 1, error => 1 } ); > > $result = 1; >- foreach my $plugin_class ( map{ $_->{class} } @plugins ) { >- $result = 0 unless("$plugin_class" =~ ":Test\$" || "$plugin_class" =~ ":MarcFieldValues\$"); >+ foreach my $plugin_class ( map { $_->{class} } @plugins ) { >+ $result = 0 unless ( "$plugin_class" =~ ":Test\$" || "$plugin_class" =~ ":MarcFieldValues\$" ); > } >- ok($result, "Only included plugins are installed"); >+ ok( $result, "Only included plugins are installed" ); > > $schema->storage->txn_rollback; > }; >-- >2.45.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 34978
:
156539
|
156555
|
156557
|
160210
|
160239
|
160240
|
163800
|
163801
|
166560
|
166561
|
166562
|
166576
|
166736
|
166738
|
166739
|
166740
|
166741
|
166742