Skip to content

Commit

Permalink
Merge pull request #429 from deivid-rodriguez/chore/test_against_2.5_…
Browse files Browse the repository at this point in the history
…on_appveyor

Test against ruby 2.5 on Appveyor
  • Loading branch information
deivid-rodriguez committed Jan 26, 2018
2 parents dfe05cb + e6ce456 commit ac34dfc
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 14 deletions.
4 changes: 4 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ environment:
ruby_abi_version: 2.4.0
- ruby_version: 24-x64
ruby_abi_version: 2.4.0
- ruby_version: "25"
ruby_abi_version: 2.5.0
- ruby_version: 25-x64
ruby_abi_version: 2.5.0
- ruby_version: head-x86
ruby_abi_version: 2.6.0
- ruby_version: head-x64
Expand Down
12 changes: 8 additions & 4 deletions lib/byebug/remote/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ module Remote
# Client for remote debugging
#
class Client
attr_reader :interface
attr_reader :interface, :socket

def initialize(interface)
@interface = interface
@socket = nil
end

#
# Connects to the remote byebug
#
def start(host = "localhost", port = PORT)
socket = connect_at(host, port)
connect_at(host, port)

while (line = socket.gets)
case line
Expand All @@ -38,13 +39,16 @@ def start(host = "localhost", port = PORT)
socket.close
end

def started?
!socket.nil?
end

private

def connect_at(host, port)
interface.puts "Connecting to byebug server at #{host}:#{port}..."
socket = TCPSocket.new(host, port)
@socket = TCPSocket.new(host, port)
interface.puts "Connected."
socket
end
end
end
Expand Down
32 changes: 22 additions & 10 deletions test/support/remote_debugging_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,19 @@ def remote_debug_and_connect(*commands)
remote_debug(*commands) do |wait_th|
launch_client

wait_for_client_startup

wait_th.value
end
end

def remote_debug_connect_and_interrupt(*commands)
remote_debug(*commands) do |wait_th|
th = Thread.new { launch_client }
sleep(7)
Thread.kill(th)

wait_for_client_startup

th.kill

wait_th.value
end
Expand All @@ -81,15 +85,23 @@ def remote_debug(*commands)
end
end

def wait_for_client_startup
sleep 0.1 until mutex.synchronize { client.started? }
end

def launch_client
Timeout.timeout(7) do
begin
Byebug.start_client("127.0.0.1")
rescue Errno::ECONNREFUSED
sleep 0.1
retry
end
end
mutex.synchronize { client.start("127.0.0.1") }
rescue Errno::ECONNREFUSED
sleep 0.1
retry
end

def mutex
@mutex ||= Mutex.new
end

def client
@client ||= Remote::Client.new(Context.interface)
end
end
end

0 comments on commit ac34dfc

Please sign in to comment.