diff --git a/lib/ruby-debug-ide/thread-alias/alias_thread.rb b/lib/ruby-debug-ide/thread-alias/alias_thread.rb deleted file mode 100644 index a37eddb..0000000 --- a/lib/ruby-debug-ide/thread-alias/alias_thread.rb +++ /dev/null @@ -1,2 +0,0 @@ -OldThread = Thread -Thread = Debugger::DebugThread \ No newline at end of file diff --git a/lib/ruby-debug-ide/thread-alias/unalias_thread.rb b/lib/ruby-debug-ide/thread-alias/unalias_thread.rb deleted file mode 100644 index 8ead867..0000000 --- a/lib/ruby-debug-ide/thread-alias/unalias_thread.rb +++ /dev/null @@ -1 +0,0 @@ -Thread = OldThread \ No newline at end of file diff --git a/lib/ruby-debug-ide/thread_alias.rb b/lib/ruby-debug-ide/thread_alias.rb index 1cc38d4..4e10a7b 100644 --- a/lib/ruby-debug-ide/thread_alias.rb +++ b/lib/ruby-debug-ide/thread_alias.rb @@ -2,11 +2,25 @@ module Debugger module TimeoutHandler class << self def do_thread_alias - load File.expand_path(File.dirname(__FILE__) + '/thread-alias/alias_thread.rb') + if defined? ::OldThread + Debugger.print_debug 'Tried to re-alias thread for eval' + return + end + + Object.const_set :OldThread, ::Thread + Object.send :remove_const, :Thread + Object.const_set :Thread, ::Debugger::DebugThread end def undo_thread_alias - load File.expand_path(File.dirname(__FILE__) + '/thread-alias/unalias_thread.rb') + unless defined? ::OldThread + Debugger.print_debug 'Tried to de-alias thread twice' + return + end + + Object.send :remove_const, :Thread + Object.const_set :Thread, ::OldThread + Object.send :remove_const, :OldThread end end end diff --git a/lib/ruby-debug-ide/version.rb b/lib/ruby-debug-ide/version.rb index d14c8d8..36552ae 100755 --- a/lib/ruby-debug-ide/version.rb +++ b/lib/ruby-debug-ide/version.rb @@ -1,3 +1,3 @@ module Debugger - IDE_VERSION='0.7.0.beta2' + IDE_VERSION='0.7.0.beta3' end diff --git a/test-base/inspect_test.rb b/test-base/inspect_test.rb index ca57de8..c130bc0 100644 --- a/test-base/inspect_test.rb +++ b/test-base/inspect_test.rb @@ -58,6 +58,26 @@ def test_inspect_error_2 send_cont end + def test_inspect_expr_with_timeout + create_socket ["require 'timeout'", "puts 'test'"] + run_to_line(2) + send_ruby("v inspect (Timeout::timeout(10) { nil })") + variables = read_variables + assert_equal(1, variables.length, "There is one variable returned which is nil.") + assert_equal(nil, variables[0].value) + send_cont + end + + def test_inspect_failing_expr_with_timeout + create_socket ["require 'timeout'", "puts 'test'"] + run_to_line(2) + send_ruby("v inspect (Timeout::timeout(0.1) { sleep 0.2 })") + variables = read_variables + assert_equal(1, variables.length, "There is one variable returned which is nil.") + assert_equal("Timeout::Error", variables[0].type) + send_cont + end + def test_inspect_multiline_expression create_socket ["sleep 0.1"] run_to_line(1)