Skip to content

Commit

Permalink
Skip sporadic Zlib::BufError failures in JRuby tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyshields committed Jan 11, 2025
1 parent 6f73a4f commit f6564b3
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,22 @@
RubySaml::Logging.logger = TEST_LOGGER

class Minitest::Test
def jruby?
def self.jruby?
defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
end

def truffleruby?
def jruby?
self.class.jruby?
end

def self.truffleruby?
defined?(RUBY_ENGINE) && RUBY_ENGINE == 'truffleruby'
end

def truffleruby?
self.class.truffleruby?
end

def fixture(document, base64 = true)
response = Dir.glob(File.join(File.dirname(__FILE__), "responses", "#{document}*")).first
if base64 && response =~ /\.xml$/
Expand Down Expand Up @@ -488,3 +496,19 @@ def encrypt_xml(assertion_xml, private_key)
encrypted_assertion_xml
end
end

# Remove after https://github.com/jruby/jruby/issues/6613 is fixed
if Minitest::Test.jruby?
module JRubyZlibTestExtension
@@jruby_zlib_failures = 0

def run
super
rescue Zlib::BufError => e
raise e unless (@@jruby_zlib_failures += 1) < 10
skip "Skipping Zlib::BufError in JRuby, see https://github.com/jruby/jruby/issues/6613"
end
end

Minitest::Test.prepend(JRubyZlibTestExtension)
end

0 comments on commit f6564b3

Please sign in to comment.