Bug 17600: Standardize our EXPORT_OK
[koha.git] / misc / devel / coverage.pl
1 #!/usr/bin/perl
2
3 # Copyright 2015 BibLibre
4 #
5 # This file is part of Koha.
6 #
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 3 of the License, or (at your option) any later
10 # version.
11 #
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, see <http://www.gnu.org/licenses>.
18
19 =head1 NAME
20
21 coverage.pl
22
23 =head1 SYNOPSIS
24
25     misc/devel/coverage.pl [-h|--help]
26
27 This script must be run from your Koha source tree.
28
29 =head1 DESCRIPTION
30
31 This script runs all Koha tests and generates a coverage report on the
32 cover_db directory.
33
34 =cut
35
36 =head1 OPTIONS
37
38 =over 8
39
40 =item B<-h|--help>
41
42 prints this help text
43
44 =back
45
46 =cut
47
48 use Modern::Perl;
49
50 use C4::Context;
51 use Cwd qw( getcwd );
52 use Getopt::Long qw( GetOptions );
53 use Pod::Usage qw( pod2usage );
54
55 my $help;
56
57 GetOptions(
58     "h|help"      => \$help
59 );
60
61 pod2usage(1) if defined $help;
62
63 #Die if you are not in your Koha src directory
64 my $KOHA_PATH = C4::Context->config("intranetdir");
65 die "ERROR : You are not in Koha src/ directory"
66   unless $KOHA_PATH eq getcwd;
67
68 # Delete old coverage
69 system("cover -delete");
70
71 #Start the cover
72 system("PERL5OPT=-MDevel::Cover /usr/bin/prove -r t/");
73
74 #Create the HTML output
75 system("cover");
76 say("file://$KOHA_PATH/cover_db/coverage.html")
77   unless !-e "$KOHA_PATH/cover_db/coverage.html";
78
79 1;