summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authortomoya ishida <tomoyapenguin@gmail.com>2024-03-25 20:48:08 +0900
committergit <svn-admin@ruby-lang.org>2024-03-25 11:48:11 +0000
commitf53209f02370b3590662de76fe63ec2818633139 (patch)
treef082ac3f31cd1b8713482fdd81b687fb1f1ec9bb /test
parent5f334b67d23f1397b71931646c96fb6b8aa96e08 (diff)
[ruby/irb] Cache RDoc::RI::Driver.new
(https://github.com/ruby/irb/pull/911) * Cache RDoc::RI::Driver.new to improve performance and to avoid flaky test * Insert sleep to fix flaky rendering test that renders document dialog https://github.com/ruby/irb/commit/da84e6cb56
Diffstat (limited to 'test')
-rw-r--r--test/irb/test_input_method.rb13
-rw-r--r--test/irb/yamatanooroti/test_rendering.rb4
2 files changed, 10 insertions, 7 deletions
diff --git a/test/irb/test_input_method.rb b/test/irb/test_input_method.rb
index 7644d3176a..ce317b4b32 100644
--- a/test/irb/test_input_method.rb
+++ b/test/irb/test_input_method.rb
@@ -88,17 +88,18 @@ module TestIRB
@driver = RDoc::RI::Driver.new(use_stdout: true)
end
- def display_document(target, bind)
+ def display_document(target, bind, driver = nil)
input_method = IRB::RelineInputMethod.new(IRB::RegexpCompletor.new)
+ input_method.instance_variable_set(:@rdoc_ri_driver, driver) if driver
input_method.instance_variable_set(:@completion_params, ['', target, '', bind])
- input_method.display_document(target, driver: @driver)
+ input_method.display_document(target)
end
def test_perfectly_matched_namespace_triggers_document_display
omit unless has_rdoc_content?
out, err = capture_output do
- display_document("String", binding)
+ display_document("String", binding, @driver)
end
assert_empty(err)
@@ -109,7 +110,7 @@ module TestIRB
def test_perfectly_matched_multiple_namespaces_triggers_document_display
result = nil
out, err = capture_output do
- result = display_document("{}.nil?", binding)
+ result = display_document("{}.nil?", binding, @driver)
end
assert_empty(err)
@@ -131,7 +132,7 @@ module TestIRB
def test_not_matched_namespace_triggers_nothing
result = nil
out, err = capture_output do
- result = display_document("Stri", binding)
+ result = display_document("Stri", binding, @driver)
end
assert_empty(err)
@@ -156,7 +157,7 @@ module TestIRB
def test_perfect_matching_handles_nil_namespace
out, err = capture_output do
# symbol literal has `nil` doc namespace so it's a good test subject
- assert_nil(display_document(":aiueo", binding))
+ assert_nil(display_document(":aiueo", binding, @driver))
end
assert_empty(err)
diff --git a/test/irb/yamatanooroti/test_rendering.rb b/test/irb/yamatanooroti/test_rendering.rb
index df4ec01a5c..44e07a3a12 100644
--- a/test/irb/yamatanooroti/test_rendering.rb
+++ b/test/irb/yamatanooroti/test_rendering.rb
@@ -256,9 +256,9 @@ class IRB::RenderingTest < Yamatanooroti::TestCase
start_terminal(3, 50, %W{ruby -I#{@pwd}/lib #{@pwd}/exe/irb}, startup_message: 'start IRB')
write("{}.__id_")
write("\C-i")
+ sleep 0.2
close
screen = result.join("\n").sub(/\n*\z/, "\n")
- # This assertion passes whether showdoc dialog completed or not.
assert_match(/start\ IRB\nirb\(main\):001> {}\.__id__\n }\.__id__(?:Press )?/, screen)
end
@@ -278,6 +278,7 @@ class IRB::RenderingTest < Yamatanooroti::TestCase
start_terminal(4, 19, %W{ruby -I#{@pwd}/lib #{@pwd}/exe/irb}, startup_message: 'start IRB')
write("IR")
write("\C-i")
+ sleep 0.2
close
# This is because on macOS we display different shortcut for displaying the full doc
@@ -315,6 +316,7 @@ class IRB::RenderingTest < Yamatanooroti::TestCase
start_terminal(4, 12, %W{ruby -I#{@pwd}/lib #{@pwd}/exe/irb}, startup_message: 'start IRB')
write("IR")
write("\C-i")
+ sleep 0.2
close
assert_screen(<<~EOC)
start IRB