diff --git a/test/test_helper.rb b/test/test_helper.rb index 61581475..04712bee 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -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$/ @@ -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