File: | t/00-valid-xml.t |
Coverage: | 92.7% |
line | stmt | bran | cond | sub | time | code |
---|---|---|---|---|---|---|
1 | # Copyright 2010 Galen Charlton | |||||
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.33283515432869e+15 2 33 | use strict; | |||
19 | 1 1 1 | 5 1 31 | use warnings; | |||
20 | ||||||
21 | 1 1 1 | 209 29861 13 | use Test::More; | |||
22 | 1 1 1 | 331 1 19 | use File::Spec; | |||
23 | 1 1 1 | 75701 294925 81 | use File::Find; | |||
24 | 1 1 1 | 85115 285064 44 | use XML::LibXML; | |||
25 | ||||||
26 | 1 | 252772 | my $parser = XML::LibXML->new(); | |||
27 | ||||||
28 | find({ | |||||
29 | bydepth => 1, | |||||
30 | no_chdir => 1, | |||||
31 | wanted => sub { | |||||
32 | 9680 | 6231712 | my $file = $_; | |||
33 | 9680 | 102773 | return unless $file =~ /(\.xml|\.xsl|\.xslt)$/i; | |||
34 | 127 | 224 | my $dom; | |||
35 | 127 127 | 266 1181 | eval { $dom = $parser->parse_file($file); }; | |||
36 | 127 | 647172 | if ($@) { | |||
37 | 0 | 0 | fail("$file parses"); | |||
38 | 0 | 0 | diag($@); | |||
39 | } else { | |||||
40 | 127 | 1394 | pass("$file parses"); | |||
41 | } | |||||
42 | }, | |||||
43 | 1 | 178 | }, File::Spec->curdir()); | |||
44 | 1 | 37 | done_testing(); |