Skip to content

Commit

Permalink
test: ensure upstream libxml2 is passing
Browse files Browse the repository at this point in the history
A few fixes, including ones by your truly, have made it upstream (but
not yet in a release) and the tests' conditional logic is being
updated.

Closes #2468
  • Loading branch information
flavorjones committed May 4, 2022
1 parent 520f4e7 commit baa6453
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions test/html4/test_comments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class TestComment < Nokogiri::TestCase
let(:html) { "<html><body><div id=under-test><!--></div><div id=also-here></div></body></html>" }

if Nokogiri.uses_libxml?
if Nokogiri.libxml2_patches.include?("0008-htmlParseComment-handle-abruptly-closed-comments.patch")
if Nokogiri.libxml2_patches.include?("0008-htmlParseComment-handle-abruptly-closed-comments.patch") || Nokogiri::LIBXML_LOADED_VERSION.include?("-GIT") # fixed on libxml2 master
it "behaves as if the comment is closed correctly" do # COMPLIANT
assert_equal 1, subject.children.length
assert_predicate subject.children.first, :comment?
Expand Down Expand Up @@ -54,7 +54,7 @@ class TestComment < Nokogiri::TestCase
let(:html) { "<html><body><div id=under-test><!---></div><div id=also-here></div></body></html>" }

if Nokogiri.uses_libxml?
if Nokogiri.libxml2_patches.include?("0008-htmlParseComment-handle-abruptly-closed-comments.patch")
if Nokogiri.libxml2_patches.include?("0008-htmlParseComment-handle-abruptly-closed-comments.patch") || Nokogiri::LIBXML_LOADED_VERSION.include?("-GIT") # fixed on libxml2 master
it "behaves as if the comment is closed correctly" do # COMPLIANT
assert_equal 1, subject.children.length
assert_predicate subject.children.first, :comment?
Expand Down Expand Up @@ -173,7 +173,7 @@ class TestComment < Nokogiri::TestCase
let(:body) { doc.at_css("body") }
let(:subject) { doc.at_css("div#under-test") }

if Nokogiri.uses_libxml?("<=2.9.13")
if Nokogiri.uses_libxml?("<=2.9.13") && !Nokogiri::LIBXML_LOADED_VERSION.include?("-GIT") # fixed on libxml2 master
it "ignores up to the next '>'" do # NON-COMPLIANT
assert_equal 2, body.children.length
assert_equal body.children[0], subject
Expand Down
4 changes: 2 additions & 2 deletions test/html4/test_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ def test_leaking_dtd_nodes_after_internal_subset_removal
doc = Nokogiri::HTML4::Document.parse(html)
expected = if Nokogiri.jruby?
[Nokogiri::XML::Node::COMMENT_NODE, Nokogiri::XML::Node::PI_NODE]
elsif Nokogiri.libxml2_patches.include?("0008-htmlParseComment-handle-abruptly-closed-comments.patch")
elsif Nokogiri.libxml2_patches.include?("0008-htmlParseComment-handle-abruptly-closed-comments.patch") || Nokogiri::LIBXML_LOADED_VERSION.include?("-GIT") # fixed on libxml2 master
[Nokogiri::XML::Node::COMMENT_NODE]
else
[]
Expand All @@ -804,7 +804,7 @@ def test_leaking_dtd_nodes_after_internal_subset_removal
doc = Nokogiri::HTML4.parse(input)
body = doc.at_xpath("//body")

if Nokogiri.uses_libxml?("= 2.9.13")
if Nokogiri.uses_libxml?("= 2.9.13") && !Nokogiri::LIBXML_LOADED_VERSION.include?("-GIT") # fixed on libxml2 master
# <body><div>this <div>second element</div></div></body>
assert_equal(1, body.children.length)
body.children.first.tap do |div|
Expand Down

0 comments on commit baa6453

Please sign in to comment.