Skip to content

Commit 59b1fcf

Browse files
committed
retry connection to avoid fragile tests
``` Error: test_next_goes_to_the_next_statement(DEBUGGER__::NextTest): Errno::ECONNREFUSED: Connection refused - connect(2) for 127.0.0.1:44075 /opt/hostedtoolcache/Ruby/2.6.10/x64/lib/ruby/2.6.0/socket.rb:64:in `connect' /opt/hostedtoolcache/Ruby/2.6.10/x64/lib/ruby/2.6.0/socket.rb:64:in `connect_internal' /opt/hostedtoolcache/Ruby/2.6.10/x64/lib/ruby/2.6.0/socket.rb:137:in `connect' /opt/hostedtoolcache/Ruby/2.6.10/x64/lib/ruby/2.6.0/socket.rb:641:in `block in tcp' /opt/hostedtoolcache/Ruby/2.6.10/x64/lib/ruby/2.6.0/socket.rb:227:in `each' /opt/hostedtoolcache/Ruby/2.6.10/x64/lib/ruby/2.6.0/socket.rb:227:in `foreach' /opt/hostedtoolcache/Ruby/2.6.10/x64/lib/ruby/2.6.0/socket.rb:631:in `tcp' /home/runner/work/debug/debug/test/support/protocol_test_case.rb:402:in `attach_to_cdp_server' /home/runner/work/debug/debug/test/support/protocol_test_case.rb:320:in `execute_cdp_scenario' /home/runner/work/debug/debug/test/support/protocol_test_case.rb:47:in `block in run_protocol_scenario' /opt/hostedtoolcache/Ruby/2.6.10/x64/lib/ruby/2.6.0/timeout.rb:93:in `block in timeout' /opt/hostedtoolcache/Ruby/2.6.10/x64/lib/ruby/2.6.0/timeout.rb:33:in `block in catch' /opt/hostedtoolcache/Ruby/2.6.10/x64/lib/ruby/2.6.0/timeout.rb:33:in `catch' /opt/hostedtoolcache/Ruby/2.6.10/x64/lib/ruby/2.6.0/timeout.rb:33:in `catch' /opt/hostedtoolcache/Ruby/2.6.10/x64/lib/ruby/2.6.0/timeout.rb:108:in `timeout' /home/runner/work/debug/debug/test/support/protocol_test_case.rb:44:in `run_protocol_scenario' /home/runner/work/debug/debug/test/protocol/next_test.rb:20:in `test_next_goes_to_the_next_statement' ```
1 parent 47b01da commit 59b1fcf

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

test/support/protocol_test_case.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,16 @@ def attach_to_cdp_server
399399
sleep 0.001 until @remote_info.debuggee_backlog.join.include? 'Disconnected.'
400400
end
401401

402-
sock = Socket.tcp HOST, @remote_info.port
402+
retry_cnt = 0
403+
begin
404+
sock = Socket.tcp HOST, @remote_info.port
405+
rescue Errno::ECONNREFUSED
406+
raise if (retry_cnt += 1) > 10 # retry up to 10 times
407+
408+
sleep 0.1
409+
retry
410+
end
411+
403412
uuid = body[0][:id]
404413

405414
Timeout.timeout(TIMEOUT_SEC) do

0 commit comments

Comments
 (0)