[前][次][番号順一覧][スレッド一覧]

ruby-changes:70723

From: Yusuke <ko1@a...>
Date: Tue, 4 Jan 2022 17:38:58 +0900 (JST)
Subject: [ruby-changes:70723] 426ddbfff5 (master): test/ruby/test_method.rb: Fix a random failure during `make COVERAGE=1`

https://git.ruby-lang.org/ruby.git/commit/?id=426ddbfff5

From 426ddbfff5e3106db52456e2b91a23f2f1644872 Mon Sep 17 00:00:00 2001
From: Yusuke Endoh <mame@r...>
Date: Tue, 4 Jan 2022 17:34:28 +0900
Subject: test/ruby/test_method.rb: Fix a random failure during `make
 COVERAGE=1`

This fixes the following failure.

```
1) Error:
TestMethod#test_method_list:
NoMethodError: undefined method `<=>' for #<BasicObject:0x00007f7757e7eb60>

      mods = mods.sort_by {|m| m.name }
                 ^^^^^^^^
```
https://github.com/ruby/actions/runs/4699487470?check_suite_focus=true

TestNoMethodError#test_to_s creates an anonymous module whose `#name`
method returns a BasicObject.

https://github.com/ruby/ruby/blob/f0669fb6cbdbad499974252ef2d955a608d0adc1/test/ruby/test_nomethod_error.rb#L95-L99

TestMethod#test_method_list uses `ObjectSpace.each_object(Module)` to
gather all Modules and attempts to sort them by `#name`.
But the anonymous module returns a BasicObject, which leads to the test
failure above.
---
 test/ruby/test_method.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb
index 0da69fd4e4b..8f68df7b245 100644
--- a/test/ruby/test_method.rb
+++ b/test/ruby/test_method.rb
@@ -1409,7 +1409,7 @@ class TestMethod < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_method.rb#L1409
     # use_symbol = Object.instance_methods[0].is_a?(Symbol)
     nummodule = nummethod = 0
     mods = []
-    ObjectSpace.each_object(Module) {|m| mods << m if m.name }
+    ObjectSpace.each_object(Module) {|m| mods << m if Symbol === m.name }
     mods = mods.sort_by {|m| m.name }
     mods.each {|mod|
       nummodule += 1
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]