Skip to content

Commit

Permalink
Merge pull request #738 from SAML-Toolkits/skip-jruby-zlib-errors
Browse files Browse the repository at this point in the history
Skip sporadic Zlib::BufError failures in JRuby tests
  • Loading branch information
pitbulk authored Jan 13, 2025
2 parents c70e911 + eb14644 commit 0da0b55
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
6 changes: 6 additions & 0 deletions ruby-saml.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ Gem::Specification.new do |s|
s.add_runtime_dependency('rexml')
end

if RUBY_VERSION >= '3.4.0'
s.add_runtime_dependency("logger")
s.add_runtime_dependency("base64")
s.add_runtime_dependency('mutex_m')
end

s.add_development_dependency('simplecov', '<0.22.0')
if RUBY_VERSION < '2.4.1'
s.add_development_dependency('simplecov-lcov', '<0.8.0')
Expand Down
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 0da0b55

Please sign in to comment.