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

ruby-changes:67056

From: aycabta <ko1@a...>
Date: Fri, 6 Aug 2021 03:50:35 +0900 (JST)
Subject: [ruby-changes:67056] cd57b39f79 (master): Fix control structure to preperly catch Timeout::Error

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

From cd57b39f79e4304f5b9b4585592a3bd765392a8f Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Fri, 6 Aug 2021 03:15:58 +0900
Subject: Fix control structure to preperly catch Timeout::Error

---
 test/readline/test_readline.rb | 52 ++++++++++++++++++++++--------------------
 1 file changed, 27 insertions(+), 25 deletions(-)

diff --git a/test/readline/test_readline.rb b/test/readline/test_readline.rb
index a688792..8ede81a 100644
--- a/test/readline/test_readline.rb
+++ b/test/readline/test_readline.rb
@@ -510,32 +510,34 @@ module BasetestReadline https://github.com/ruby/ruby/blob/trunk/test/readline/test_readline.rb#L510
     asserted = false
     current_dir = File.expand_path("..", __FILE__)
     log, status = EnvUtil.invoke_ruby(["-I#{current_dir}", path], "", true, :merge_to_stdout) do |_in, _out, _, pid|
-      Timeout.timeout(4) do
-        log = String.new
-        while c = _out.read(1)
-          log << c if c
-          break if log.include?('input>')
-        end
-        Process.kill(:INT, pid)
-        sleep 0.1
-        while c = _out.read(1)
-          log << c if c
-          break if log.include?('INT')
-        end
-        begin
-          _in.write "\n"
-        rescue Errno::EPIPE
-          # The "write" will fail if Reline crashed by SIGINT.
-        end
-        while c = _out.read(1)
-          log << c if c
-          if log.include?('FAILED')
-            assert false, "Should handle SIGINT correctly but failed."
-            asserted = true
+      begin
+        Timeout.timeout(4) do
+          log = String.new
+          while c = _out.read(1)
+            log << c if c
+            break if log.include?('input>')
           end
-          if log.include?('SUCCEEDED')
-            assert true, "Should handle SIGINT correctly but failed."
-            asserted = true
+          Process.kill(:INT, pid)
+          sleep 0.1
+          while c = _out.read(1)
+            log << c if c
+            break if log.include?('INT')
+          end
+          begin
+            _in.write "\n"
+          rescue Errno::EPIPE
+            # The "write" will fail if Reline crashed by SIGINT.
+          end
+          while c = _out.read(1)
+            log << c if c
+            if log.include?('FAILED')
+              assert false, "Should handle SIGINT correctly but failed."
+              asserted = true
+            end
+            if log.include?('SUCCEEDED')
+              assert true, "Should handle SIGINT correctly but failed."
+              asserted = true
+            end
           end
         end
       rescue Timeout::Error
-- 
cgit v1.1


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

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