1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
|
From bee8338fd1cbd7aad4bf60c2965833343b6ead6f Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer@aevum.de>
Date: Tue, 21 May 2024 15:17:30 +0200
Subject: [PATCH 1/3] Fix test suite with libxml2 2.13.0
---
t/02parse.t | 7 ++++++-
t/08findnodes.t | 8 +++++++-
t/19die_on_invalid_utf8_rt_58848.t | 2 +-
t/25relaxng.t | 4 ++--
t/26schema.t | 4 ++--
t/60error_prev_chain.t | 8 ++++----
6 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/t/02parse.t b/t/02parse.t
index b111507b..40aa5f13 100644
--- a/t/02parse.t
+++ b/t/02parse.t
@@ -884,7 +884,12 @@ EOXML
eval {
$doc2 = $parser->parse_string( $xmldoc );
};
- isnt($@, '', "error parsing $xmldoc");
+ # https://gitlab.gnome.org/GNOME/libxml2/-/commit/b717abdd
+ if (XML::LibXML::LIBXML_RUNTIME_VERSION() < 21300) {
+ isnt($@, '', "error parsing $xmldoc");
+ } else {
+ is( $doc2->documentElement()->firstChild()->nodeName(), "foo" );
+ }
$parser->validation(1);
diff --git a/t/08findnodes.t b/t/08findnodes.t
index 016c85a1..e9417bc5 100644
--- a/t/08findnodes.t
+++ b/t/08findnodes.t
@@ -123,7 +123,13 @@ my $docstring = q{
my @ns = $root->findnodes('namespace::*');
# TEST
-is(scalar(@ns), 2, ' TODO : Add test name' );
+# https://gitlab.gnome.org/GNOME/libxml2/-/commit/aca16fb3
+# fixed xmlCopyNamespace with XML namespace.
+if (XML::LibXML::LIBXML_RUNTIME_VERSION() < 21300) {
+ is(scalar(@ns), 2, ' TODO : Add test name' );
+} else {
+ is(scalar(@ns), 3, ' TODO : Add test name' );
+}
# bad xpaths
# TEST:$badxpath=4;
diff --git a/t/19die_on_invalid_utf8_rt_58848.t b/t/19die_on_invalid_utf8_rt_58848.t
index aa8ad105..4160cb27 100644
--- a/t/19die_on_invalid_utf8_rt_58848.t
+++ b/t/19die_on_invalid_utf8_rt_58848.t
@@ -16,7 +16,7 @@ use XML::LibXML;
my $err = $@;
# TEST
- like ("$err", qr{parser error : Input is not proper UTF-8},
+ like ("$err", qr{not proper UTF-8|Invalid bytes in character encoding},
'Parser error.',
);
}
diff --git a/t/25relaxng.t b/t/25relaxng.t
index 93e61883..71383b2a 100644
--- a/t/25relaxng.t
+++ b/t/25relaxng.t
@@ -132,7 +132,7 @@ print "# 6 check that no_network => 1 works\n";
{
my $rng = eval { XML::LibXML::RelaxNG->new( location => $netfile, no_network => 1 ) };
# TEST
- like( $@, qr{I/O error : Attempt to load network entity}, 'RNG from file location with external import and no_network => 1 throws an exception.' );
+ like( $@, qr{Attempt to load network entity}, 'RNG from file location with external import and no_network => 1 throws an exception.' );
# TEST
ok( !defined $rng, 'RNG from file location with external import and no_network => 1 is not loaded.' );
}
@@ -152,7 +152,7 @@ print "# 6 check that no_network => 1 works\n";
</grammar>
EOF
# TEST
- like( $@, qr{I/O error : Attempt to load network entity}, 'RNG from buffer with external import and no_network => 1 throws an exception.' );
+ like( $@, qr{Attempt to load network entity}, 'RNG from buffer with external import and no_network => 1 throws an exception.' );
# TEST
ok( !defined $rng, 'RNG from buffer with external import and no_network => 1 is not loaded.' );
}
diff --git a/t/26schema.t b/t/26schema.t
index 17f641e4..c404cedd 100644
--- a/t/26schema.t
+++ b/t/26schema.t
@@ -117,7 +117,7 @@ EOF
{
my $schema = eval { XML::LibXML::Schema->new( location => $netfile, no_network => 1 ) };
# TEST
- like( $@, qr{I/O error : Attempt to load network entity}, 'Schema from file location with external import and no_network => 1 throws an exception.' );
+ like( $@, qr{Attempt to load network entity}, 'Schema from file location with external import and no_network => 1 throws an exception.' );
# TEST
ok( !defined $schema, 'Schema from file location with external import and no_network => 1 is not loaded.' );
}
@@ -129,7 +129,7 @@ EOF
</xsd:schema>
EOF
# TEST
- like( $@, qr{I/O error : Attempt to load network entity}, 'Schema from buffer with external import and no_network => 1 throws an exception.' );
+ like( $@, qr{Attempt to load network entity}, 'Schema from buffer with external import and no_network => 1 throws an exception.' );
# TEST
ok( !defined $schema, 'Schema from buffer with external import and no_network => 1 is not loaded.' );
}
diff --git a/t/60error_prev_chain.t b/t/60error_prev_chain.t
index e48215c4..55ac0b2e 100644
--- a/t/60error_prev_chain.t
+++ b/t/60error_prev_chain.t
@@ -16,13 +16,11 @@ use XML::LibXML;
{
my $parser = XML::LibXML->new();
- $parser->validation(0);
- $parser->load_ext_dtd(0);
eval
{
local $^W = 0;
- $parser->parse_file('example/JBR-ALLENtrees.htm');
+ $parser->parse_string('<doc>“ ”</doc>');
};
my $err = $@;
@@ -31,7 +29,7 @@ use XML::LibXML;
if( $err && !ref($err) ) {
plan skip_all => 'The local libxml library does not support errors as objects to $@';
}
- plan tests => 1;
+ plan tests => 2;
while (defined($err) && $count < 200)
{
@@ -44,6 +42,8 @@ use XML::LibXML;
# TEST
ok ((!$err), "Reached the end of the chain.");
+ # TEST
+ is ($count, 3, "Correct number of errors reported")
}
=head1 COPYRIGHT & LICENSE
From c9f9c2fe51173b0a00969f01b577399f1098aa47 Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer@aevum.de>
Date: Thu, 13 Feb 2025 19:50:35 +0100
Subject: [PATCH 2/3] Fix test suite with libxml2 2.14.0
---
t/16docnodes.t | 7 ++++++-
t/49_load_html.t | 8 +++++++-
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/t/16docnodes.t b/t/16docnodes.t
index db7bc1fc..0b0ae005 100644
--- a/t/16docnodes.t
+++ b/t/16docnodes.t
@@ -60,7 +60,12 @@ for my $time (0 .. 2) {
$doc->setDocumentElement($node);
# TEST
- is( $node->serialize(), '<test contents="ä"/>', 'Node serialise works.' );
+ # libxml2 2.14 avoids unnecessary escaping of attribute values.
+ if (XML::LibXML::LIBXML_VERSION() >= 21400) {
+ is( $node->serialize(), "<test contents=\"\xE4\"/>", 'Node serialise works.' );
+ } else {
+ is( $node->serialize(), '<test contents="ä"/>', 'Node serialise works.' );
+ }
$doc->setEncoding('utf-8');
# Second output
diff --git a/t/49_load_html.t b/t/49_load_html.t
index 70d26607..3861edf8 100644
--- a/t/49_load_html.t
+++ b/t/49_load_html.t
@@ -52,7 +52,13 @@ use XML::LibXML;
</div>
EOS
- {
+ SKIP: {
+ # libxml2 2.14 tokenizes HTML according to HTML5 where
+ # this isn't an error, see "13.2.5.73 Named character
+ # reference state".
+ skip("libxml2 version >= 21400", 1)
+ if XML::LibXML::LIBXML_VERSION >= 21400;
+
my $buf = '';
open my $fh, '>', \$buf;
# redirect STDERR there
From ecbebc2f33fecb66b3d5487c6e48bea353e374f9 Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer@aevum.de>
Date: Fri, 16 May 2025 19:11:12 +0200
Subject: [PATCH 3/3] Remove tests that disable line numbers
Line numbers are always enabled since libxml2 2.15.0.
---
t/02parse.t | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)
diff --git a/t/02parse.t b/t/02parse.t
index 40aa5f13..17419f8f 100644
--- a/t/02parse.t
+++ b/t/02parse.t
@@ -14,7 +14,7 @@ use locale;
POSIX::setlocale(LC_ALL, "C");
-use Test::More tests => 533;
+use Test::More tests => 531;
use IO::File;
use XML::LibXML::Common qw(:libxml);
@@ -25,7 +25,7 @@ use constant XML_DECL => "<?xml version=\"1.0\"?>\n";
use Errno qw(ENOENT);
-# TEST*533
+# TEST*531
##
# test values
@@ -773,15 +773,6 @@ EOXML
my $newkid = $root->appendChild( $doc->createElement( "bar" ) );
is( $newkid->line_number(), 0, "line number is 0");
-
- $parser->line_numbers(0);
- eval { $doc = $parser->parse_string( $goodxml ); };
-
- $root = $doc->documentElement();
- is( $root->line_number(), 0, "line number is 0");
-
- @kids = $root->childNodes();
- is( $kids[1]->line_number(), 0, "line number is 0");
}
SKIP: {
|