Skip to content

Commit

Permalink
tests: updated for upstream libxml support (#3083)
Browse files Browse the repository at this point in the history
**What problem is this PR intended to solve?**

Upstream error handling changed for XPath and IO in 954b8984 and
7e511f35.

This PR updates the tests to accept the new behavior.


**Have you included adequate test coverage?**

Yes.


**Does this change affect the behavior of either the C or the Java
implementations?**

No behavioral changes.
  • Loading branch information
flavorjones committed Dec 28, 2023
2 parents 3457199 + 68bb3bb commit 94cb2dc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
12 changes: 3 additions & 9 deletions test/test_xslt_transforms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -357,16 +357,10 @@ def test_non_html_xslt_transform
exception = assert_raises(RuntimeError) do
xslt.transform(doc)
end
if truffleruby_system_libraries?
assert_equal(
"xslt_generic_error_handler: xmlXPathCompOpEval: function %s not found\nxslt_generic_error_handler: %s",
exception.message,
)
if Nokogiri.uses_libxml?(">= 2.13") # upstream commit 954b8984
assert_includes(exception.message, "Unregistered function")
else
assert_match(
/xmlXPathCompOpEval: function decimal not found/,
exception.message,
)
assert_match(/xmlXPathCompOpEval: function .* not found/, exception.message)
end
end

Expand Down
10 changes: 8 additions & 2 deletions test/xml/test_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -500,10 +500,16 @@ def test_namespace_should_not_exist
end

def test_non_existent_function
e = assert_raises(Nokogiri::XML::XPath::SyntaxError) do
exception = assert_raises(Nokogiri::XML::XPath::SyntaxError) do
xml.xpath("//name[foo()]")
end
assert_match(/function.*not found|Could not find function/, e.to_s)
if Nokogiri.jruby?
assert_includes(exception.message, "Could not find function: foo")
elsif Nokogiri.uses_libxml?(">= 2.13") # upstream commit 954b8984
assert_includes(exception.message, "Unregistered function")
else
assert_match(/xmlXPathCompOpEval: function .* not found/, exception.message)
end
end

def test_xpath_syntax_error
Expand Down
4 changes: 2 additions & 2 deletions test/xml/test_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ class TestNokogiriXMLSchema < Nokogiri::TestCase
errors.grep(/ERROR: Attempt to load network entity/).length,
"Should not see xmlIO.c:xmlNoNetExternalEntityLoader() raising XML_IO_NETWORK_ATTEMPT",
)
assert_equal(1, errors.grep(/WARNING: failed to load HTTP resource|WARNING: failed to load external entity/).length)
assert_equal(1, errors.grep(/WARNING: failed to load/).length)
end

it "XML::Schema parsing of memory attempts to access external DTDs" do
Expand All @@ -323,7 +323,7 @@ class TestNokogiriXMLSchema < Nokogiri::TestCase
errors.grep(/ERROR: Attempt to load network entity/).length,
"Should not see xmlIO.c:xmlNoNetExternalEntityLoader() raising XML_IO_NETWORK_ATTEMPT",
)
assert_equal(1, errors.grep(/WARNING: failed to load HTTP resource|WARNING: failed to load external entity/).length)
assert_equal(1, errors.grep(/WARNING: failed to load/).length)
end
end
end
Expand Down

0 comments on commit 94cb2dc

Please sign in to comment.