debugger 1.2.4 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +14 -0
- data/.travis.yml +0 -1
- data/CHANGELOG.md +9 -0
- data/Gemfile +3 -0
- data/README.md +2 -0
- data/Rakefile +3 -55
- data/debugger.gemspec +2 -0
- data/lib/debugger/version.rb +1 -1
- data/lib/ruby-debug-base.rb +3 -1
- data/lib/ruby-debug/commands/irb.rb +1 -1
- data/lib/ruby-debug/commands/jump.rb +1 -1
- data/lib/ruby-debug/commands/method.rb +1 -1
- data/lib/ruby-debug/commands/show.rb +1 -1
- data/lib/ruby-debug/commands/trace.rb +2 -2
- data/lib/ruby-debug/commands/variables.rb +3 -3
- data/test/breakpoints_test.rb +365 -0
- data/test/conditions_test.rb +76 -0
- data/test/continue_test.rb +28 -0
- data/test/display_test.rb +141 -0
- data/test/edit_test.rb +55 -0
- data/test/eval_test.rb +92 -0
- data/test/examples/breakpoint1.rb +15 -0
- data/test/examples/breakpoint2.rb +7 -0
- data/test/examples/conditions.rb +4 -0
- data/test/examples/continue.rb +4 -0
- data/test/examples/display.rb +5 -0
- data/test/examples/edit.rb +3 -0
- data/test/examples/edit2.rb +3 -0
- data/test/examples/eval.rb +4 -0
- data/test/examples/finish.rb +20 -0
- data/test/examples/frame.rb +31 -0
- data/test/examples/help.rb +2 -0
- data/test/examples/info.rb +48 -0
- data/test/examples/info2.rb +3 -0
- data/test/examples/irb.rb +6 -0
- data/test/examples/jump.rb +14 -0
- data/test/examples/kill.rb +2 -0
- data/test/examples/list.rb +12 -0
- data/test/examples/method.rb +15 -0
- data/test/examples/post_mortem.rb +19 -0
- data/test/examples/quit.rb +2 -0
- data/test/examples/reload.rb +6 -0
- data/test/examples/restart.rb +6 -0
- data/test/examples/save.rb +3 -0
- data/test/examples/set.rb +3 -0
- data/test/examples/set_annotate.rb +12 -0
- data/test/examples/settings.rb +1 -0
- data/test/examples/show.rb +2 -0
- data/test/examples/source.rb +3 -0
- data/test/examples/stepping.rb +21 -0
- data/test/examples/thread.rb +32 -0
- data/test/examples/tmate.rb +10 -0
- data/test/examples/trace.rb +7 -0
- data/test/examples/trace_threads.rb +20 -0
- data/test/examples/variables.rb +26 -0
- data/test/finish_test.rb +48 -0
- data/test/frame_test.rb +140 -0
- data/test/help_test.rb +50 -0
- data/test/info_test.rb +325 -0
- data/test/irb_test.rb +81 -0
- data/test/jump_test.rb +70 -0
- data/test/kill_test.rb +47 -0
- data/test/list_test.rb +145 -0
- data/test/method_test.rb +70 -0
- data/test/post_mortem_test.rb +25 -0
- data/test/quit_test.rb +55 -0
- data/test/reload_test.rb +43 -0
- data/test/restart_test.rb +143 -0
- data/test/save_test.rb +92 -0
- data/test/set_test.rb +163 -0
- data/test/show_test.rb +292 -0
- data/test/source_test.rb +44 -0
- data/test/stepping_test.rb +118 -0
- data/test/support/breakpoint.rb +12 -0
- data/test/support/context.rb +14 -0
- data/test/support/matchers.rb +67 -0
- data/test/support/mocha_extensions.rb +71 -0
- data/test/support/processor.rb +7 -0
- data/test/support/test_dsl.rb +205 -0
- data/test/support/test_interface.rb +66 -0
- data/test/test_helper.rb +8 -0
- data/test/thread_test.rb +122 -0
- data/test/tmate_test.rb +43 -0
- data/test/trace_test.rb +154 -0
- data/test/variables_test.rb +114 -0
- metadata +107 -158
- data/test/base/base.rb +0 -71
- data/test/base/binding.rb +0 -24
- data/test/base/catchpoint.rb +0 -22
- data/test/base/load.rb +0 -36
- data/test/bp_loop_issue.rb +0 -3
- data/test/classes.rb +0 -11
- data/test/config.yaml +0 -8
- data/test/data/annotate.cmd +0 -29
- data/test/data/annotate.right +0 -139
- data/test/data/break_bad.cmd +0 -18
- data/test/data/break_bad.right +0 -28
- data/test/data/break_loop_bug.cmd +0 -5
- data/test/data/break_loop_bug.right +0 -15
- data/test/data/breakpoints.cmd +0 -38
- data/test/data/breakpoints.right +0 -98
- data/test/data/catch.cmd +0 -20
- data/test/data/catch.right +0 -49
- data/test/data/catch2.cmd +0 -19
- data/test/data/catch2.right +0 -65
- data/test/data/catch3.cmd +0 -11
- data/test/data/catch3.right +0 -37
- data/test/data/condition.cmd +0 -28
- data/test/data/condition.right +0 -65
- data/test/data/ctrl.cmd +0 -23
- data/test/data/ctrl.right +0 -70
- data/test/data/display.cmd +0 -24
- data/test/data/display.right +0 -44
- data/test/data/dollar-0.right +0 -2
- data/test/data/dollar-0a.right +0 -2
- data/test/data/dollar-0b.right +0 -2
- data/test/data/edit.cmd +0 -12
- data/test/data/edit.right +0 -19
- data/test/data/emacs_basic.cmd +0 -43
- data/test/data/emacs_basic.right +0 -106
- data/test/data/enable.cmd +0 -20
- data/test/data/enable.right +0 -36
- data/test/data/finish.cmd +0 -16
- data/test/data/finish.right +0 -31
- data/test/data/frame.cmd +0 -26
- data/test/data/frame.right +0 -55
- data/test/data/help.cmd +0 -20
- data/test/data/help.right +0 -21
- data/test/data/history.right +0 -7
- data/test/data/info-thread.cmd +0 -13
- data/test/data/info-thread.right +0 -37
- data/test/data/info-var-bug2.cmd +0 -5
- data/test/data/info-var-bug2.right +0 -10
- data/test/data/info-var.cmd +0 -23
- data/test/data/info-var.right +0 -52
- data/test/data/info.cmd +0 -21
- data/test/data/info.right +0 -65
- data/test/data/jump.cmd +0 -16
- data/test/data/jump.right +0 -56
- data/test/data/jump2.cmd +0 -16
- data/test/data/jump2.right +0 -44
- data/test/data/linetrace.cmd +0 -6
- data/test/data/linetrace.right +0 -23
- data/test/data/list.cmd +0 -19
- data/test/data/list.right +0 -127
- data/test/data/method.cmd +0 -10
- data/test/data/method.right +0 -21
- data/test/data/methodsig.cmd +0 -10
- data/test/data/methodsig.right +0 -20
- data/test/data/next.cmd +0 -22
- data/test/data/next.right +0 -61
- data/test/data/noquit.right +0 -1
- data/test/data/output.cmd +0 -6
- data/test/data/output.right +0 -31
- data/test/data/pm-bug.cmd +0 -7
- data/test/data/pm-bug.right +0 -12
- data/test/data/post-mortem-next.cmd +0 -8
- data/test/data/post-mortem-next.right +0 -14
- data/test/data/post-mortem-osx.right +0 -31
- data/test/data/post-mortem.cmd +0 -13
- data/test/data/post-mortem.right +0 -32
- data/test/data/quit.cmd +0 -6
- data/test/data/quit.right +0 -0
- data/test/data/raise.cmd +0 -11
- data/test/data/raise.right +0 -23
- data/test/data/save.cmd +0 -34
- data/test/data/save.right +0 -59
- data/test/data/scope-var.cmd +0 -42
- data/test/data/scope-var.right +0 -587
- data/test/data/setshow.cmd +0 -56
- data/test/data/setshow.right +0 -98
- data/test/data/source.cmd +0 -5
- data/test/data/source.right +0 -15
- data/test/data/stepping.cmd +0 -21
- data/test/data/stepping.right +0 -50
- data/test/data/test-init-cygwin.right +0 -7
- data/test/data/test-init-osx.right +0 -4
- data/test/data/test-init.right +0 -5
- data/test/data/trace.right +0 -14
- data/test/dollar-0.rb +0 -5
- data/test/gcd-dbg-nox.rb +0 -30
- data/test/gcd-dbg.rb +0 -29
- data/test/gcd.rb +0 -18
- data/test/helper.rb +0 -142
- data/test/info-var-bug.rb +0 -47
- data/test/info-var-bug2.rb +0 -2
- data/test/jump.rb +0 -14
- data/test/jump2.rb +0 -27
- data/test/lib/commands/catchpoint_test.rb +0 -28
- data/test/lib/commands/unit/regexp.rb +0 -38
- data/test/next.rb +0 -18
- data/test/null.rb +0 -1
- data/test/output.rb +0 -2
- data/test/pm-base.rb +0 -17
- data/test/pm-bug.rb +0 -3
- data/test/pm-catch.rb +0 -12
- data/test/pm-catch2.rb +0 -27
- data/test/pm-catch3.rb +0 -47
- data/test/pm.rb +0 -11
- data/test/raise.rb +0 -3
- data/test/rdebug-save.1 +0 -7
- data/test/runall +0 -12
- data/test/scope-var.rb +0 -29
- data/test/tdebug.rb +0 -246
- data/test/test-annotate.rb +0 -24
- data/test/test-break-bad.rb +0 -36
- data/test/test-breakpoints.rb +0 -24
- data/test/test-catch.rb +0 -24
- data/test/test-catch2.rb +0 -24
- data/test/test-catch3.rb +0 -24
- data/test/test-condition.rb +0 -24
- data/test/test-ctrl.rb +0 -51
- data/test/test-display.rb +0 -25
- data/test/test-dollar-0.rb +0 -39
- data/test/test-edit.rb +0 -25
- data/test/test-emacs-basic.rb +0 -25
- data/test/test-enable.rb +0 -24
- data/test/test-finish.rb +0 -33
- data/test/test-frame.rb +0 -33
- data/test/test-help.rb +0 -54
- data/test/test-hist.rb +0 -65
- data/test/test-info-thread.rb +0 -31
- data/test/test-info-var.rb +0 -46
- data/test/test-info.rb +0 -25
- data/test/test-init.rb +0 -43
- data/test/test-jump.rb +0 -34
- data/test/test-list.rb +0 -24
- data/test/test-method.rb +0 -33
- data/test/test-next.rb +0 -24
- data/test/test-output.rb +0 -25
- data/test/test-quit.rb +0 -29
- data/test/test-raise.rb +0 -24
- data/test/test-remote.rb +0 -14
- data/test/test-save.rb +0 -30
- data/test/test-scope-var.rb +0 -24
- data/test/test-setshow.rb +0 -24
- data/test/test-source.rb +0 -24
- data/test/test-stepping.rb +0 -25
- data/test/test-trace.rb +0 -46
- data/test/thread1.rb +0 -25
- data/test/trunc-call.rb +0 -30
@@ -0,0 +1,66 @@
|
|
1
|
+
class TestInterface < Debugger::Interface
|
2
|
+
attr_reader :input_queue, :output_queue, :error_queue, :confirm_queue
|
3
|
+
attr_accessor :command_queue, :test_block, :print_queue
|
4
|
+
attr_accessor :restart_file, :history_save, :history_length, :readline_support, :histfile
|
5
|
+
def initialize
|
6
|
+
@input_queue = []
|
7
|
+
@output_queue = []
|
8
|
+
@error_queue = []
|
9
|
+
@confirm_queue = []
|
10
|
+
@command_queue = []
|
11
|
+
@print_queue = []
|
12
|
+
@readline_support = false
|
13
|
+
end
|
14
|
+
|
15
|
+
def errmsg(*args)
|
16
|
+
@error_queue << format(args)
|
17
|
+
end
|
18
|
+
|
19
|
+
def read_command(*args)
|
20
|
+
if @input_queue.empty? && test_block
|
21
|
+
test_block.call
|
22
|
+
self.test_block = nil
|
23
|
+
end
|
24
|
+
result = @input_queue.shift
|
25
|
+
result.is_a?(Proc) ? result.call : result
|
26
|
+
end
|
27
|
+
|
28
|
+
def print(*args)
|
29
|
+
@output_queue << format(args)
|
30
|
+
end
|
31
|
+
|
32
|
+
def confirm(message)
|
33
|
+
@confirm_queue << message
|
34
|
+
read_command message
|
35
|
+
end
|
36
|
+
|
37
|
+
def readline_support?
|
38
|
+
@readline_support
|
39
|
+
end
|
40
|
+
|
41
|
+
def finalize
|
42
|
+
end
|
43
|
+
|
44
|
+
def close
|
45
|
+
end
|
46
|
+
|
47
|
+
def inspect
|
48
|
+
[
|
49
|
+
"input_queue: #{input_queue.inspect}",
|
50
|
+
"output_queue: #{output_queue.inspect}",
|
51
|
+
"error_queue: #{error_queue.inspect}",
|
52
|
+
"confirm_queue: #{confirm_queue.inspect}",
|
53
|
+
"print_queue: #{print_queue.inspect}"
|
54
|
+
].join("\n")
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def format(args)
|
60
|
+
if args.size > 1
|
61
|
+
args.first % args[1..-1]
|
62
|
+
else
|
63
|
+
args.first
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/test/test_helper.rb
ADDED
data/test/thread_test.rb
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe "Thread Command" do
|
4
|
+
include TestDsl
|
5
|
+
let(:release) { 'eval Thread.main[:should_break] = true' }
|
6
|
+
|
7
|
+
describe "list" do
|
8
|
+
it "must show current thread by 'plus' sign" do
|
9
|
+
thnum = nil
|
10
|
+
enter 'break 8', 'cont', 'thread list', release
|
11
|
+
debug_file('thread') { thnum = Debugger.contexts.first.thnum }
|
12
|
+
check_output_includes '+', thnum.to_s, /#<Thread:\S+ run>/, "#{fullpath('thread')}:8"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "must work with shortcut" do
|
16
|
+
thnum = nil
|
17
|
+
enter 'break 8', 'cont', 'th list', release
|
18
|
+
debug_file('thread') { thnum = Debugger.contexts.first.thnum }
|
19
|
+
check_output_includes '+', thnum.to_s, /#<Thread:\S+ run>/, "#{fullpath('thread')}:8"
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
it "must show 3 available threads" do
|
24
|
+
enter 'break 21', 'cont', 'thread list', release
|
25
|
+
debug_file 'thread'
|
26
|
+
check_output_includes /#<Thread:\S+ (sleep|run)>/, /#<Thread:\S+ (sleep|run)>/, /#<Thread:\S+ (sleep|run)>/
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
describe "stop" do
|
32
|
+
it "must stop one of the threads" do
|
33
|
+
thnum = nil
|
34
|
+
enter 'break 21', 'cont', ->{"thread stop #{Debugger.contexts.last.thnum}"}, release
|
35
|
+
debug_file('thread') { thnum = Debugger.contexts.last.thnum }
|
36
|
+
check_output_includes "$", thnum.to_s, /#<Thread:/
|
37
|
+
end
|
38
|
+
|
39
|
+
it "must show error message if thread number is not specified" do
|
40
|
+
enter 'break 8', 'cont', "thread stop", release
|
41
|
+
debug_file 'thread'
|
42
|
+
check_output_includes "'thread stop' needs a thread number", interface.error_queue
|
43
|
+
end
|
44
|
+
|
45
|
+
it "must show error message when trying to stop current thread" do
|
46
|
+
enter 'break 8', 'cont', ->{"thread stop #{Debugger.contexts.first.thnum}"}, release
|
47
|
+
debug_file 'thread'
|
48
|
+
check_output_includes "It's the current thread.", interface.error_queue
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
describe "resume" do
|
54
|
+
|
55
|
+
# TODO: This test sometimes causes Segmentation Fault. No idea how to fix it...
|
56
|
+
it "must resume one of the threads"# do
|
57
|
+
# thnum = nil
|
58
|
+
# # If we don't put some sleep before 'thread resume', it may not change its status yet... :(
|
59
|
+
# enter(
|
60
|
+
# 'break 21',
|
61
|
+
# 'cont',
|
62
|
+
# -> do
|
63
|
+
# thnum = Debugger.contexts.last.thnum
|
64
|
+
# "thread stop #{thnum}"
|
65
|
+
# end,
|
66
|
+
# -> { puts; "thread resume #{thnum}" },
|
67
|
+
# -> { puts; release }
|
68
|
+
# )
|
69
|
+
# debug_file('thread') { Debugger.contexts.last.suspended?.must_equal false }
|
70
|
+
# check_output_includes "", thnum.to_s, /#<Thread:/
|
71
|
+
#end
|
72
|
+
|
73
|
+
it "must show error message if thread number is not specified" do
|
74
|
+
enter 'break 8', 'cont', "thread resume", release
|
75
|
+
debug_file 'thread'
|
76
|
+
check_output_includes "'thread resume' needs a thread number", interface.error_queue
|
77
|
+
end
|
78
|
+
|
79
|
+
it "must show error message when trying to resume current thread" do
|
80
|
+
enter 'break 8', 'cont', ->{"thread resume #{Debugger.contexts.first.thnum}"}, release
|
81
|
+
debug_file 'thread'
|
82
|
+
check_output_includes "It's the current thread.", interface.error_queue
|
83
|
+
end
|
84
|
+
|
85
|
+
it "must show error message if it is not stopped" do
|
86
|
+
thnum = nil
|
87
|
+
enter 'break 21', 'cont', ->{"thread resume #{Debugger.contexts.last.thnum}"}, release
|
88
|
+
debug_file('thread') { thnum = Debugger.contexts.last.thnum }
|
89
|
+
check_output_includes "Already running."
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
describe "switch" do
|
95
|
+
it "must switch to another thread"# do
|
96
|
+
# enter 'break 21', 'cont', ->{"thread #{Debugger.contexts.last.thnum}"}, release
|
97
|
+
# debug_file('thread') { state.line.must_equal 16 }
|
98
|
+
#end
|
99
|
+
|
100
|
+
it "must show error message if thread number is not specified" do
|
101
|
+
enter 'break 8', 'cont', "thread switch", release
|
102
|
+
debug_file 'thread'
|
103
|
+
check_output_includes "thread thread switch argument 'switch' needs to be a number."
|
104
|
+
end
|
105
|
+
|
106
|
+
it "must show error message when trying to switch current thread" do
|
107
|
+
enter 'break 8', 'cont', ->{"thread switch #{Debugger.contexts.first.thnum}"}, release
|
108
|
+
debug_file 'thread'
|
109
|
+
check_output_includes "It's the current thread.", interface.error_queue
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
|
114
|
+
describe "Post Mortem" do
|
115
|
+
it "must work in post-mortem mode" do
|
116
|
+
enter 'cont', 'thread list'
|
117
|
+
debug_file('post_mortem')
|
118
|
+
check_output_includes "+", /\d+/, /#<Thread:(\S+) run/
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
data/test/tmate_test.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
if RUBY_PLATFORM =~ /darwin/
|
2
|
+
require_relative 'test_helper'
|
3
|
+
|
4
|
+
describe "Tmate Command" do
|
5
|
+
include TestDsl
|
6
|
+
|
7
|
+
it "must open a current file with current frame in Textmate" do
|
8
|
+
Debugger::TextMateCommand.any_instance.expects(:`).with("open 'txmt://open?url=file://#{fullpath('tmate')}&line=7'")
|
9
|
+
enter 'break 7', 'cont', 'tmate'
|
10
|
+
debug_file 'tmate'
|
11
|
+
end
|
12
|
+
|
13
|
+
it "must open a current file with specified frame in Textmate" do
|
14
|
+
Debugger::TextMateCommand.any_instance.expects(:`).with("open 'txmt://open?url=file://#{fullpath('tmate')}&line=4'")
|
15
|
+
enter 'break 7', 'cont', 'tmate 2'
|
16
|
+
debug_file 'tmate'
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "errors" do
|
20
|
+
it "must show an error message if frame == 0" do
|
21
|
+
enter 'tmate 0'
|
22
|
+
debug_file 'tmate'
|
23
|
+
check_output_includes "Wrong frame number"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "must show an error message if frame > max frame" do
|
27
|
+
enter 'tmate 10'
|
28
|
+
debug_file 'tmate'
|
29
|
+
check_output_includes "Wrong frame number"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "Post Mortem" do
|
34
|
+
it "must work in post-mortem mode" do
|
35
|
+
Debugger::TextMateCommand.any_instance.expects(:`).with(
|
36
|
+
"open 'txmt://open?url=file://#{fullpath('post_mortem')}&line=8'"
|
37
|
+
)
|
38
|
+
enter 'cont', 'tmate'
|
39
|
+
debug_file 'post_mortem'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/test/trace_test.rb
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe "Trace Command" do
|
4
|
+
include TestDsl
|
5
|
+
temporary_set_const(Debugger, "PROG_SCRIPT", fullpath('trace'))
|
6
|
+
temporary_change_hash_value(Debugger::Command.settings, :basename, false)
|
7
|
+
temporary_change_method_value(Debugger, :tracing, false)
|
8
|
+
before { untrace_var(:$bla) if defined?($bla) }
|
9
|
+
|
10
|
+
describe "tracing on the current thread" do
|
11
|
+
describe "enabling" do
|
12
|
+
it "must trace execution by setting trace to on" do
|
13
|
+
temporary_set_const(Debugger, "PROG_SCRIPT", fullpath('trace_threads')) do
|
14
|
+
thnum = nil
|
15
|
+
enter 'trace on'
|
16
|
+
debug_file('trace_threads') { thnum = context.thnum }
|
17
|
+
check_output_includes(
|
18
|
+
"Tracing(#{thnum}):#{fullpath('trace_threads')}:4 @break1 = false",
|
19
|
+
"Tracing(#{thnum}):#{fullpath('trace_threads')}:5 @break2 = false"
|
20
|
+
)
|
21
|
+
check_output_doesnt_include /Tracing\(\d+\):#{fullpath('trace_threads')}:8 until @break1/
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it "must show a message it is on" do
|
26
|
+
enter 'trace on'
|
27
|
+
debug_file 'trace'
|
28
|
+
check_output_includes "Tracing on on current thread."
|
29
|
+
end
|
30
|
+
|
31
|
+
it "must be able to use a shortcut" do
|
32
|
+
enter 'tr on'
|
33
|
+
debug_file 'trace'
|
34
|
+
check_output_includes "Tracing on on current thread."
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
it "must show an error message if given subcommand is incorrect" do
|
39
|
+
enter 'trace bla'
|
40
|
+
debug_file 'trace'
|
41
|
+
check_output_includes "expecting 'on', 'off', 'var' or 'variable'; got: bla", interface.error_queue
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "disabling" do
|
45
|
+
it "must stop tracing by setting trace to off" do
|
46
|
+
thnum = nil
|
47
|
+
enter 'trace on', 'next', 'trace off'
|
48
|
+
debug_file('trace') { thnum = context.thnum }
|
49
|
+
check_output_includes "Tracing(#{thnum}):#{fullpath('trace')}:4 $bla = 4"
|
50
|
+
check_output_doesnt_include "Tracing(#{thnum}):#{fullpath('trace')}:5 $bla = 5"
|
51
|
+
end
|
52
|
+
|
53
|
+
it "must show a message it is off" do
|
54
|
+
enter 'trace off'
|
55
|
+
debug_file 'trace'
|
56
|
+
check_output_includes "Tracing off on current thread."
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
describe "tracing on all thread" do
|
63
|
+
describe "enabling" do
|
64
|
+
it "must trace execution by setting trace to on" do
|
65
|
+
temporary_set_const(Debugger, "PROG_SCRIPT", fullpath('trace_threads')) do
|
66
|
+
thnum = nil
|
67
|
+
enter 'trace on all'
|
68
|
+
debug_file('trace_threads') { thnum = context.thnum }
|
69
|
+
check_output_includes(
|
70
|
+
"Tracing(#{thnum}):#{fullpath('trace_threads')}:4 @break1 = false",
|
71
|
+
"Tracing(#{thnum}):#{fullpath('trace_threads')}:5 @break2 = false"
|
72
|
+
)
|
73
|
+
check_output_includes /Tracing\(\d+\):#{fullpath('trace_threads')}:8 until @break1/
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
it "must show a message it is on" do
|
78
|
+
enter 'trace on all'
|
79
|
+
debug_file 'trace'
|
80
|
+
check_output_includes "Tracing on all threads."
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "disabling" do
|
85
|
+
it "must stop tracing by setting trace to off" do
|
86
|
+
temporary_set_const(Debugger, "PROG_SCRIPT", fullpath('trace_threads')) do
|
87
|
+
thnum = nil
|
88
|
+
enter 'trace on all', 'break 19', 'cont', 'trace off all'
|
89
|
+
debug_file('trace_threads') { thnum = context.thnum }
|
90
|
+
check_output_includes /Tracing\(\d+\):#{fullpath('trace_threads')}:8 until @break1/
|
91
|
+
check_output_includes "Tracing(#{thnum}):#{fullpath('trace_threads')}:19 t1.join"
|
92
|
+
check_output_doesnt_include "Tracing(#{thnum}):#{fullpath('trace_threads')}:20 t1"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
it "must show a message it is off" do
|
97
|
+
enter 'trace off'
|
98
|
+
debug_file 'trace'
|
99
|
+
check_output_includes "Tracing off on current thread."
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
describe "tracing global variables" do
|
106
|
+
it "must track global variable" do
|
107
|
+
enter 'trace variable $bla'
|
108
|
+
debug_file 'trace'
|
109
|
+
check_output_includes(
|
110
|
+
"traced variable $bla has value 3",
|
111
|
+
"traced variable $bla has value 7",
|
112
|
+
)
|
113
|
+
end
|
114
|
+
|
115
|
+
it "must be able to use a shortcut" do
|
116
|
+
enter 'trace var $bla'
|
117
|
+
debug_file 'trace'
|
118
|
+
check_output_includes "traced variable $bla has value 3"
|
119
|
+
end
|
120
|
+
|
121
|
+
it "must track global variable with stop" do
|
122
|
+
enter 'trace variable $bla stop', 'break 7', 'cont'
|
123
|
+
debug_file('trace') { state.line.must_equal 4 }
|
124
|
+
end
|
125
|
+
|
126
|
+
it "must track global variable with nostop" do
|
127
|
+
enter 'trace variable $bla nostop', 'break 7', 'cont'
|
128
|
+
debug_file('trace') { state.line.must_equal 7 }
|
129
|
+
end
|
130
|
+
|
131
|
+
describe "errors" do
|
132
|
+
it "must show an error message if there is no such global variable" do
|
133
|
+
enter 'trace variable $foo'
|
134
|
+
debug_file 'trace'
|
135
|
+
check_output_includes "$foo is not a global variable.", interface.error_queue
|
136
|
+
end
|
137
|
+
|
138
|
+
it "must show an error message if subcommand is invalid" do
|
139
|
+
enter 'trace variable $bla foo'
|
140
|
+
debug_file 'trace'
|
141
|
+
check_output_includes "expecting 'stop' or 'nostop'; got foo", interface.error_queue
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
describe "Post Mortem" do
|
147
|
+
it "must work in post-mortem mode" do
|
148
|
+
enter 'cont', 'trace on'
|
149
|
+
debug_file 'post_mortem'
|
150
|
+
check_output_includes "Tracing on on current thread."
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe "Variables Command" do
|
4
|
+
include TestDsl
|
5
|
+
temporary_change_hash_value(Debugger::Command.settings, :width, 40)
|
6
|
+
|
7
|
+
describe "class variables" do
|
8
|
+
it "must show variables" do
|
9
|
+
enter 'break 19', 'cont', 'var class'
|
10
|
+
debug_file 'variables'
|
11
|
+
check_output_includes "@@class_c = 3"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "must be able to use shortcut" do
|
15
|
+
enter 'break 19', 'cont', 'v cl'
|
16
|
+
debug_file 'variables'
|
17
|
+
check_output_includes "@@class_c = 3"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "constants" do
|
22
|
+
it "must show constants" do
|
23
|
+
enter 'break 25', 'cont', 'var const VariablesExample'
|
24
|
+
debug_file 'variables'
|
25
|
+
check_output_includes 'SOMECONST => "foo"'
|
26
|
+
end
|
27
|
+
|
28
|
+
it "must be able to use shortcut" do
|
29
|
+
enter 'break 25', 'cont', 'v co VariablesExample'
|
30
|
+
debug_file 'variables'
|
31
|
+
check_output_includes 'SOMECONST => "foo"'
|
32
|
+
end
|
33
|
+
|
34
|
+
it "must show an error message if the given object is not a Class or Module" do
|
35
|
+
enter 'break 25', 'cont', 'var const v'
|
36
|
+
debug_file 'variables'
|
37
|
+
check_output_includes "Should be Class/Module: v"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "globals" do
|
42
|
+
it "must show global variables" do
|
43
|
+
enter 'break 25', 'cont', 'var global'
|
44
|
+
debug_file 'variables'
|
45
|
+
check_output_includes '$glob = 100'
|
46
|
+
end
|
47
|
+
|
48
|
+
it "must be able to use shortcut" do
|
49
|
+
enter 'break 25', 'cont', 'v g'
|
50
|
+
debug_file 'variables'
|
51
|
+
check_output_includes '$glob = 100'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "instance variables" do
|
56
|
+
it "must show instance variables of the given object" do
|
57
|
+
enter 'break 25', 'cont', 'var instance v'
|
58
|
+
debug_file 'variables'
|
59
|
+
check_output_includes "@inst_a = 1", "@inst_b = 2"
|
60
|
+
end
|
61
|
+
|
62
|
+
it "must show instance variables of self" do
|
63
|
+
enter 'break 11', 'cont', 'var instance'
|
64
|
+
debug_file 'variables'
|
65
|
+
check_output_includes "@inst_a = 1", "@inst_b = 2"
|
66
|
+
end
|
67
|
+
|
68
|
+
it "must show instance variables" do
|
69
|
+
enter 'break 25', 'cont', 'var instance v'
|
70
|
+
debug_file 'variables'
|
71
|
+
check_output_includes "@inst_a = 1", "@inst_b = 2"
|
72
|
+
end
|
73
|
+
|
74
|
+
it "must be able to use shortcut" do
|
75
|
+
enter 'break 25', 'cont', 'v ins v'
|
76
|
+
debug_file 'variables'
|
77
|
+
check_output_includes "@inst_a = 1", "@inst_b = 2"
|
78
|
+
end
|
79
|
+
|
80
|
+
it "must cut long variable values according to :width setting" do
|
81
|
+
temporary_change_hash_value(Debugger::Command.settings, :width, 20) do
|
82
|
+
enter 'break 25', 'cont', 'var instance v'
|
83
|
+
debug_file 'variables'
|
84
|
+
check_output_includes '@inst_c = "1111111111111111...'
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
it "must show fallback message if value doesn't have #to_s or #inspect methods" do
|
89
|
+
enter 'break 25', 'cont', 'var instance v'
|
90
|
+
debug_file 'variables'
|
91
|
+
check_output_includes '@inst_d = *Error in evaluation*'
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "local variables" do
|
96
|
+
it "must show local variables" do
|
97
|
+
enter 'break 17', 'cont', 'var local'
|
98
|
+
debug_file 'variables'
|
99
|
+
check_output_includes "a => 4", "b => nil", "i => 1"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
# TODO: Need to write tests for 'var ct' command, but I can't install the 'ruby-internal' gem
|
104
|
+
# on my machine, it fails to build gem native extension.
|
105
|
+
|
106
|
+
describe "Post Mortem" do
|
107
|
+
it "must work in post-mortem mode" do
|
108
|
+
enter 'cont', 'var local'
|
109
|
+
debug_file 'post_mortem'
|
110
|
+
check_output_includes "x => nil", "z => 4"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|