From 348bca3dbb200627b3f3fd3ae9aae2d012892ecd Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 14 Nov 2014 15:28:55 -0300 Subject: [PATCH] Bug 11401: (followup) make tests run on absent deps The current code breaks if a dependency is missing. The evals are rearranged so there's no error on missing dependency. To reproduce: - Have a dependency for t/NorwegianPatronDB.t removed - Run $ prove t/NorwegianPatronDB.t => FAIL: You see an error similar to this (may vary depending on the lib you removed): t/NorwegianPatronDB.t .. You tried to plan twice at t/NorwegianPatronDB.t line 37. - Apply the patch - Run $ prove t/NorwegianPatronDB.t => SUCCESS: Tests are skipped on missing lib Signed-off-by: Tomas Cohen Arazi --- t/NorwegianPatronDB.t | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/t/NorwegianPatronDB.t b/t/NorwegianPatronDB.t index 4f05d91..1f0808c 100644 --- a/t/NorwegianPatronDB.t +++ b/t/NorwegianPatronDB.t @@ -16,43 +16,48 @@ # along with Koha; if not, see . use Modern::Perl; -use Test::More tests => 73; +use Test::More; use Test::MockModule; use t::lib::Mocks; use Data::Dumper; # Check that all the modules we need are installed, or bail out BEGIN { + my $missing_lib; eval { require Test::DBIx::Class; 1; } or do { - plan skip_all => "Test::DBIx::Class is not available"; + $missing_lib = "Test::DBIx::Class"; }; -} -BEGIN { + eval { require SOAP::Lite; 1; } or do { - plan skip_all => "SOAP::Lite is not available"; + $missing_lib = "SOAP::Lite"; }; -} -BEGIN { + eval { require Crypt::GCrypt; 1; } or do { - plan skip_all => "Crypt::GCrypt is not available"; + $missing_lib = "Crypt::GCrypt"; }; -} -BEGIN { + eval { require Convert::BaseN; 1; } or do { - plan skip_all => "Convert::BaseN is not available"; + $missing_lib = "Convert::BaseN"; }; + + if ( $missing_lib ) { + plan skip_all => $missing_lib . " is not available."; + } else { + # Everything good + plan tests => 73; + } } use Test::DBIx::Class { -- 1.9.1