From 55a9f83d49235c0690bde632f85fa0b8dedd83b2 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Wed, 17 Jan 2024 13:24:18 +0900 Subject: [PATCH 1/7] Added current directory to LOAD_PATH of assert_in_out_err for test-bundled-gems at ruby/ruby --- test/bigdecimal/test_bigdecimal.rb | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb index b28242b7..f4b54901 100644 --- a/test/bigdecimal/test_bigdecimal.rb +++ b/test/bigdecimal/test_bigdecimal.rb @@ -1768,7 +1768,9 @@ def test_ctov def test_split_under_gc_stress bug3258 = '[ruby-dev:41213]' expect = 10.upto(20).map{|i|[1, "1", 10, i+1].inspect} - assert_in_out_err(%w[-rbigdecimal --disable-gems], <<-EOS, expect, [], bug3258) + # for test-bundled-gems in ruby/ruby repository + extension_paths = Dir.glob(File.expand_path('../../../../../.bundle/extensions', __dir__) + '/**/*/bigdecimal-*').join(":") + assert_in_out_err(["-I#{extension_paths}", "-rbigdecimal", "--disable-gems"], <<-EOS, expect, [], bug3258) GC.stress = true 10.upto(20) do |i| p BigDecimal("1"+"0"*i).split @@ -1777,7 +1779,9 @@ def test_split_under_gc_stress end def test_coerce_under_gc_stress - assert_in_out_err(%w[-rbigdecimal --disable-gems], <<-EOS, [], []) + # for test-bundled-gems in ruby/ruby repository + extension_paths = Dir.glob(File.expand_path('../../../../../.bundle/extensions', __dir__) + '/**/*/bigdecimal-*').join(":") + assert_in_out_err(["-I#{extension_paths}", "-rbigdecimal", "--disable-gems"], <<-EOS, [], []) expect = ":too_long_to_embed_as_string can't be coerced into BigDecimal" b = BigDecimal("1") GC.stress = true @@ -1884,7 +1888,9 @@ def test_BigMath_exp_with_rational end def test_BigMath_exp_under_gc_stress - assert_in_out_err(%w[-rbigdecimal --disable-gems], <<-EOS, [], []) + # for test-bundled-gems in ruby/ruby repository + extension_paths = Dir.glob(File.expand_path('../../../../../.bundle/extensions', __dir__) + '/**/*/bigdecimal-*').join(":") + assert_in_out_err(["-I#{extension_paths}", "-rbigdecimal", "--disable-gems"], <<-EOS, [], []) expect = ":too_long_to_embed_as_string can't be coerced into BigDecimal" 10.times do begin @@ -2026,7 +2032,9 @@ def test_BigMath_log_with_reciprocal_of_42 end def test_BigMath_log_under_gc_stress - assert_in_out_err(%w[-rbigdecimal --disable-gems], <<-EOS, [], []) + # for test-bundled-gems in ruby/ruby repository + extension_paths = Dir.glob(File.expand_path('../../../../../.bundle/extensions', __dir__) + '/**/*/bigdecimal-*').join(":") + assert_in_out_err(["-I#{extension_paths}", "-rbigdecimal", "--disable-gems"], <<-EOS, [], []) expect = ":too_long_to_embed_as_string can't be coerced into BigDecimal" 10.times do begin @@ -2073,7 +2081,9 @@ def test_to_d end if RUBY_VERSION < '2.5' # mathn was removed from Ruby 2.5 def test_bug6406 - assert_in_out_err(%w[-rbigdecimal --disable-gems], <<-EOS, [], []) + # for test-bundled-gems in ruby/ruby repository + extension_paths = Dir.glob(File.expand_path('../../../../../.bundle/extensions', __dir__) + '/**/*/bigdecimal-*').join(":") + assert_in_out_err(["-I#{extension_paths}", "-rbigdecimal", "--disable-gems"], <<-EOS, [], []) Thread.current.keys.to_s EOS end From 1bbca814f9650ee3de351a4f3eb126cdc7ad36ae Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Wed, 17 Jan 2024 17:10:43 +0900 Subject: [PATCH 2/7] Support ruby/bigdecimal repository cases --- test/bigdecimal/test_bigdecimal.rb | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb index f4b54901..e97fd48c 100644 --- a/test/bigdecimal/test_bigdecimal.rb +++ b/test/bigdecimal/test_bigdecimal.rb @@ -1770,7 +1770,9 @@ def test_split_under_gc_stress expect = 10.upto(20).map{|i|[1, "1", 10, i+1].inspect} # for test-bundled-gems in ruby/ruby repository extension_paths = Dir.glob(File.expand_path('../../../../../.bundle/extensions', __dir__) + '/**/*/bigdecimal-*').join(":") - assert_in_out_err(["-I#{extension_paths}", "-rbigdecimal", "--disable-gems"], <<-EOS, expect, [], bug3258) + opts = ["-rbigdecimal", "--disable-gems"] + opts.unshift "-I#{extension_paths}" unless extension_paths.empty? + assert_in_out_err(opts, <<-EOS, expect, [], bug3258) GC.stress = true 10.upto(20) do |i| p BigDecimal("1"+"0"*i).split @@ -1781,7 +1783,9 @@ def test_split_under_gc_stress def test_coerce_under_gc_stress # for test-bundled-gems in ruby/ruby repository extension_paths = Dir.glob(File.expand_path('../../../../../.bundle/extensions', __dir__) + '/**/*/bigdecimal-*').join(":") - assert_in_out_err(["-I#{extension_paths}", "-rbigdecimal", "--disable-gems"], <<-EOS, [], []) + opts = ["-rbigdecimal", "--disable-gems"] + opts.unshift "-I#{extension_paths}" unless extension_paths.empty? + assert_in_out_err(opts, <<-EOS, [], []) expect = ":too_long_to_embed_as_string can't be coerced into BigDecimal" b = BigDecimal("1") GC.stress = true @@ -1890,7 +1894,9 @@ def test_BigMath_exp_with_rational def test_BigMath_exp_under_gc_stress # for test-bundled-gems in ruby/ruby repository extension_paths = Dir.glob(File.expand_path('../../../../../.bundle/extensions', __dir__) + '/**/*/bigdecimal-*').join(":") - assert_in_out_err(["-I#{extension_paths}", "-rbigdecimal", "--disable-gems"], <<-EOS, [], []) + opts = ["-rbigdecimal", "--disable-gems"] + opts.unshift "-I#{extension_paths}" unless extension_paths.empty? + assert_in_out_err(opts, <<-EOS, [], []) expect = ":too_long_to_embed_as_string can't be coerced into BigDecimal" 10.times do begin @@ -2034,7 +2040,9 @@ def test_BigMath_log_with_reciprocal_of_42 def test_BigMath_log_under_gc_stress # for test-bundled-gems in ruby/ruby repository extension_paths = Dir.glob(File.expand_path('../../../../../.bundle/extensions', __dir__) + '/**/*/bigdecimal-*').join(":") - assert_in_out_err(["-I#{extension_paths}", "-rbigdecimal", "--disable-gems"], <<-EOS, [], []) + opts = ["-rbigdecimal", "--disable-gems"] + opts.unshift "-I#{extension_paths}" unless extension_paths.empty? + assert_in_out_err(opts, <<-EOS, [], []) expect = ":too_long_to_embed_as_string can't be coerced into BigDecimal" 10.times do begin @@ -2083,7 +2091,9 @@ def test_to_d def test_bug6406 # for test-bundled-gems in ruby/ruby repository extension_paths = Dir.glob(File.expand_path('../../../../../.bundle/extensions', __dir__) + '/**/*/bigdecimal-*').join(":") - assert_in_out_err(["-I#{extension_paths}", "-rbigdecimal", "--disable-gems"], <<-EOS, [], []) + opts = ["-rbigdecimal", "--disable-gems"] + opts.unshift "-I#{extension_paths}" unless extension_paths.empty? + assert_in_out_err(opts, <<-EOS, [], []) Thread.current.keys.to_s EOS end From bf5ebd0be03a8cba3e7a1569ee0ccde8ebc16cf6 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Wed, 17 Jan 2024 19:34:01 +0900 Subject: [PATCH 3/7] Simplified LOAD_PATH delegation for assert_in_out_err --- test/bigdecimal/test_bigdecimal.rb | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb index e97fd48c..078b059c 100644 --- a/test/bigdecimal/test_bigdecimal.rb +++ b/test/bigdecimal/test_bigdecimal.rb @@ -1768,11 +1768,7 @@ def test_ctov def test_split_under_gc_stress bug3258 = '[ruby-dev:41213]' expect = 10.upto(20).map{|i|[1, "1", 10, i+1].inspect} - # for test-bundled-gems in ruby/ruby repository - extension_paths = Dir.glob(File.expand_path('../../../../../.bundle/extensions', __dir__) + '/**/*/bigdecimal-*').join(":") - opts = ["-rbigdecimal", "--disable-gems"] - opts.unshift "-I#{extension_paths}" unless extension_paths.empty? - assert_in_out_err(opts, <<-EOS, expect, [], bug3258) + assert_in_out_err(["-I#{$LOAD_PATH.join(":")}", "-rbigdecimal", "--disable-gems"], <<-EOS, expect, [], bug3258) GC.stress = true 10.upto(20) do |i| p BigDecimal("1"+"0"*i).split @@ -1781,11 +1777,7 @@ def test_split_under_gc_stress end def test_coerce_under_gc_stress - # for test-bundled-gems in ruby/ruby repository - extension_paths = Dir.glob(File.expand_path('../../../../../.bundle/extensions', __dir__) + '/**/*/bigdecimal-*').join(":") - opts = ["-rbigdecimal", "--disable-gems"] - opts.unshift "-I#{extension_paths}" unless extension_paths.empty? - assert_in_out_err(opts, <<-EOS, [], []) + assert_in_out_err(["-I#{$LOAD_PATH.join(":")}", "-rbigdecimal", "--disable-gems"], <<-EOS, [], []) expect = ":too_long_to_embed_as_string can't be coerced into BigDecimal" b = BigDecimal("1") GC.stress = true @@ -1892,11 +1884,7 @@ def test_BigMath_exp_with_rational end def test_BigMath_exp_under_gc_stress - # for test-bundled-gems in ruby/ruby repository - extension_paths = Dir.glob(File.expand_path('../../../../../.bundle/extensions', __dir__) + '/**/*/bigdecimal-*').join(":") - opts = ["-rbigdecimal", "--disable-gems"] - opts.unshift "-I#{extension_paths}" unless extension_paths.empty? - assert_in_out_err(opts, <<-EOS, [], []) + assert_in_out_err(["-I#{$LOAD_PATH.join(":")}", "-rbigdecimal", "--disable-gems"], <<-EOS, [], []) expect = ":too_long_to_embed_as_string can't be coerced into BigDecimal" 10.times do begin @@ -2038,11 +2026,7 @@ def test_BigMath_log_with_reciprocal_of_42 end def test_BigMath_log_under_gc_stress - # for test-bundled-gems in ruby/ruby repository - extension_paths = Dir.glob(File.expand_path('../../../../../.bundle/extensions', __dir__) + '/**/*/bigdecimal-*').join(":") - opts = ["-rbigdecimal", "--disable-gems"] - opts.unshift "-I#{extension_paths}" unless extension_paths.empty? - assert_in_out_err(opts, <<-EOS, [], []) + assert_in_out_err(["-I#{$LOAD_PATH.join(":")}", "-rbigdecimal", "--disable-gems"], <<-EOS, [], []) expect = ":too_long_to_embed_as_string can't be coerced into BigDecimal" 10.times do begin @@ -2089,11 +2073,7 @@ def test_to_d end if RUBY_VERSION < '2.5' # mathn was removed from Ruby 2.5 def test_bug6406 - # for test-bundled-gems in ruby/ruby repository - extension_paths = Dir.glob(File.expand_path('../../../../../.bundle/extensions', __dir__) + '/**/*/bigdecimal-*').join(":") - opts = ["-rbigdecimal", "--disable-gems"] - opts.unshift "-I#{extension_paths}" unless extension_paths.empty? - assert_in_out_err(opts, <<-EOS, [], []) + assert_in_out_err(["-I#{$LOAD_PATH.join(":")}", "-rbigdecimal", "--disable-gems"], <<-EOS, [], []) Thread.current.keys.to_s EOS end From 758fc62a52cbf382788c7aa9eca170d5ba9d7648 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Wed, 17 Jan 2024 19:34:25 +0900 Subject: [PATCH 4/7] We need to care assert_no_memory_leak too --- test/bigdecimal/test_bigdecimal.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb index 078b059c..bab23a47 100644 --- a/test/bigdecimal/test_bigdecimal.rb +++ b/test/bigdecimal/test_bigdecimal.rb @@ -2283,7 +2283,7 @@ def test_bsearch_for_bigdecimal def assert_no_memory_leak(code, *rest, **opt) code = "8.times {20_000.times {begin #{code}; rescue NoMemoryError; end}; GC.start}" - super(["-rbigdecimal"], + super(["-I#{$LOAD_PATH.join(":")}", "-rbigdecimal"], "b = BigDecimal('10'); b.nil?; " \ "GC.add_stress_to_class(BigDecimal); "\ "#{code}", code, *rest, rss: true, limit: 1.1, **opt) From 2aab78bee1d24f2c29d89ef905d16539bcd036be Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Wed, 17 Jan 2024 21:12:31 +0900 Subject: [PATCH 5/7] BigDecimal() is obsoleted today. We shouldn't test it --- test/bigdecimal/test_bigdecimal.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb index bab23a47..866cd962 100644 --- a/test/bigdecimal/test_bigdecimal.rb +++ b/test/bigdecimal/test_bigdecimal.rb @@ -2294,10 +2294,6 @@ def test_no_memory_leak_allocate assert_no_memory_leak("BigDecimal.allocate") end - def test_no_memory_leak_initialize - assert_no_memory_leak("BigDecimal()") - end - def test_no_memory_leak_BigDecimal assert_no_memory_leak("BigDecimal('10')") assert_no_memory_leak("BigDecimal(b)") From c25d93e0e465b50dd3f197838f7ac0311a91ee00 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Wed, 17 Jan 2024 21:12:53 +0900 Subject: [PATCH 6/7] BigDecimal.allocate is obsoleted too --- test/bigdecimal/test_bigdecimal.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb index 866cd962..898eb7ec 100644 --- a/test/bigdecimal/test_bigdecimal.rb +++ b/test/bigdecimal/test_bigdecimal.rb @@ -2290,10 +2290,6 @@ def assert_no_memory_leak(code, *rest, **opt) end if EnvUtil.gc_stress_to_class? - def test_no_memory_leak_allocate - assert_no_memory_leak("BigDecimal.allocate") - end - def test_no_memory_leak_BigDecimal assert_no_memory_leak("BigDecimal('10')") assert_no_memory_leak("BigDecimal(b)") From a77d7751382f4947bf1f5fa98a380f3c2eb7bde9 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 18 Jan 2024 11:54:24 +0900 Subject: [PATCH 7/7] Don't use : for Windows platforms --- test/bigdecimal/test_bigdecimal.rb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb index 898eb7ec..41d8bad7 100644 --- a/test/bigdecimal/test_bigdecimal.rb +++ b/test/bigdecimal/test_bigdecimal.rb @@ -1768,7 +1768,8 @@ def test_ctov def test_split_under_gc_stress bug3258 = '[ruby-dev:41213]' expect = 10.upto(20).map{|i|[1, "1", 10, i+1].inspect} - assert_in_out_err(["-I#{$LOAD_PATH.join(":")}", "-rbigdecimal", "--disable-gems"], <<-EOS, expect, [], bug3258) + paths = $LOAD_PATH.map{|path| "-I#{path}" } + assert_in_out_err([*paths, "-rbigdecimal", "--disable-gems"], <<-EOS, expect, [], bug3258) GC.stress = true 10.upto(20) do |i| p BigDecimal("1"+"0"*i).split @@ -1777,7 +1778,8 @@ def test_split_under_gc_stress end def test_coerce_under_gc_stress - assert_in_out_err(["-I#{$LOAD_PATH.join(":")}", "-rbigdecimal", "--disable-gems"], <<-EOS, [], []) + paths = $LOAD_PATH.map{|path| "-I#{path}" } + assert_in_out_err([*paths, "-rbigdecimal", "--disable-gems"], <<-EOS, [], []) expect = ":too_long_to_embed_as_string can't be coerced into BigDecimal" b = BigDecimal("1") GC.stress = true @@ -1884,7 +1886,8 @@ def test_BigMath_exp_with_rational end def test_BigMath_exp_under_gc_stress - assert_in_out_err(["-I#{$LOAD_PATH.join(":")}", "-rbigdecimal", "--disable-gems"], <<-EOS, [], []) + paths = $LOAD_PATH.map{|path| "-I#{path}" } + assert_in_out_err([*paths, "-rbigdecimal", "--disable-gems"], <<-EOS, [], []) expect = ":too_long_to_embed_as_string can't be coerced into BigDecimal" 10.times do begin @@ -2026,7 +2029,8 @@ def test_BigMath_log_with_reciprocal_of_42 end def test_BigMath_log_under_gc_stress - assert_in_out_err(["-I#{$LOAD_PATH.join(":")}", "-rbigdecimal", "--disable-gems"], <<-EOS, [], []) + paths = $LOAD_PATH.map{|path| "-I#{path}" } + assert_in_out_err([*paths, "-rbigdecimal", "--disable-gems"], <<-EOS, [], []) expect = ":too_long_to_embed_as_string can't be coerced into BigDecimal" 10.times do begin @@ -2073,7 +2077,8 @@ def test_to_d end if RUBY_VERSION < '2.5' # mathn was removed from Ruby 2.5 def test_bug6406 - assert_in_out_err(["-I#{$LOAD_PATH.join(":")}", "-rbigdecimal", "--disable-gems"], <<-EOS, [], []) + paths = $LOAD_PATH.map{|path| "-I#{path}" } + assert_in_out_err([*paths, "-rbigdecimal", "--disable-gems"], <<-EOS, [], []) Thread.current.keys.to_s EOS end @@ -2283,7 +2288,8 @@ def test_bsearch_for_bigdecimal def assert_no_memory_leak(code, *rest, **opt) code = "8.times {20_000.times {begin #{code}; rescue NoMemoryError; end}; GC.start}" - super(["-I#{$LOAD_PATH.join(":")}", "-rbigdecimal"], + paths = $LOAD_PATH.map{|path| "-I#{path}" } + super([*paths, "-rbigdecimal"], "b = BigDecimal('10'); b.nil?; " \ "GC.add_stress_to_class(BigDecimal); "\ "#{code}", code, *rest, rss: true, limit: 1.1, **opt)