Skip to content

Commit ef8827a

Browse files
committed
Skip sporadic Zlib::BufError failures in JRuby tests
1 parent c70e911 commit ef8827a

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

test/response_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ def generate_audience_error(expected, actual)
11601160

11611161
it "optionally allows for clock drift on NotOnOrAfter" do
11621162
# Java Floats behave differently than MRI
1163-
java = defined?(RUBY_ENGINE) && %w[jruby truffleruby].include?(RUBY_ENGINE)
1163+
java = jruby? || truffleruby?
11641164

11651165
settings.soft = true
11661166

test/slo_logoutrequest_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ class RubySamlTest < Minitest::Test
211211

212212
it "optionally allows for clock drift" do
213213
# Java Floats behave differently than MRI
214-
java = defined?(RUBY_ENGINE) && %w[jruby truffleruby].include?(RUBY_ENGINE)
214+
java = jruby? || truffleruby?
215215

216216
logout_request.soft = true
217217
logout_request.document.root.attributes['NotOnOrAfter'] = '2011-06-14T18:31:01.516Z'

test/test_helper.rb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,22 @@
3030
OneLogin::RubySaml::Logging.logger = TEST_LOGGER
3131

3232
class Minitest::Test
33+
def self.jruby?
34+
defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
35+
end
36+
37+
def jruby?
38+
self.class.jruby?
39+
end
40+
41+
def self.truffleruby?
42+
defined?(RUBY_ENGINE) && RUBY_ENGINE == 'truffleruby'
43+
end
44+
45+
def truffleruby?
46+
self.class.truffleruby?
47+
end
48+
3349
def fixture(document, base64 = true)
3450
response = Dir.glob(File.join(File.dirname(__FILE__), "responses", "#{document}*")).first
3551
if base64 && response =~ /\.xml$/
@@ -365,3 +381,19 @@ def downcased_escape(str)
365381
CGI.escape(str).gsub(/%[A-Fa-f0-9]{2}/) { |match| match.downcase }
366382
end
367383
end
384+
385+
# Remove after https://github.com/jruby/jruby/issues/6613 is fixed
386+
if Minitest::Test.jruby?
387+
module JRubyZlibTestExtension
388+
@@jruby_zlib_failures = 0
389+
390+
def run
391+
super
392+
rescue Zlib::BufError => e
393+
raise e unless (@@jruby_zlib_failures += 1) < 10
394+
skip "Skipping Zlib::BufError in JRuby, see https://github.com/jruby/jruby/issues/6613"
395+
end
396+
end
397+
398+
Minitest::Test.prepend(JRubyZlibTestExtension)
399+
end

0 commit comments

Comments
 (0)