Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
language: ruby
dist: trusty
os:
- linux
- osx

rvm:
- 1.9.3
- 2.0.0
- 2.1.10
- 2.2.8
- 2.3.5
- 2.4.2
- 2.5.0-preview1
- ruby-head

matrix:
fast_finish: true
allow_failures:
- rvm: ruby-head

exclude:
- os: osx
rvm: 1.9.3
- os: osx
rvm: 2.0.0
- os: linux
rvm: 2.5.0-preview1

# include:
# - os: osx
# rvm: 1.9.3
# before_script: rvm install ruby-1.9.3 # not binary
# - os: osx
# rvm: 2.0.0
# before_script: rvm install ruby-2.0.0 # not binary
17 changes: 15 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
source "http://rubygems.org"

gem "ruby-debug-base", :platforms => [:jruby, :ruby_18, :mingw_18]
gem "ruby-debug-base19x", ">= 0.11.30.pre4", :platforms => [:ruby_19, :mingw_19]
# @param [Array<String>] versions compatible ruby versions
# @return [Array<String>] an array with mri platforms of given versions
def mries(*versions)
versions.flat_map do |v|
%w(ruby mingw x64_mingw)
.map { |platform| "#{platform}_#{v}".to_sym unless platform == "x64_mingw" && v < "2.0" }
.delete_if &:nil?
end
end

gem "ruby-debug-base", :platforms => [:jruby, *mries('18')]
gem "ruby-debug-base19x", ">= 0.11.32", :platforms => mries('19')
if RUBY_VERSION && RUBY_VERSION >= "2.0"
gem "debase", ">= 0.2.2.beta14", :platforms => mries('20', '21', '22', '23', '24', '25')
end

gemspec

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ An interface which glues ruby-debug to IDEs like Eclipse (RDT), NetBeans and Rub

