ruby-changes:61308
From: Yusuke <ko1@a...>
Date: Thu, 21 May 2020 13:27:39 +0900 (JST)
Subject: [ruby-changes:61308] 3eb3f7bb8c (master): test/ruby/test_optimization.rb: Proc creation test should count :T_DATA
https://git.ruby-lang.org/ruby.git/commit/?id=3eb3f7bb8c From 3eb3f7bb8c3da4d3e71246ad011c580b6ad68d78 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh <mame@r...> Date: Thu, 21 May 2020 13:16:42 +0900 Subject: test/ruby/test_optimization.rb: Proc creation test should count :T_DATA instead of :TOTAL of ObjectSpace.count_objects. This test had failed very occasionally: https://rubyci.org/logs/rubyci.s3.amazonaws.com/centos8/ruby-master/log/20200521T033004Z.fail.html.gz ``` 1) Failure: TestRubyOptimization#test_block_parameter_should_not_create_objects [/home/chkbuild/chkbuild/tmp/build/20200521T033004Z/ruby/test/ruby/test_optimization.rb:713]: <0> expected but was <407>. ``` This test of lazy proc creation checks if no object is created during a method call. However, calling a method itself increases the count of objects because method cache is now an object (T_MEMO). The reason why this test rarely fails is because the test was buggy; it checked the count of :TOTAL, but :TOTAL count changes only when the GC heap is expanded. Creating one object rarely causes heap expansion. The test must have checked not only :TOTAL but also the count of :FREE. Instead, this change more directly checks :T_DATA. Note that a Proc object is T_DATA. diff --git a/test/ruby/test_optimization.rb b/test/ruby/test_optimization.rb index e6163c0..7f2db19 100644 --- a/test/ruby/test_optimization.rb +++ b/test/ruby/test_optimization.rb @@ -710,7 +710,7 @@ class TestRubyOptimization < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_optimization.rb#L710 foo{} ObjectSpace.count_objects(h2) - assert_equal 0, h2[:TOTAL] - h1[:TOTAL] + assert_equal 0, h2[:T_DATA] - h1[:T_DATA] # Proc is T_DATA END end -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/