ruby/irb

Flaky test case test_autocomplete_with_multiple_doc_namespaces

hogelog opened this issue · 0 comments

Description

In my environment, test_autocomplete_with_multiple_doc_namespaces (test/irb/yamatanooroti/test_rendering.rb) will almost certainly fail.

$ WITH_VTERM=1 bundle exec ruby -I test test/irb/yamatanooroti/test_rendering.rb -n test_autocomplete_with_multiple_doc_namespaces
Loaded suite test/irb/yamatanooroti/test_rendering
Started
/Users/hogelog/.rbenv/versions/3.3.0-preview2/lib/ruby/gems/3.3.0+0/bundler/gems/yamatanooroti-8539beef8dde/lib/yamatanooroti/vterm.rb:16: warning: undefining the allocator of T_DATA class VTerm::Screen
F
====================================================================================================================================================================================================================
Failure: test_autocomplete_with_multiple_doc_namespaces(IRB::RenderingTest::TestVTerm)
/Users/hogelog/.rbenv/versions/3.3.0-preview2/lib/ruby/gems/3.3.0+0/bundler/gems/yamatanooroti-8539beef8dde/lib/yamatanooroti/vterm.rb:114:in `assert_screen'
test/irb/yamatanooroti/test_rendering.rb:214:in `test_autocomplete_with_multiple_doc_namespaces'
     211:     write("{}.__id_")
     212:     write("\C-i")
     213:     close
  => 214:     assert_screen(<<~EOC)
     215:       start IRB
     216:       irb(main):001> {}.__id__
     217:                       }.__id__
<"start IRB\n" + "irb(main):001> {}.__id__\n" + "                }.__id__\n"> expected but was
<"start IRB\n" +
"irb(main):001> {}.__id__\n" +
"Press Option+d t}.__id__\n" +
"Hash.__id__\n">

diff:
  start IRB
  irb(main):001> {}.__id__
+ Press Option+d t}.__id__
?                 }.__id__
? Hash                    
? ?????????????????                    
====================================================================================================================================================================================================================
Finished in 1.540809 seconds.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 tests, 1 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
0% passed
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0.65 tests/s, 0.65 assertions/s

This test case sometimes succeeds in my environment.
And it has been mostly successful in CI.

In fact, when I type {}. __id_<C-i> in irb, I get the following completion candidates and RDoc.
So it seems correct that this test fails.

irb(main):001> {}.__id__
                }.__id__Press Option+d to read the full document
                        Hash.__id__                             
                                                                
                        (from ruby core)                        
                        Implementation from BasicObject         
                        ----------------------------------------
                          obj.__id__       -> integer           
                          obj.object_id    -> integer           
                                                                
                        ----------------------------------------

What is happening

The RDoc dialog display process is quite slow.

Reline::DialogRenderInfo.new(pos: Reline::CursorPos.new(x, y), contents: contents, width: width, bg_color: '49')

So when the dialog display is delayed, the test seems to succeed.

Result of irb_info

irb(main):001> irb_info
Ruby version: 3.3.0
IRB version: irb 1.9.1 (2023-11-21)
InputMethod: RelineInputMethod with Reline 0.4.0
Completion: Autocomplete, RegexpCompletor
RUBY_PLATFORM: arm64-darwin22
LANG env: ja_JP.UTF-8
East Asian Ambiguous Width: 1

Terminal Emulator

macOS
Terminal.app

Setting Files

Are you using ~/.irbrc and ~/.inputrc?

No.