[![official JetBrains project](http://jb.gg/badges/official.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
[![Gem Version](https://badge.fury.io/rb/ruby-debug-ide.svg)][gem]
[![Build Status](https://travis-ci.org/ruby-debug/ruby-debug-ide.svg?branch=master)](https://travis-ci.org/ruby-debug/ruby-debug-ide)
2 changes: 1 addition & 1 deletion lib/ruby-debug-ide.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def start_control(host, port, notify_dispatcher)
# "localhost" and nil have problems on some systems.
host ||= '127.0.0.1'
server = TCPServer.new(host, port)
print_greeting_msg($stderr, host, port)
print_greeting_msg($stderr, host, port) if defined? IDE_VERSION
notify_dispatcher(port) if notify_dispatcher
while (session = server.accept)
$stderr.puts "Connected from #{session.peeraddr[2]}" if Debugger.cli_debug
Expand Down
6 changes: 6 additions & 0 deletions lib/ruby-debug-ide/command.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
if RUBY_VERSION < '2.0' || defined?(JRUBY_VERSION)
require 'ruby-debug-base'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

19x?

else
require 'debase'
end

require 'ruby-debug-ide/helper'
require 'delegate'

Expand Down
2 changes: 1 addition & 1 deletion lib/ruby-debug-ide/commands/expression_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def regexp
end

def execute
string_to_parse = Command.unescape_incoming(@match.post_match) + " \n\n\n"
string_to_parse = Command.unescape_incoming(@match.post_match) + " \n \n\n"
total_lines = string_to_parse.count("\n") + 1

lexer = RubyLex.new
Expand Down
12 changes: 8 additions & 4 deletions test-base/test_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def teardown
send_ruby("cont")
end
debug "Waiting for the server process to finish..."
(config_load('server_start_up_timeout')*4).times do
(config_load('server_start_up_timeout')*5).times do
unless @process_finished
debug '.'
sleep 0.25
Expand Down Expand Up @@ -86,7 +86,7 @@ def start_ruby_process(script)
@port = TestBase.find_free_port
cmd = debug_command(script, @port)
debug "Starting: #{cmd}\n"

Thread.new do
if RUBY_VERSION < '1.9'
(_, p_out, p_err) = Open3.popen3(cmd)
Expand Down Expand Up @@ -132,7 +132,8 @@ def TestBase.find_free_port(port = 1098)
end

def create_file(script_name, lines)
script_path = File.join(TMP_DIR, script_name)
script_path = File.realdirpath(File.join(TMP_DIR, script_name))

File.open(script_path, "w") do |script|
script.printf(lines.join("\n"))
end
Expand All @@ -141,7 +142,7 @@ def create_file(script_name, lines)

def create_test2(lines)
@test2_name = "test2.rb"
@test2_path = create_file(@test2_name, lines)
@test2_path = create_file(@test2_name, lines).force_encoding(Encoding::UTF_8)
end

# Creates test.rb with the given lines, set up @test_name and @test_path
Expand Down Expand Up @@ -222,7 +223,9 @@ def assert_suspension(exp_file, exp_line, exp_frames, exp_thread_id=1)
suspension = read_suspension
assert_equal(exp_file, suspension.file)
assert_equal(exp_line, suspension.line)
exp_frames += 2 if Debugger::FRONT_END == "debase"
assert_equal(exp_frames, suspension.frames)
exp_thread_id += 1 if Debugger::FRONT_END == "debase"
assert_equal(exp_thread_id, suspension.threadId)
end

Expand Down Expand Up @@ -271,6 +274,7 @@ def assert_exception(exp_file, exp_line, exp_type, exp_thread_id=1)
assert_equal(exp_file, exception.file)
assert_equal(exp_line, exception.line)
assert_equal(exp_type, exception.type)
exp_thread_id += 1 if Debugger::FRONT_END == "debase"
assert_equal(exp_thread_id, exception.threadId)
assert_not_nil(exception.message)
end
Expand Down
18 changes: 15 additions & 3 deletions test-base/threads_and_frames_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ def test_frames
assert_breakpoint_added_no(2)
send_ruby("w")
frames = read_frames
assert_equal(2, frames.length)

needed_frame_length = 2
needed_frame_length += 2 if Debugger::FRONT_END == "debase"
assert_equal(needed_frame_length, frames.length)

frame1 = frames[0]
assert_equal(@test2_path, frame1.file)
assert_equal(1, frame1.no)
Expand All @@ -27,7 +31,11 @@ def test_frames
assert_test_breakpoint(4)
send_ruby("w")
frames = read_frames
assert_equal(1, frames.length)

needed_frame_length = 1
needed_frame_length += 2 if Debugger::FRONT_END == "debase"

assert_equal(needed_frame_length, frames.length)
send_cont # test:4 -> test2:3
assert_breakpoint("test2.rb", 3)
send_cont # test2:3 -> finish
Expand All @@ -42,7 +50,11 @@ def test_frames_when_thread_spawned
"def calc", "5 + 5", "end", "start_thread()", "calc()"]
run_to_line(5)
send_ruby("w")
assert_equal(2, read_frames.length)

needed_length = 2
needed_length += 2 if Debugger::FRONT_END == "debase"

assert_equal(needed_length, read_frames.length)
send_cont
end

Expand Down
61 changes: 49 additions & 12 deletions test-base/variables_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# encoding: utf-8

$:.unshift File.join(File.dirname(__FILE__), "..", "lib")

Expand All @@ -25,7 +26,7 @@ def test_variable_with_xml_content
{:name => "stringA"},
{:name => "testHashValue"})
# will receive ''
assert_equal("<start test=\"&\"/>", variables[0].value)
assert_equal(CGI.escapeHTML("<start test=\"&\"/>"), variables[0].value)
assert_local(variables[0])
# the testHashValue contains an example, where the name consists of special
# characters
Expand All @@ -46,7 +47,7 @@ def test_variable_in_object
{:name => "self", :value => "test", :type => "Test", :hasChildren => true})
send_ruby("v i self")
assert_variables(read_variables, 1,
{:name => "@y", :value => "5", :type => "Fixnum", :hasChildren => false, :kind => "instance"})
{:name => "@y", :value => "5", :type => int_type_name, :hasChildren => false, :kind => "instance"})
send_cont
end

Expand All @@ -59,7 +60,7 @@ def test_class_variables
{:name => "self", :hasChildren => true})
send_ruby("v i self")
assert_variables(read_variables, 1,
{:name => "@@class_var", :value => "55", :type => "Fixnum", :kind => "class"})
{:name => "@@class_var", :value => "55", :type => int_type_name, :kind => "class"})
send_cont
end

Expand All @@ -69,7 +70,7 @@ def test_singleton_class_variables
run_to_line(3)
send_ruby("v i self")
assert_variables(read_variables, 1,
{:name => "@@class_var", :value => "55", :type => "Fixnum", :hasChildren => false, :kind => "class"})
{:name => "@@class_var", :value => "55", :type => int_type_name, :hasChildren => false, :kind => "class"})
send_cont
end

Expand All @@ -94,17 +95,19 @@ def test_variable_local
assert_not_nil variables[1].objectId
send_ruby("v i " + variables[1].objectId) # 'user' variable
assert_variables(read_variables, 1,
{:name => "@id", :value => "22", :type => "Fixnum", :hasChildren => false})
{:name => "@id", :value => "22", :type => int_type_name, :hasChildren => false})
send_cont
end

def test_variable_instance
create_socket ["require 'test2.rb'", "custom_object=Test2.new", "puts custom_object"]
create_socket ["require_relative 'test2.rb'", "custom_object=Test2.new", "puts custom_object"]
create_test2 ["class Test2", "def initialize", "@y=5", "end", "def to_s", "'test'", "end", "end"]
run_to("test2.rb", 6)
send_ruby("frame 3; v i custom_object")
frame_number = 3
frame_number -= 1 if Debugger::FRONT_END == "debase"
send_ruby("frame #{frame_number}; v i custom_object")
assert_variables(read_variables, 1,
{:name => "@y", :value => "5", :type => "Fixnum", :hasChildren => false})
{:name => "@y", :value => "5", :type => int_type_name, :hasChildren => false})
send_cont
end

