From 699779017948da3a40dea33db36d88ec85599b72 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Fri, 1 Sep 2017 14:15:44 -0400 Subject: [PATCH] Bug 18897: Use Module::Load::Conditional::can_load Rather than rely on eval(), Jonathan Druart recommended in comment #6 to use Use Module::Load::Conditional::can_load. This addresses that concern. TEST PLAN --------- $ git fetch $ git checkout -b bug_18897 origin/master $ git bz apply 18897 $ sudo apt-get remove libcatmandu-store-elasticsearch-perl ... $ prove t/db_dependent/Koha_Elasticsearch_Indexer.t -- Note that the message says the correct library is missing. $ sudo apt-get install libcatmandu-store-elasticsearch-perl -- Note it runs as expected. run the koha qa test tools Signed-off-by: Lee Jamison Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/Koha_Elasticsearch_Indexer.t | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/t/db_dependent/Koha_Elasticsearch_Indexer.t b/t/db_dependent/Koha_Elasticsearch_Indexer.t index ea65517..3f3b7a7 100644 --- a/t/db_dependent/Koha_Elasticsearch_Indexer.t +++ b/t/db_dependent/Koha_Elasticsearch_Indexer.t @@ -17,6 +17,7 @@ use Modern::Perl; +use Module::Load::Conditional qw[can_load check_install requires]; use Test::More; use Test::MockModule; use t::lib::Mocks; @@ -27,10 +28,11 @@ use Koha::Database; my $schema = Koha::Database->schema(); -eval { require Koha::SearchEngine::Elasticsearch::Indexer; }; -if ( $@ ) { +if ( ! can_load( + modules => { 'Koha::SearchEngine::Elasticsearch::Indexer' => undef, } ) +) { my $missing_module; - if ( $@ =~ /Can\'t locate (.*?) / ) { + if ( $Module::Load::Conditional::ERROR =~ /Can\'t locate (.*?) / ) { $missing_module = $1; } my $es_dep_msg = "Required module $missing_module is not installed"; -- 2.7.4