From f06c482b6f8348f96a6a91ef754bacec1b0bdb06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ondruch?= Date: Wed, 28 Jul 2021 14:56:44 +0200 Subject: [PATCH] Fix test suite compatibility with libxml 2.9.12. Resolves: rhbz#1980885 --- ...sts-to-pass-on-system-libxml2-2.9.11.patch | 35 ++++++++++++++ ...test-to-libxml2s-max-recursion-depth.patch | 24 ++++++++++ ...-baseline-behavior-for-MS-Words-html.patch | 46 +++++++++++++++++++ ...ue-HTML-SAX-PushParser-encoding-test.patch | 31 +++++++++++++ ...pdate-behavior-of-namespaces-in-HTML.patch | 34 ++++++++++++++ ...okogiri-1.5.0-allow-non-crosscompile.patch | 26 ----------- rubygem-nokogiri.spec | 27 ++++++++++- 7 files changed, 196 insertions(+), 27 deletions(-) create mode 100644 rubygem-nokogiri-1.11.2-adjust-tests-to-pass-on-system-libxml2-2.9.11.patch create mode 100644 rubygem-nokogiri-1.11.2-adjust-xpath-gc-test-to-libxml2s-max-recursion-depth.patch create mode 100644 rubygem-nokogiri-1.11.2-establish-better-baseline-behavior-for-MS-Words-html.patch create mode 100644 rubygem-nokogiri-1.11.2-remove-low-value-HTML-SAX-PushParser-encoding-test.patch create mode 100644 rubygem-nokogiri-1.11.2-update-behavior-of-namespaces-in-HTML.patch delete mode 100644 rubygem-nokogiri-1.5.0-allow-non-crosscompile.patch diff --git a/rubygem-nokogiri-1.11.2-adjust-tests-to-pass-on-system-libxml2-2.9.11.patch b/rubygem-nokogiri-1.11.2-adjust-tests-to-pass-on-system-libxml2-2.9.11.patch new file mode 100644 index 0000000..85e1549 --- /dev/null +++ b/rubygem-nokogiri-1.11.2-adjust-tests-to-pass-on-system-libxml2-2.9.11.patch @@ -0,0 +1,35 @@ +From 56a8004de8f0b4253ea4deef608e72eb9b1824e5 Mon Sep 17 00:00:00 2001 +From: Mike Dalessio +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? diff --git a/rubygem-nokogiri-1.11.2-adjust-xpath-gc-test-to-libxml2s-max-recursion-depth.patch b/rubygem-nokogiri-1.11.2-adjust-xpath-gc-test-to-libxml2s-max-recursion-depth.patch new file mode 100644 index 0000000..c01e672 --- /dev/null +++ b/rubygem-nokogiri-1.11.2-adjust-xpath-gc-test-to-libxml2s-max-recursion-depth.patch @@ -0,0 +1,24 @@ +From f9d72bb67bf81d0d3712134cd4ccea8a3d5a033d Mon Sep 17 00:00:00 2001 +From: Mike Dalessio +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(',') + diff --git a/rubygem-nokogiri-1.11.2-establish-better-baseline-behavior-for-MS-Words-html.patch b/rubygem-nokogiri-1.11.2-establish-better-baseline-behavior-for-MS-Words-html.patch new file mode 100644 index 0000000..8ddbc2f --- /dev/null +++ b/rubygem-nokogiri-1.11.2-establish-better-baseline-behavior-for-MS-Words-html.patch @@ -0,0 +1,46 @@ +From 4fe6b46f04f94b31bc39fe5be4f363b025ec0aaf Mon Sep 17 00:00:00 2001 +From: Mike Dalessio +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) +
foo
+ 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("

foo

", node.to_html) ++ else ++ # Xerces does something completely different ++ assert_empty(node.namespaces.keys) ++ assert_equal("foo", node.to_html) ++ end + end + + def test_xpath_results_have_document_and_are_decorated diff --git a/rubygem-nokogiri-1.11.2-remove-low-value-HTML-SAX-PushParser-encoding-test.patch b/rubygem-nokogiri-1.11.2-remove-low-value-HTML-SAX-PushParser-encoding-test.patch new file mode 100644 index 0000000..d347f7f --- /dev/null +++ b/rubygem-nokogiri-1.11.2-remove-low-value-HTML-SAX-PushParser-encoding-test.patch @@ -0,0 +1,31 @@ +From 458c3241db78ac2ee2be061eb1c738742e21d0ee Mon Sep 17 00:00:00 2001 +From: Mike Dalessio +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.<< "Gau\337" +- @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 diff --git a/rubygem-nokogiri-1.11.2-update-behavior-of-namespaces-in-HTML.patch b/rubygem-nokogiri-1.11.2-update-behavior-of-namespaces-in-HTML.patch new file mode 100644 index 0000000..523516c --- /dev/null +++ b/rubygem-nokogiri-1.11.2-update-behavior-of-namespaces-in-HTML.patch @@ -0,0 +1,34 @@ +From 0e743c8a6d34bd4416fd986c9777b22744ad2283 Mon Sep 17 00:00:00 2001 +From: Mike Dalessio +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("

foo

", 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("

foo

", node.to_html) +- else +- # Xerces does something completely different ++ else # jruby + assert_empty(node.namespaces.keys) + assert_equal("foo", node.to_html) + end diff --git a/rubygem-nokogiri-1.5.0-allow-non-crosscompile.patch b/rubygem-nokogiri-1.5.0-allow-non-crosscompile.patch deleted file mode 100644 index f45734b..0000000 --- a/rubygem-nokogiri-1.5.0-allow-non-crosscompile.patch +++ /dev/null @@ -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')}" diff --git a/rubygem-nokogiri.spec b/rubygem-nokogiri.spec index 1f59083..24d067e 100644 --- a/rubygem-nokogiri.spec +++ b/rubygem-nokogiri.spec @@ -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 - 1.11.2-3 +- Fix test suite compatibility with libxml 2.9.12. + Resolves: rhbz#1980885 + * Fri May 07 2021 Vít Ondruch - 1.11.2-2 - Remove rubygem(minitest-reporters) dependency.