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