Skip to content

Commit 4ce10b3

Browse files
authored
Merge pull request #734 from johnnyshields/v2.x-skip-jruby-zlib-errors
[READY] v2.x -Skip sporadic Zlib::BufError failures in JRuby tests
2 parents cca9a67 + f6564b3 commit 4ce10b3

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

test/test_helper.rb

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,22 @@
2929
RubySaml::Logging.logger = TEST_LOGGER
3030

3131
class Minitest::Test
32-
def jruby?
32+
def self.jruby?
3333
defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
3434
end
3535

36-
def truffleruby?
36+
def jruby?
37+
self.class.jruby?
38+
end
39+
40+
def self.truffleruby?
3741
defined?(RUBY_ENGINE) && RUBY_ENGINE == 'truffleruby'
3842
end
3943

44+
def truffleruby?
45+
self.class.truffleruby?
46+
end
47+
4048
def fixture(document, base64 = true)
4149
response = Dir.glob(File.join(File.dirname(__FILE__), "responses", "#{document}*")).first
4250
if base64 && response =~ /\.xml$/
@@ -488,3 +496,19 @@ def encrypt_xml(assertion_xml, private_key)
488496
encrypted_assertion_xml
489497
end
490498
end
499+
500+
# Remove after https://github.com/jruby/jruby/issues/6613 is fixed
501+
if Minitest::Test.jruby?
502+
module JRubyZlibTestExtension
503+
@@jruby_zlib_failures = 0
504+
505+
def run
506+
super
507+
rescue Zlib::BufError => e
508+
raise e unless (@@jruby_zlib_failures += 1) < 10
509+
skip "Skipping Zlib::BufError in JRuby, see https://github.com/jruby/jruby/issues/6613"
510+
end
511+
end
512+
513+
Minitest::Test.prepend(JRubyZlibTestExtension)
514+
end

0 commit comments

Comments
 (0)