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
pitbulk committed Jan 13, 2025
1 parent c70e911 commit ef8827a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion test/response_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ def generate_audience_error(expected, actual)

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

settings.soft = true

Expand Down
2 changes: 1 addition & 1 deletion test/slo_logoutrequest_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class RubySamlTest < Minitest::Test

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

logout_request.soft = true
logout_request.document.root.attributes['NotOnOrAfter'] = '2011-06-14T18:31:01.516Z'
Expand Down
32 changes: 32 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,22 @@
OneLogin::RubySaml::Logging.logger = TEST_LOGGER

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

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 @@ -365,3 +381,19 @@ def downcased_escape(str)
CGI.escape(str).gsub(/%[A-Fa-f0-9]{2}/) { |match| match.downcase }
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 ef8827a

Please sign in to comment.