Expand All @@ -116,7 +119,7 @@ def test_variable_array
{:name => "array", :type => "Array", :hasChildren => true})
send_ruby("v i array")
assert_variables(read_variables, 2,
{:name => "[0]", :value => "1", :type => "Fixnum"})
{:name => "[0]", :value => "1", :type => int_type_name})
send_cont
end

Expand All @@ -128,7 +131,7 @@ def test_variable_hash_with_string_keys
{:name => "hash", :hasChildren => true})
send_ruby("v i hash")
assert_variables(read_variables, 2,
{:name => "'a'", :value => "z", :type => "String"})
{:name => CGI.escape_html("'a'"), :value => "z", :type => "String"})
send_cont
end

Expand All @@ -149,7 +152,7 @@ def test_variable_hash_with_object_keys
# get the value
send_ruby("frame 1 ; v i " + elements[0].objectId)
assert_variables(read_variables, 1,
{:name => "@a", :value => "66", :type => "Fixnum"})
{:name => "@a", :value => "66", :type => int_type_name})
send_cont
end

Expand All @@ -176,7 +179,7 @@ def test_non_string_from_to_s
create_socket ["class BugExample; def to_s; 1; end; end", "b = BugExample.new", "sleep 0.01"]
run_to_line(3)
send_ruby("v local")
assert_variables(read_variables, 1, {:value => "ERROR: BugExample.to_s method returns Fixnum. Should return String."})
assert_variables(read_variables, 1, {:value => "ERROR: BugExample.to_s method returns #{int_type_name}. Should return String."})
send_cont
end

Expand All @@ -196,6 +199,34 @@ def test_to_s_raises_exception
send_cont
end

def test_to_s_timelimit
create_socket ['class A',
'def to_s',
'a = 1',
'loop do',
'a = a + 1',
'sleep 1',
'break if (a > 2)',
'end',
'a.to_s',
'end',
'end',
'b = Hash.new',
'b[A.new] = A.new',
'b[1] = A.new',
'puts b #bp here']
run_to_line(15)
send_ruby('v l')
assert_variables(read_variables, 1,
{:name => "b", :value => "Hash (2 elements)", :type => "Hash"})

send_ruby("v i b")
assert_variables(read_variables, 2,
{:name => "Timeout: evaluation of to_s took longer than 100ms.", :value => "Timeout: evaluation of to_s took longer than 100ms.", :type => "A"},
{:name => "1", :value => "Timeout: evaluation of to_s took longer than 100ms.", :type => "A"})
send_cont
end

def assert_xml(expected_xml, actual_xml)
# XXX is there a better way then html_escape in standard libs?
assert_equal(ERB::Util.html_escape(expected_xml), actual_xml)
Expand Down Expand Up @@ -230,5 +261,11 @@ def assert_variables(vars, count, *expected)
end
end

private

def int_type_name
(Fixnum || Integer).name
end

end

2 changes: 1 addition & 1 deletion test/rd_test_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def debug_command(script, port)
cmd << " -J-Xdebug -J-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y" if jruby? and debug_jruby?
cmd << " -I 'lib:#{File.dirname(script)}' #{@rdebug_ide}" +
(@verbose_server ? " -d" : "") +
" -p #{port} -- '#{script}'"
" -p #{port} --evaluation-control --time-limit 100 --memory-limit 0 -- '#{script}'"
end

def start_debugger
Expand Down
9 changes: 6 additions & 3 deletions test/ruby-debug/xml_printer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def test_print_frames
test_path = File.join(Dir.pwd, 'test.rb')
expected = [
"<frames>",
"<frame no='1' file='#{test_path}' line='0' current='true' />",
"<frame no='2' file='#{test_path}' line='10' />",
"<frame no=\"1\" file=\"#{test_path}\" line=\"0\" current='true' />",
"<frame no=\"2\" file=\"#{test_path}\" line=\"10\" />",
"</frames>"]
assert_equal(expected, interface.data)
end
Expand All @@ -64,7 +64,10 @@ def test_print_at_line
Debugger.stop
end
test_path = File.join(Dir.pwd, 'test.rb')
expected = ["<suspended file='#{test_path}' line='1' threadId='1' frames='#{RUBY_VERSION < '1.9' ? 4 : 5}'/>"]

#TODO investigate
expected = ["<suspended file=\"#{test_path}\" line=\"1\" threadId=\"1\" frames=\"#{Debugger::FRONT_END == 'debase' ? 0 : 4}\"/>"]

assert_equal(expected, interface.data)
end

Expand Down