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
data/test/jump_test.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe "Jump Command" do
|
4
|
+
include TestDsl
|
5
|
+
|
6
|
+
describe "successful" do
|
7
|
+
it "must jump with absolute line number" do
|
8
|
+
enter 'break 6', 'cont', "jump 8 #{fullpath('jump')}"
|
9
|
+
debug_file('jump') { state.line.must_equal 8 }
|
10
|
+
end
|
11
|
+
|
12
|
+
it "must not initialize skipped variables during jump" do
|
13
|
+
enter 'break 6', 'cont', "jump 8 #{fullpath('jump')}", 'next'
|
14
|
+
enter 'var local'
|
15
|
+
debug_file('jump')
|
16
|
+
check_output_includes "a => 2", "b => nil", "c => nil", "d => 5"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "must jump with relative line number (-)" do
|
20
|
+
enter 'break 8', 'cont', "jump -2 #{fullpath('jump')}"
|
21
|
+
debug_file('jump') { state.line.must_equal 6 }
|
22
|
+
end
|
23
|
+
|
24
|
+
it "must jump with relative line number (+)" do
|
25
|
+
enter 'break 8', 'cont', "jump +2 #{fullpath('jump')}"
|
26
|
+
debug_file('jump') { state.line.must_equal 10 }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "errors" do
|
31
|
+
it "must show an error if line number is invalid" do
|
32
|
+
enter 'jump bla'
|
33
|
+
debug_file('jump')
|
34
|
+
check_output_includes "Bad line number: bla", interface.error_queue
|
35
|
+
end
|
36
|
+
|
37
|
+
it "must show an error if line number is not specified" do
|
38
|
+
enter 'jump'
|
39
|
+
debug_file('jump')
|
40
|
+
check_output_includes '"jump" must be followed by a line number', interface.error_queue
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "when there is no active code in specified line" do
|
44
|
+
it "must not jump to there" do
|
45
|
+
enter "jump 13 #{fullpath('jump')}"
|
46
|
+
debug_file('jump') { state.line.must_equal 3 }
|
47
|
+
end
|
48
|
+
|
49
|
+
it "must show an error" do
|
50
|
+
enter "jump 13 #{fullpath('jump')}"
|
51
|
+
debug_file('jump')
|
52
|
+
check_output_includes "Couldn't find active code at #{fullpath('jump')}:13", interface.error_queue
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
describe "Post Mortem" do
|
59
|
+
# TODO: This test fails with "Segmentation fault". Probably need to fix it somehow, or forbid this
|
60
|
+
# command in the post mortem mode. Seems like state.context.frame_file and state.context.frame_line
|
61
|
+
# cause that.
|
62
|
+
it "must work in post-mortem mode"# do
|
63
|
+
# enter 'cont', 'jump 12'
|
64
|
+
# debug_file 'post_mortem'
|
65
|
+
# pi
|
66
|
+
#end
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
end
|
data/test/kill_test.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe "Kill Command" do
|
4
|
+
include TestDsl
|
5
|
+
|
6
|
+
it "must send signal to some pid" do
|
7
|
+
Process.expects(:kill).with("USR1", Process.pid)
|
8
|
+
enter 'kill USR1'
|
9
|
+
debug_file('kill')
|
10
|
+
end
|
11
|
+
|
12
|
+
it "must finalize interface when sending KILL signal explicitly" do
|
13
|
+
Process.stubs(:kill).with("KILL", Process.pid)
|
14
|
+
interface.expects(:finalize)
|
15
|
+
enter 'kill KILL'
|
16
|
+
debug_file('kill')
|
17
|
+
end
|
18
|
+
|
19
|
+
it "must ask confirmation when sending KILL implicitly" do
|
20
|
+
Process.expects(:kill).with("KILL", Process.pid)
|
21
|
+
enter 'kill', 'y'
|
22
|
+
debug_file('kill')
|
23
|
+
check_output_includes "Really kill? (y/n)", interface.confirm_queue
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "unknown signal" do
|
27
|
+
it "must not send the signal" do
|
28
|
+
Process.expects(:kill).with("BLA", Process.pid).never
|
29
|
+
enter 'kill BLA'
|
30
|
+
debug_file('kill')
|
31
|
+
end
|
32
|
+
|
33
|
+
it "must show an error" do
|
34
|
+
enter 'kill BLA'
|
35
|
+
debug_file('kill')
|
36
|
+
check_output_includes "signal name BLA is not a signal I know about", interface.error_queue
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "Post Mortem" do
|
41
|
+
it "must work in post-mortem mode" do
|
42
|
+
Process.expects(:kill).with("USR1", Process.pid)
|
43
|
+
enter 'cont', 'kill USR1'
|
44
|
+
debug_file "post_mortem"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/test/list_test.rb
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe "List Command" do
|
4
|
+
include TestDsl
|
5
|
+
temporary_change_hash_value(Debugger::Command.settings, :listsize, 3)
|
6
|
+
before { LineCache.clear_file_cache }
|
7
|
+
after { LineCache.clear_file_cache }
|
8
|
+
|
9
|
+
describe "listsize" do
|
10
|
+
it "must show lines according to :listsize setting" do
|
11
|
+
enter 'set listsize 4', 'break 5', 'cont', 'list'
|
12
|
+
debug_file 'list'
|
13
|
+
check_output_includes "[3, 6] in #{fullpath('list')}"
|
14
|
+
end
|
15
|
+
|
16
|
+
it "must not set it if the param is not an integer" do
|
17
|
+
enter 'set listsize 4.0', 'break 5', 'cont', 'list'
|
18
|
+
debug_file 'list'
|
19
|
+
check_output_includes "[4, 6] in #{fullpath('list')}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "without arguments" do
|
24
|
+
it "must show surrounding lines with the first call" do
|
25
|
+
enter 'break 5', 'cont', 'list'
|
26
|
+
debug_file 'list'
|
27
|
+
check_output_includes "[4, 6] in #{fullpath('list')}", "4 4", "=> 5 5", "6 6"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "must list forward after second call" do
|
31
|
+
enter 'break 5', 'cont', 'list', 'list'
|
32
|
+
debug_file 'list'
|
33
|
+
check_output_includes "[7, 9] in #{fullpath('list')}", "7 7", "8 8", "9 9"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "list backward" do
|
38
|
+
it "must show surrounding lines with the first call" do
|
39
|
+
enter 'break 5', 'cont', 'list -'
|
40
|
+
debug_file 'list'
|
41
|
+
check_output_includes "[4, 6] in #{fullpath('list')}", "4 4", "=> 5 5", "6 6"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "must list backward after second call" do
|
45
|
+
enter 'break 5', 'cont', 'list -', 'list -'
|
46
|
+
debug_file 'list'
|
47
|
+
check_output_includes "[1, 3] in #{fullpath('list')}", "1 debugger", "2 2", "3 3"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
it "must show the surrounding lines with =" do
|
52
|
+
enter 'break 5', 'cont', 'list ='
|
53
|
+
debug_file 'list'
|
54
|
+
check_output_includes "[4, 6] in #{fullpath('list')}", "4 4", "=> 5 5", "6 6"
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "autolist" do
|
58
|
+
temporary_change_hash_value(Debugger::Command.settings, :autolist, 0)
|
59
|
+
|
60
|
+
it "must show the surronding lines even without 'list' command if autolist is enabled" do
|
61
|
+
enter 'set autolist', 'break 5', 'cont'
|
62
|
+
debug_file 'list'
|
63
|
+
check_output_includes "[4, 6] in #{fullpath('list')}", "4 4", "=> 5 5", "6 6"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "specified lines" do
|
68
|
+
it "must show with mm-nn" do
|
69
|
+
enter 'list 4-6'
|
70
|
+
debug_file 'list'
|
71
|
+
check_output_includes "[4, 6] in #{fullpath('list')}", "4 4", "5 5", "6 6"
|
72
|
+
end
|
73
|
+
|
74
|
+
it "must show with mm,nn" do
|
75
|
+
enter 'list 4,6'
|
76
|
+
debug_file 'list'
|
77
|
+
check_output_includes "[4, 6] in #{fullpath('list')}", "4 4", "5 5", "6 6"
|
78
|
+
end
|
79
|
+
|
80
|
+
it "must show surroundings with mm-" do
|
81
|
+
enter 'list 4-'
|
82
|
+
debug_file 'list'
|
83
|
+
check_output_includes "[3, 5] in #{fullpath('list')}", "3 3", "4 4", "5 5"
|
84
|
+
end
|
85
|
+
|
86
|
+
it "must show surroundings with mm," do
|
87
|
+
enter 'list 4,'
|
88
|
+
debug_file 'list'
|
89
|
+
check_output_includes "[3, 5] in #{fullpath('list')}", "3 3", "4 4", "5 5"
|
90
|
+
end
|
91
|
+
|
92
|
+
it "must show nothing if there is no such lines" do
|
93
|
+
enter 'list 44,44'
|
94
|
+
debug_file 'list'
|
95
|
+
check_output_includes "[44, 44] in #{fullpath('list')}"
|
96
|
+
check_output_doesnt_include /^44 \S/
|
97
|
+
end
|
98
|
+
|
99
|
+
it "must show nothing if range is incorrect" do
|
100
|
+
enter 'list 5,4'
|
101
|
+
debug_file 'list'
|
102
|
+
check_output_includes "[5, 4] in #{fullpath('list')}"
|
103
|
+
check_output_doesnt_include "5 5"
|
104
|
+
check_output_doesnt_include "4 4"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe "reload source" do
|
109
|
+
temporary_change_hash_value(Debugger::Command.settings, :reload_source_on_change, false)
|
110
|
+
|
111
|
+
after { change_line_in_file(fullpath('list'), 4, '4') }
|
112
|
+
it "must not reload if setting is false" do
|
113
|
+
enter 'set noautoreload', -> do
|
114
|
+
change_line_in_file(fullpath('list'), 4, '100')
|
115
|
+
'list 4-4'
|
116
|
+
end
|
117
|
+
debug_file 'list'
|
118
|
+
check_output_includes "4 4"
|
119
|
+
end
|
120
|
+
|
121
|
+
it "must reload if setting is true" do
|
122
|
+
enter 'set autoreload', -> do
|
123
|
+
change_line_in_file(fullpath('list'), 4, '100')
|
124
|
+
'list 4-4'
|
125
|
+
end
|
126
|
+
debug_file 'list'
|
127
|
+
check_output_includes "4 100"
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
it "must show an error when there is no such file" do
|
132
|
+
enter ->{state.file = "blabla"; 'list 4-4'}
|
133
|
+
debug_file 'list'
|
134
|
+
check_output_includes "No sourcefile available for blabla", interface.error_queue
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
describe "Post Mortem" do
|
139
|
+
it "must work in post-mortem mode" do
|
140
|
+
enter 'cont', 'list'
|
141
|
+
debug_file 'post_mortem'
|
142
|
+
check_output_includes "[7, 9] in #{fullpath('post_mortem')}"
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
data/test/method_test.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe "Method Command" do
|
4
|
+
include TestDsl
|
5
|
+
|
6
|
+
# TODO: Need to write tests for 'method signature' command, but I can't install the 'ruby-internal' gem
|
7
|
+
# on my machine, it fails to build gem native extension.
|
8
|
+
|
9
|
+
describe "show instance method of a class" do
|
10
|
+
it "must show using full command name" do
|
11
|
+
enter 'break 15', 'cont', 'm MethodEx'
|
12
|
+
debug_file 'method'
|
13
|
+
check_output_includes /bla/
|
14
|
+
check_output_doesnt_include /foo/
|
15
|
+
end
|
16
|
+
|
17
|
+
it "must show using shortcut" do
|
18
|
+
enter 'break 15', 'cont', 'method MethodEx'
|
19
|
+
debug_file 'method'
|
20
|
+
check_output_includes /bla/
|
21
|
+
end
|
22
|
+
|
23
|
+
it "must show an error if specified object is not a class or module" do
|
24
|
+
enter 'break 15', 'cont', 'm a'
|
25
|
+
debug_file 'method'
|
26
|
+
check_output_includes "Should be Class/Module: a"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
describe "show methods of an object" do
|
32
|
+
it "must show using full command name" do
|
33
|
+
enter 'break 15', 'cont', 'method instance a'
|
34
|
+
debug_file 'method'
|
35
|
+
check_output_includes /bla/
|
36
|
+
check_output_doesnt_include /foo/
|
37
|
+
end
|
38
|
+
|
39
|
+
it "must show using shortcut" do
|
40
|
+
enter 'break 15', 'cont', 'm i a'
|
41
|
+
debug_file 'method'
|
42
|
+
check_output_includes /bla/
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
describe "show instance variables of an object" do
|
48
|
+
it "must show using full name command" do
|
49
|
+
enter 'break 15', 'cont', 'method iv a'
|
50
|
+
debug_file 'method'
|
51
|
+
check_output_includes '@a = "b"', '@c = "d"'
|
52
|
+
end
|
53
|
+
|
54
|
+
it "must show using shortcut" do
|
55
|
+
enter 'break 15', 'cont', 'm iv a'
|
56
|
+
debug_file 'method'
|
57
|
+
check_output_includes '@a = "b"', '@c = "d"'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
describe "Post Mortem" do
|
63
|
+
it "must work in post-mortem mode" do
|
64
|
+
enter 'cont', 'm i self'
|
65
|
+
debug_file 'post_mortem'
|
66
|
+
check_output_includes /to_s/
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe "Post Mortem" do
|
4
|
+
include TestDsl
|
5
|
+
|
6
|
+
it "must enter into port mortem mode" do
|
7
|
+
enter 'cont'
|
8
|
+
debug_file("post_mortem") { Debugger.post_mortem?.must_equal true }
|
9
|
+
end
|
10
|
+
|
11
|
+
it "must stop at the correct line" do
|
12
|
+
enter 'cont'
|
13
|
+
debug_file("post_mortem") { state.line.must_equal 8 }
|
14
|
+
end
|
15
|
+
|
16
|
+
it "must exit from post mortem mode after stepping command" do
|
17
|
+
enter 'cont', 'break 12', 'cont'
|
18
|
+
debug_file("post_mortem") { Debugger.post_mortem?.must_equal false }
|
19
|
+
end
|
20
|
+
|
21
|
+
it "must save the raised exception" do
|
22
|
+
enter 'cont'
|
23
|
+
debug_file("post_mortem") { Debugger.last_exception.must_be_kind_of RuntimeError }
|
24
|
+
end
|
25
|
+
end
|
data/test/quit_test.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe "Quit Command" do
|
4
|
+
include TestDsl
|
5
|
+
|
6
|
+
it "must quit if user confirmed" do
|
7
|
+
Debugger::QuitCommand.any_instance.expects(:exit!)
|
8
|
+
enter 'quit', 'y'
|
9
|
+
debug_file 'quit'
|
10
|
+
check_output_includes "Really quit? (y/n)", interface.confirm_queue
|
11
|
+
end
|
12
|
+
|
13
|
+
it "must not quit if user didn't confirm" do
|
14
|
+
Debugger::QuitCommand.any_instance.expects(:exit!).never
|
15
|
+
enter 'quit', 'n'
|
16
|
+
debug_file 'quit'
|
17
|
+
check_output_includes "Really quit? (y/n)", interface.confirm_queue
|
18
|
+
end
|
19
|
+
|
20
|
+
it "must quit immediatly if used with !" do
|
21
|
+
Debugger::QuitCommand.any_instance.expects(:exit!)
|
22
|
+
enter 'quit!'
|
23
|
+
debug_file 'quit'
|
24
|
+
check_output_doesnt_include "Really quit? (y/n)", interface.confirm_queue
|
25
|
+
end
|
26
|
+
|
27
|
+
it "must quit immediatly if used with 'unconditionally'" do
|
28
|
+
Debugger::QuitCommand.any_instance.expects(:exit!)
|
29
|
+
enter 'quit unconditionally'
|
30
|
+
debug_file 'quit'
|
31
|
+
check_output_doesnt_include "Really quit? (y/n)", interface.confirm_queue
|
32
|
+
end
|
33
|
+
|
34
|
+
it "must finalize interface before quitting" do
|
35
|
+
Debugger::QuitCommand.any_instance.stubs(:exit!)
|
36
|
+
interface.expects(:finalize)
|
37
|
+
enter 'quit!'
|
38
|
+
debug_file 'quit'
|
39
|
+
end
|
40
|
+
|
41
|
+
it "must quit if used 'exit' alias" do
|
42
|
+
Debugger::QuitCommand.any_instance.expects(:exit!)
|
43
|
+
enter 'exit!'
|
44
|
+
debug_file 'quit'
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "Post Mortem" do
|
48
|
+
it "must work in post-mortem mode" do
|
49
|
+
Debugger::QuitCommand.any_instance.expects(:exit!)
|
50
|
+
enter 'cont', 'exit!'
|
51
|
+
debug_file 'post_mortem'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
data/test/reload_test.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe "Reload Command" do
|
4
|
+
include TestDsl
|
5
|
+
temporary_change_hash_value(Debugger::Command.settings, :reload_source_on_change, false)
|
6
|
+
|
7
|
+
it "must notify that automatic reloading is off" do
|
8
|
+
enter 'reload'
|
9
|
+
debug_file 'reload'
|
10
|
+
check_output_includes "Source code is reloaded. Automatic reloading is off."
|
11
|
+
end
|
12
|
+
|
13
|
+
it "must notify that automatic reloading is on" do
|
14
|
+
enter 'set autoreload', 'reload'
|
15
|
+
debug_file 'reload'
|
16
|
+
check_output_includes "Source code is reloaded. Automatic reloading is on."
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "reloading" do
|
20
|
+
after { change_line_in_file(fullpath('reload'), 4, '4') }
|
21
|
+
it "must reload the code" do
|
22
|
+
enter 'break 3', 'cont', 'l 4-4', -> do
|
23
|
+
change_line_in_file(fullpath('reload'), 4, '100')
|
24
|
+
'reload'
|
25
|
+
end, 'l 4-4'
|
26
|
+
debug_file 'reload'
|
27
|
+
check_output_includes "4 100"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "Post Mortem" do
|
32
|
+
after { change_line_in_file(fullpath('post_mortem'), 7, ' z = 4') }
|
33
|
+
it "must work in post-mortem mode" do
|
34
|
+
enter 'cont', -> do
|
35
|
+
change_line_in_file(fullpath('post_mortem'), 7, 'z = 100')
|
36
|
+
'reload'
|
37
|
+
end, 'l 7-7'
|
38
|
+
debug_file 'post_mortem'
|
39
|
+
check_output_includes "7 z = 100"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|