diff options
| author | aycabta <aycabta@gmail.com> | 2021-08-06 03:15:58 +0900 |
|---|---|---|
| committer | aycabta <aycabta@gmail.com> | 2021-08-06 03:15:58 +0900 |
| commit | cd57b39f79e4304f5b9b4585592a3bd765392a8f (patch) | |
| tree | 1b0110bb363c0211d0df1b652177a6ba328eb5ee | |
| parent | 7bcbee37b5feda172b1651b34a5c3d058db04611 (diff) | |
Fix control structure to preperly catch Timeout::Error
| -rw-r--r-- | test/readline/test_readline.rb | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/test/readline/test_readline.rb b/test/readline/test_readline.rb index a68879222e..8ede81a213 100644 --- a/test/readline/test_readline.rb +++ b/test/readline/test_readline.rb @@ -510,32 +510,34 @@ module BasetestReadline 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 |
