From 02a29dc7ea60cb580cde3fd1a1f2bb658e69e634 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 8 Oct 2025 23:28:20 +0900 Subject: [PATCH] Load the same loaded zlib Zlib is used by also rubygems, the built extension cannot be loaded after the default gem is loaded. --- test/zlib/test_zlib.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/zlib/test_zlib.rb b/test/zlib/test_zlib.rb index 5a8463a..bedf243 100644 --- a/test/zlib/test_zlib.rb +++ b/test/zlib/test_zlib.rb @@ -9,6 +9,9 @@ begin require 'zlib' rescue LoadError +else + z = "/zlib.#{RbConfig::CONFIG["DLEXT"]}" + LOADED_ZLIB, = $".select {|f| f.end_with?(z)} end if defined? Zlib @@ -1525,7 +1528,7 @@ def test_gunzip_encoding end def test_gunzip_no_memory_leak - assert_no_memory_leak(%[-rzlib], "#{<<~"{#"}", "#{<<~'};'}") + assert_no_memory_leak(%W[-r#{LOADED_ZLIB}], "#{<<~"{#"}", "#{<<~'};'}") d = Zlib.gzip("data") {# 10_000.times {Zlib.gunzip(d)}