Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: update tests to reflect upstream libxml2 entity references #3182

Merged
merged 1 commit into from Apr 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 22 additions & 9 deletions test/xml/test_entity_reference.rb
Expand Up @@ -163,7 +163,9 @@ def setup
doc = @parser.parse(xml, path, &:default_xml)

assert_kind_of Nokogiri::XML::EntityReference, doc.xpath("//body").first.children.first
if Nokogiri.uses_libxml?
if Nokogiri.uses_libxml?(">= 2.13.0") # gnome/libxml2@b717abdd
assert_equal ["5:14: WARNING: Entity 'bar' not defined"], doc.errors.map(&:to_s)
elsif Nokogiri.uses_libxml?
assert_equal ["5:14: ERROR: Entity 'bar' not defined"], doc.errors.map(&:to_s)
end
end
Expand All @@ -184,11 +186,11 @@ def setup

assert_kind_of Nokogiri::XML::EntityReference, doc.xpath("//body").first.children.first

expected = if Nokogiri.uses_libxml?(">= 2.13")
expected = if Nokogiri.uses_libxml?(">= 2.13") # many gnome/libxml2 changes made in 2023-12
[
"2:49: WARNING: failed to load \"http://foo.bar.com/\": Attempt to load network entity",
"ERROR: Attempt to load network entity: http://foo.bar.com/",
"4:14: ERROR: Entity 'bar' not defined",
"4:14: WARNING: Entity 'bar' not defined", # gnome/libxml2@b717abdd
]
elsif Nokogiri.uses_libxml?
[
Expand Down Expand Up @@ -218,16 +220,20 @@ def setup
xml = File.read(xml_document)
@parser.parse(xml)

refute_nil @parser.document.errors
actual = if Nokogiri.uses_libxml?(">= 2.13.0") # gnome/libxml2@b717abdd
@parser.document.warnings
else
@parser.document.errors
end

errors = @parser.document.errors.map { |e| e.to_s.strip }
actual = actual.map { |e| e.to_s.strip }
expected = if truffleruby_system_libraries?
["error_func: %s"]
else
["Entity 'bar' not defined"]
end

assert_equal(expected, errors)
assert_equal(expected, actual)
end

test_relative_and_absolute_path :test_more_sax_entity_reference do
Expand All @@ -241,16 +247,23 @@ def setup
XML
@parser.parse(xml)

refute_nil @parser.document.errors
actual = if Nokogiri.uses_libxml?(">= 2.13.0") # gnome/libxml2@b717abdd
@parser.document.warnings
else
@parser.document.errors
end

refute_nil(actual)
refute_empty(actual)

errors = @parser.document.errors.map { |e| e.to_s.strip }
actual = actual.map { |e| e.to_s.strip }
expected = if truffleruby_system_libraries?
["error_func: %s"]
else
["Entity 'bar' not defined"]
end

assert_equal(expected, errors)
assert_equal(expected, actual)
end
end

Expand Down