Skip to content

Commit

Permalink
add test for how we handle compressed files
Browse files Browse the repository at this point in the history
this is insufficient coverage, there are other methods that likely
support decompression. this test is only intended to demonstrate an
instance of zlib/lzma support, relative to libxml2's "legacy" option
in v2.13.0.
  • Loading branch information
flavorjones committed Jun 22, 2024
1 parent 8e03cc8 commit 7e98917
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ext/nokogiri/nokogiri.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ Init_nokogiri(void)
rb_const_set(mNokogiri, rb_intern("LIBXSLT_COMPILED_VERSION"), NOKOGIRI_STR_NEW2(LIBXSLT_DOTTED_VERSION));
rb_const_set(mNokogiri, rb_intern("LIBXSLT_LOADED_VERSION"), NOKOGIRI_STR_NEW2(xsltEngineVersion));

rb_const_set(mNokogiri, rb_intern("LIBXML_ZLIB_ENABLED"),
xmlHasFeature(XML_WITH_ZLIB) == 1 ? Qtrue : Qfalse);

#ifdef NOKOGIRI_PACKAGED_LIBRARIES
rb_const_set(mNokogiri, rb_intern("PACKAGED_LIBRARIES"), Qtrue);
# ifdef NOKOGIRI_PRECOMPILED_LIBRARIES
Expand Down
Binary file added test/files/staff.xml.gz
Binary file not shown.
10 changes: 10 additions & 0 deletions test/xml/sax/test_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,16 @@ def call_parse_io_with_encoding(encoding)
end
end

it "parses a compressed file" do
skip("libxml2 legacy support") unless Nokogiri.uses_libxml? && Nokogiri::LIBXML_ZLIB_ENABLED

filename = XML_FILE + ".gz"
parser.parse_file(filename)

refute_nil(parser.document.start_elements)
assert_operator(parser.document.start_elements.count, :>, 30)
end

it :test_render_parse_nil_param do
assert_raises(TypeError) { parser.parse_memory(nil) }
end
Expand Down

0 comments on commit 7e98917

Please sign in to comment.