Fix test suite compatibility with libxml 2.9.12.
Resolves: rhbz#1980885
This commit is contained in:
parent
9515fadf5d
commit
f06c482b6f
@ -0,0 +1,35 @@
|
||||
From 56a8004de8f0b4253ea4deef608e72eb9b1824e5 Mon Sep 17 00:00:00 2001
|
||||
From: Mike Dalessio <mike.dalessio@gmail.com>
|
||||
Date: Tue, 18 May 2021 09:58:31 -0400
|
||||
Subject: [PATCH] test: adjust tests to pass on system libxml2 >= 2.9.11
|
||||
|
||||
because the comment parsing improvement was merged upstream.
|
||||
---
|
||||
test/html/test_comments.rb | 7 ++-----
|
||||
1 file changed, 2 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/test/html/test_comments.rb b/test/html/test_comments.rb
|
||||
index 476fc4b473..7d207815f5 100644
|
||||
--- a/test/html/test_comments.rb
|
||||
+++ b/test/html/test_comments.rb
|
||||
@@ -113,8 +113,7 @@ class TestComment < Nokogiri::TestCase
|
||||
let(:subject) { doc.at_css("div#under-test") }
|
||||
let(:inner_div) { doc.at_css("div#do-i-exist") }
|
||||
|
||||
- if Nokogiri.uses_libxml? && Nokogiri::VersionInfo.instance.libxml2_using_packaged?
|
||||
- # see patches/libxml2/0006-htmlParseComment-treat-as-if-it-closed-the-comment.patch
|
||||
+ if Nokogiri::VersionInfo.instance.libxml2_using_packaged? || (Nokogiri::VersionInfo.instance.libxml2_using_system? && Nokogiri.uses_libxml?(">=2.9.11"))
|
||||
it "behaves as if the comment is normally closed" do # COMPLIANT
|
||||
assert_equal 3, subject.children.length
|
||||
assert subject.children[0].comment?
|
||||
@@ -128,9 +127,7 @@ class TestComment < Nokogiri::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
- if Nokogiri.jruby? || Nokogiri::VersionInfo.instance.libxml2_using_system?
|
||||
- # this behavior may change to the above in libxml v2.9.11 depending on whether
|
||||
- # https://gitlab.gnome.org/GNOME/libxml2/-/merge_requests/82 is merged
|
||||
+ if Nokogiri.jruby? || (Nokogiri::VersionInfo.instance.libxml2_using_system? && Nokogiri.uses_libxml?("<2.9.11"))
|
||||
it "behaves as if the comment encompasses the inner div" do # NON-COMPLIANT
|
||||
assert_equal 1, subject.children.length
|
||||
assert subject.children.first.comment?
|
@ -0,0 +1,24 @@
|
||||
From f9d72bb67bf81d0d3712134cd4ccea8a3d5a033d Mon Sep 17 00:00:00 2001
|
||||
From: Mike Dalessio <mike.dalessio@gmail.com>
|
||||
Date: Thu, 13 May 2021 22:41:44 -0400
|
||||
Subject: [PATCH] test: adjust xpath gc test to libxml2's max recursion depth
|
||||
|
||||
See upstream libxml2 commit 6f1470a where the recursion limit is
|
||||
hardcoded to 5000 stack frames.
|
||||
---
|
||||
test/xml/test_xpath.rb | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/test/xml/test_xpath.rb b/test/xml/test_xpath.rb
|
||||
index 271412a70..fe22646ba 100644
|
||||
--- a/test/xml/test_xpath.rb
|
||||
+++ b/test/xml/test_xpath.rb
|
||||
@@ -337,7 +337,7 @@ def name_equals(nodeset, name, *args)
|
||||
# long list of long arguments, to apply GC pressure during
|
||||
# ruby_funcall argument marshalling
|
||||
xpath = ["//tool[name_equals(.,'hammer'"]
|
||||
- 1000.times { xpath << "'unused argument #{'x' * 1000}'" }
|
||||
+ 500.times { xpath << "'unused argument #{'x' * 1000}'" }
|
||||
xpath << "'unused argument')]"
|
||||
xpath = xpath.join(',')
|
||||
|
@ -0,0 +1,46 @@
|
||||
From 4fe6b46f04f94b31bc39fe5be4f363b025ec0aaf Mon Sep 17 00:00:00 2001
|
||||
From: Mike Dalessio <mike.dalessio@gmail.com>
|
||||
Date: Thu, 13 May 2021 23:04:13 -0400
|
||||
Subject: [PATCH] test: establish better baseline behavior for MS Word's html
|
||||
format
|
||||
|
||||
because this is about to change in libxml 2.9.12
|
||||
---
|
||||
test/xml/test_node.rb | 20 ++++++++++++--------
|
||||
1 file changed, 12 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/test/xml/test_node.rb b/test/xml/test_node.rb
|
||||
index 5995055cb..54cc9eccd 100644
|
||||
--- a/test/xml/test_node.rb
|
||||
+++ b/test/xml/test_node.rb
|
||||
@@ -1041,18 +1041,22 @@ def test_namespace_without_an_href_on_html_node
|
||||
# describe how we handle microsoft word's HTML formatting.
|
||||
# this test is descriptive, not prescriptive.
|
||||
#
|
||||
- skip("Xerces handles this edge case completely differently") unless Nokogiri.uses_libxml?
|
||||
-
|
||||
- xml = Nokogiri::HTML.parse(<<~EOF)
|
||||
+ html = Nokogiri::HTML.parse(<<~EOF)
|
||||
<div><o:p>foo</o:p></div>
|
||||
EOF
|
||||
-
|
||||
- node = xml.at("p")
|
||||
+ node = html.at("div").children.first
|
||||
assert_not_nil(node)
|
||||
|
||||
- assert_equal(1, node.namespaces.keys.size)
|
||||
- assert(node.namespaces.has_key?('xmlns:o'))
|
||||
- assert_nil(node.namespaces['xmlns:o'])
|
||||
+ if Nokogiri.uses_libxml?
|
||||
+ assert_equal(1, node.namespaces.keys.size)
|
||||
+ assert(node.namespaces.has_key?('xmlns:o'))
|
||||
+ assert_nil(node.namespaces['xmlns:o'])
|
||||
+ assert_equal("<p>foo</p>", node.to_html)
|
||||
+ else
|
||||
+ # Xerces does something completely different
|
||||
+ assert_empty(node.namespaces.keys)
|
||||
+ assert_equal("<o:p>foo</o:p>", node.to_html)
|
||||
+ end
|
||||
end
|
||||
|
||||
def test_xpath_results_have_document_and_are_decorated
|
@ -0,0 +1,31 @@
|
||||
From 458c3241db78ac2ee2be061eb1c738742e21d0ee Mon Sep 17 00:00:00 2001
|
||||
From: Mike Dalessio <mike.dalessio@gmail.com>
|
||||
Date: Thu, 13 May 2021 22:50:39 -0400
|
||||
Subject: [PATCH] test: remove low-value HTML::SAX::PushParser encoding test
|
||||
|
||||
---
|
||||
test/html/sax/test_push_parser.rb | 11 -----------
|
||||
1 file changed, 11 deletions(-)
|
||||
|
||||
diff --git a/test/html/sax/test_push_parser.rb b/test/html/sax/test_push_parser.rb
|
||||
index dd6425390..f83440d27 100644
|
||||
--- a/test/html/sax/test_push_parser.rb
|
||||
+++ b/test/html/sax/test_push_parser.rb
|
||||
@@ -70,17 +70,6 @@ def test_chevron
|
||||
def test_default_options
|
||||
assert_equal 0, @parser.options
|
||||
end
|
||||
-
|
||||
- def test_broken_encoding
|
||||
- skip("ultra hard to fix for pure Java version") if Nokogiri.jruby?
|
||||
- @parser.options |= XML::ParseOptions::RECOVER
|
||||
- # This is ISO_8859-1:
|
||||
- @parser.<< "<?xml version='1.0' encoding='UTF-8'?><r>Gau\337</r>"
|
||||
- @parser.finish
|
||||
- assert(@parser.document.errors.size >= 1)
|
||||
- assert_equal "Gau\337", @parser.document.data.join
|
||||
- assert_equal [["r"], ["body"], ["html"]], @parser.document.end_elements
|
||||
- end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,34 @@
|
||||
From 0e743c8a6d34bd4416fd986c9777b22744ad2283 Mon Sep 17 00:00:00 2001
|
||||
From: Mike Dalessio <mike.dalessio@gmail.com>
|
||||
Date: Thu, 13 May 2021 23:07:27 -0400
|
||||
Subject: [PATCH] test: update behavior of namespaces in HTML
|
||||
|
||||
libxml 2.9.12 fixes the parser to ignore namespaces in HTML docs,
|
||||
likely in upstream commit 21ca882.
|
||||
---
|
||||
test/xml/test_node.rb | 8 +++++---
|
||||
1 file changed, 5 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/test/xml/test_node.rb b/test/xml/test_node.rb
|
||||
index 54cc9eccd..11a8b993a 100644
|
||||
--- a/test/xml/test_node.rb
|
||||
+++ b/test/xml/test_node.rb
|
||||
@@ -1047,13 +1047,15 @@ def test_namespace_without_an_href_on_html_node
|
||||
node = html.at("div").children.first
|
||||
assert_not_nil(node)
|
||||
|
||||
- if Nokogiri.uses_libxml?
|
||||
+ if Nokogiri.uses_libxml?(">= 2.9.12")
|
||||
+ assert_empty(node.namespaces.keys)
|
||||
+ assert_equal("<p>foo</p>", node.to_html)
|
||||
+ elsif Nokogiri.uses_libxml?
|
||||
assert_equal(1, node.namespaces.keys.size)
|
||||
assert(node.namespaces.has_key?('xmlns:o'))
|
||||
assert_nil(node.namespaces['xmlns:o'])
|
||||
assert_equal("<p>foo</p>", node.to_html)
|
||||
- else
|
||||
- # Xerces does something completely different
|
||||
+ else # jruby
|
||||
assert_empty(node.namespaces.keys)
|
||||
assert_equal("<o:p>foo</o:p>", node.to_html)
|
||||
end
|
@ -1,26 +0,0 @@
|
||||
--- nokogiri-1.5.0/Rakefile.debug 2012-01-18 16:23:02.472224272 +0900
|
||||
+++ nokogiri-1.5.0/Rakefile 2012-01-18 16:23:29.935430496 +0900
|
||||
@@ -83,14 +83,21 @@
|
||||
HOE.spec.files += ['lib/nokogiri/nokogiri.jar']
|
||||
end
|
||||
else
|
||||
- require 'tasks/cross_compile'
|
||||
+ do_cross_compile = true
|
||||
+ begin
|
||||
+ require 'tasks/cross_compile'
|
||||
+ rescue RuntimeError => e
|
||||
+ warn "WARNING: Could not perform some cross-compiling: #{e}"
|
||||
+ do_cross_compile = false
|
||||
+ end
|
||||
require "rake/extensiontask"
|
||||
|
||||
- HOE.spec.files.reject! { |f| f =~ %r{^ext/java|\.jar$} }
|
||||
+ HOE.spec.files.reject! { |f| f =~ %r{^ext/java|\.jar$} } if do_cross_compile
|
||||
|
||||
Rake::ExtensionTask.new("nokogiri", HOE.spec) do |ext|
|
||||
ext.lib_dir = File.join(*['lib', 'nokogiri', ENV['FAT_DIR']].compact)
|
||||
ext.config_options << ENV['EXTOPTS']
|
||||
+ next unless do_cross_compile
|
||||
ext.cross_compile = true
|
||||
ext.cross_platform = ["x86-mswin32-60", "x86-mingw32"]
|
||||
ext.cross_config_options << "--with-xml2-include=#{File.join($recipes[:libxml2].path, 'include', 'libxml2')}"
|
@ -1,7 +1,7 @@
|
||||
%global mainver 1.11.2
|
||||
#%%global prever .rc4
|
||||
|
||||
%global mainrel 2
|
||||
%global mainrel 3
|
||||
%global prerpmver %(echo "%{?prever}" | sed -e 's|\\.||g')
|
||||
|
||||
%global gem_name nokogiri
|
||||
@ -24,6 +24,19 @@ Source2: nokogiri-create-full-tarball.sh
|
||||
#Patch0: rubygem-nokogiri-1.5.0-allow-non-crosscompile.patch
|
||||
# Shut down libxml2 version unmatching warning
|
||||
Patch0: %{name}-1.11.0.rc4-shutdown-libxml2-warning.patch
|
||||
# Several patches to fix test suite compatibility with libxml 2.9.12.
|
||||
# https://github.com/sparklemotion/nokogiri/pull/2235
|
||||
# https://github.com/sparklemotion/nokogiri/pull/2235/commits/4fe6b46f04f94b31bc39fe5be4f363b025ec0aaf
|
||||
Patch1: rubygem-nokogiri-1.11.2-establish-better-baseline-behavior-for-MS-Words-html.patch
|
||||
# https://github.com/sparklemotion/nokogiri/pull/2235/commits/f9d72bb67bf81d0d3712134cd4ccea8a3d5a033d
|
||||
Patch2: rubygem-nokogiri-1.11.2-adjust-xpath-gc-test-to-libxml2s-max-recursion-depth.patch
|
||||
# https://github.com/sparklemotion/nokogiri/pull/2235/commits/458c3241db78ac2ee2be061eb1c738742e21d0ee
|
||||
Patch3: rubygem-nokogiri-1.11.2-remove-low-value-HTML-SAX-PushParser-encoding-test.patch
|
||||
# https://github.com/sparklemotion/nokogiri/pull/2235/commits/0e743c8a6d34bd4416fd986c9777b22744ad2283
|
||||
Patch4: rubygem-nokogiri-1.11.2-update-behavior-of-namespaces-in-HTML.patch
|
||||
# https://github.com/sparklemotion/nokogiri/pull/2240
|
||||
# https://github.com/sparklemotion/nokogiri/pull/2240/commits/56a8004de8f0b4253ea4deef608e72eb9b1824e5
|
||||
Patch5: rubygem-nokogiri-1.11.2-adjust-tests-to-pass-on-system-libxml2-2.9.11.patch
|
||||
BuildRequires: ruby(release)
|
||||
BuildRequires: ruby(rubygems)
|
||||
##
|
||||
@ -79,6 +92,14 @@ This package provides non-Gem support for %{gem_name}.
|
||||
%prep
|
||||
%setup -q -T -c -a 1
|
||||
|
||||
pushd %{gem_name}-%{version}
|
||||
%patch1 -p1
|
||||
%patch2 -p1
|
||||
%patch3 -p1
|
||||
%patch4 -p1
|
||||
%patch5 -p1
|
||||
popd
|
||||
|
||||
# Gem repack
|
||||
TOPDIR=$(pwd)
|
||||
mkdir tmpunpackdir
|
||||
@ -236,6 +257,10 @@ popd
|
||||
%{gem_dir}/doc/%{gem_name}-%{mainver}%{?prever}/
|
||||
|
||||
%changelog
|
||||
* Wed Jul 28 2021 Vít Ondruch <vondruch@redhat.com> - 1.11.2-3
|
||||
- Fix test suite compatibility with libxml 2.9.12.
|
||||
Resolves: rhbz#1980885
|
||||
|
||||
* Fri May 07 2021 Vít Ondruch <vondruch@redhat.com> - 1.11.2-2
|
||||
- Remove rubygem(minitest-reporters) dependency.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user