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 <tomascohen@gmail.com>
This commit is contained in:
Tomas Cohen Arazi 2014-11-14 15:28:55 -03:00
parent 63dd425a46
commit 348bca3dbb
1 changed files with 16 additions and 11 deletions

View File

@ -16,43 +16,48 @@
# along with Koha; if not, see <http://www.gnu.org/licenses>.
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 {