Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip sporadic Zlib::BufError failures in JRuby tests #738

Merged
merged 2 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading