View | Details | Raw Unified | Return to bug 16618
Collapse All | Expand All

(-)a/t/00-load.t (-4 / +40 lines)
Lines 2-7 Link Here
2
2
3
# This file is part of Koha.
3
# This file is part of Koha.
4
#
4
#
5
# Copyright (c) 2016   Mark Tompsett -- is_testable()
6
#
5
# Koha is free software; you can redistribute it and/or modify it
7
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
8
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
9
# the Free Software Foundation; either version 3 of the License, or
Lines 20-26 use Modern::Perl; Link Here
20
use Test::More;
22
use Test::More;
21
use File::Spec;
23
use File::Spec;
22
use File::Find;
24
use File::Find;
23
25
use English qw( -no_match_vars );
24
use t::lib::Mocks;
26
use t::lib::Mocks;
25
27
26
=head1 DESCRIPTION
28
=head1 DESCRIPTION
Lines 59-71 find( Link Here
59
            return unless $m =~ s/[.]pm$//;
61
            return unless $m =~ s/[.]pm$//;
60
            $m =~ s{^.*/Koha/}{Koha/};
62
            $m =~ s{^.*/Koha/}{Koha/};
61
            $m =~ s{/}{::}g;
63
            $m =~ s{/}{::}g;
62
            return if $m =~ /Koha::NorwegianPatronDB/; # uses non-mandatory modules
64
            if ( is_testable($m) ) {
63
            use_ok($m) || BAIL_OUT("***** PROBLEMS LOADING FILE '$m'");
65
                use_ok($m) || BAIL_OUT("***** PROBLEMS LOADING FILE '$m'");
66
            }
64
        },
67
        },
65
    },
68
    },
66
    $lib
69
    $lib
67
);
70
);
68
71
72
# Optional modules are causing checks to fail
73
# This checks for the particular modules to determine
74
# if the testing is possible or not.
75
#
76
# Returns 1 if possible, 0 if not.
77
sub is_testable {
78
    my ($module_name) = @_;
79
    my @needed_module_names;
80
    my $return_value = 1;
81
    if ( $module_name =~ /Koha::NorwegianPatronDB/xsm ) {
82
        @needed_module_names =
83
          ( 'SOAP::Lite', 'Crypt::GCrypt', 'Digest::SHA', 'Convert::BaseN' );
84
    }
85
    elsif ( $module_name =~ /Koha::ElasticSearch::Indexer/xsm ) {
86
        @needed_module_names =
87
          ( 'Catmandu::Importer::MARC', 'Catmandu::Store::ElasticSearch' );
88
    }
89
    elsif ( $module_name =~ /Koha::SearchEngine::Elasticsearch::Search/xsm ) {
90
        @needed_module_names = ( 'Catmandu::Store::ElasticSearch' );
91
    }
92
    foreach my $current_name (@needed_module_names) {
93
        my $relative_pathname = $current_name;
94
        $relative_pathname =~ s/::/\//gxsm;
95
        $relative_pathname .= '.pm';
96
        my $check_result = eval { require "$relative_pathname"; 1; };
97
        if ($EVAL_ERROR) {
98
            diag(
99
"Skipping testing of $module_name, because $current_name is not installed."
100
            );
101
            $return_value = 0;
102
        }
103
    }
104
    return $return_value;
105
}
69
106
70
done_testing();
107
done_testing();
71
108
72
- 

Return to bug 16618