File Coverage

File:t/00-checkdatabase-version.t
Coverage:82.3%

linestmtbrancondsubtimecode
1# Copyright 2010 Chris Cormack
2#
3# This file is part of Koha.
4#
5# Koha is free software; you can redistribute it and/or modify it under the
6# terms of the GNU General Public License as published by the Free Software
7# Foundation; either version 2 of the License, or (at your option) any later
8# version.
9#
10# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License along
15# with Koha; if not, write to the Free Software Foundation, Inc.,
16# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18
1
1
1
1.33283492533037e+15
3
50
use strict;
19
1
1
1
6
1
41
use warnings;
20
21
1
1
1
1128
21987
11
use Test::More;
22
1
1
1
337
1
20
use File::Spec;
23
1
1
1
399
10966
70
use File::Find;
24
1
1
1
6
4
50780
use IO::File;
25
26
1
146928
my @files =('kohaversion.pl','installer/data/mysql/updatedatabase.pl');
27
28
1
30
foreach my $file (@files){
29
2
1376
    next unless -f $file;
30
2
75
    my @name_parts = File::Spec->splitpath($file);
31
2
4
40
11
    my %dirs = map { $_ => 1 } File::Spec->splitdir($name_parts[1]);
32
2
29
    next if exists $dirs{'.git'};
33
34
2
184
    my $fh = IO::File->new($file, 'r');
35
2
23
    my $xxx_found = 0;
36
2
22
    my $line = 0;
37
2
129
    while (<$fh>) {
38
5183
7328
       $line++;
39
5183
17790
       if (/XXX/i) {
40           #two lines are an exception for updatedatabase (routine SetVersion and TransferToNum)
41
2
45
           next if $file=~ /updatedatabase/ && ( /s\/XXX\$\/999\/;/ || /\$_\[0\]=~ \/XXX\$\/;/ );
42
0
0
           $xxx_found = 1;
43
0
0
          last;
44       }
45     }
46
2
49
     close $fh;
47
2
11
     if ($xxx_found) {
48
0
0
         fail("$file has no XXX in it");
49
0
0
        diag("XXX found in line $line");
50     } else {
51
2
49
        pass("$file has no XXX in it");
52    }
53}
54
55
1
322
done_testing();