debugger 1.2.4 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/.gitignore
ADDED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## 1.3.0 - thanks to @astashov
|
2
|
+
* New and improved test suite
|
3
|
+
* Fix line tracing
|
4
|
+
* Fix source reloading
|
5
|
+
* Fix error message of jump command
|
6
|
+
* Fix trace and trace all commands
|
7
|
+
* Fix -d flag to irb command
|
8
|
+
* Fix method command being detected
|
9
|
+
|
1
10
|
## 1.2.4
|
2
11
|
* Bump ruby_core_source dependency
|
3
12
|
|
data/Gemfile
ADDED
data/README.md
CHANGED
@@ -91,6 +91,7 @@ tutorial](http://bashdb.sourceforge.net/ruby-debug/rdebug-emacs.html)
|
|
91
91
|
* No downloading ruby source during install - was behavior of old ruby_core_source dependency
|
92
92
|
* Fix LocalJumpError caused by using proc in extconf.rb
|
93
93
|
* Fix where command failing at top level
|
94
|
+
* A new and improved test suite
|
94
95
|
* Passing tests are up on travis-ci
|
95
96
|
* Minor
|
96
97
|
* The gem name matches the module namespace, Debugger, and main required file, debugger.
|
@@ -126,6 +127,7 @@ Let's keep this working for the ruby community!
|
|
126
127
|
## Credits
|
127
128
|
|
128
129
|
* Thanks to the original authors: Kent Sibilev and Mark Moseley
|
130
|
+
* Thanks to astashov for bringing in a new and improved test suite and various bug fixes.
|
129
131
|
* Contributors: ericpromislow, jnimety, adammck, hipe, FooBarWidget
|
130
132
|
* Fork started on awesome @relevance fridays!
|
131
133
|
|
data/Rakefile
CHANGED
@@ -7,62 +7,10 @@ Rake::ExtensionTask.new('ruby_debug')
|
|
7
7
|
|
8
8
|
SO_NAME = "ruby_debug.so"
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
'CHANGES',
|
13
|
-
'LICENSE',
|
14
|
-
'README',
|
15
|
-
'Rakefile',
|
16
|
-
]
|
17
|
-
|
18
|
-
CLI_TEST_FILE_LIST = FileList['test/lib/commands/unit/*.rb',
|
19
|
-
'test/lib/commands/*_test.rb',
|
20
|
-
'test/lib/**/*_test.rb',
|
21
|
-
'test/test-remote.rb']
|
22
|
-
# disabled until requires fixed and tests pass
|
23
|
-
# 'test/test-*.rb']
|
24
|
-
CLI_FILES = COMMON_FILES + FileList[
|
25
|
-
"lib/**/*",
|
26
|
-
'ChangeLog',
|
27
|
-
'bin/*',
|
28
|
-
'doc/rdebug.1',
|
29
|
-
'test/**/data/*.cmd',
|
30
|
-
'test/**/data/*.right',
|
31
|
-
'test/**/*.rb',
|
32
|
-
'rdbg.rb',
|
33
|
-
CLI_TEST_FILE_LIST
|
34
|
-
]
|
35
|
-
|
36
|
-
BASE_TEST_FILE_LIST = %w(
|
37
|
-
test/base/base.rb
|
38
|
-
test/base/binding.rb
|
39
|
-
test/base/catchpoint.rb)
|
40
|
-
BASE_FILES = COMMON_FILES + FileList[
|
41
|
-
'ext/ruby_debug/breakpoint.c',
|
42
|
-
'ext/ruby_debug/extconf.rb',
|
43
|
-
'ext/ruby_debug/ruby_debug.c',
|
44
|
-
'ext/ruby_debug/ruby_debug.h',
|
45
|
-
'ext/win32/*',
|
46
|
-
'lib/**/*',
|
47
|
-
BASE_TEST_FILE_LIST,
|
48
|
-
]
|
49
|
-
|
50
|
-
desc "Test everything."
|
51
|
-
task :test => :test_base do
|
10
|
+
desc "Run new MiniTest tests."
|
11
|
+
task :test do
|
52
12
|
Rake::TestTask.new(:test) do |t|
|
53
|
-
t.
|
54
|
-
t.libs << './lib'
|
55
|
-
t.test_files = CLI_TEST_FILE_LIST
|
56
|
-
t.verbose = true
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
desc "Test ruby-debug-base."
|
61
|
-
task :test_base => :lib do
|
62
|
-
Rake::TestTask.new(:test_base) do |t|
|
63
|
-
t.libs << './ext'
|
64
|
-
t.libs << './lib'
|
65
|
-
t.test_files = FileList[BASE_TEST_FILE_LIST]
|
13
|
+
t.test_files = FileList["test/*_test.rb"]
|
66
14
|
t.verbose = true
|
67
15
|
end
|
68
16
|
end
|
data/debugger.gemspec
CHANGED
@@ -24,4 +24,6 @@ handling, bindings for stack frames among other things.
|
|
24
24
|
s.add_dependency "debugger-linecache", '~> 1.1.1'
|
25
25
|
s.add_development_dependency 'rake', '~> 0.9.2.2'
|
26
26
|
s.add_development_dependency 'rake-compiler', '~> 0.8.0'
|
27
|
+
s.add_development_dependency 'minitest', '~> 2.12.1'
|
28
|
+
s.add_development_dependency 'mocha', '~> 0.13.0'
|
27
29
|
end
|
data/lib/debugger/version.rb
CHANGED
data/lib/ruby-debug-base.rb
CHANGED
@@ -46,7 +46,7 @@ module Debugger
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def at_tracing(file, line)
|
49
|
-
@tracing_started =
|
49
|
+
@tracing_started = File.identical?(file, Debugger::PROG_SCRIPT)
|
50
50
|
handler.at_tracing(self, file, line) if @tracing_started
|
51
51
|
end
|
52
52
|
|
@@ -91,6 +91,8 @@ module Debugger
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def source_reload
|
94
|
+
Object.send(:remove_const, "SCRIPT_LINES__") if Object.const_defined?("SCRIPT_LINES__")
|
95
|
+
Object.const_set("SCRIPT_LINES__", {})
|
94
96
|
LineCache::clear_file_cache
|
95
97
|
end
|
96
98
|
|
@@ -72,7 +72,7 @@ module Debugger
|
|
72
72
|
throw :IRB_EXIT, :cont if $rdebug_in_irb
|
73
73
|
end
|
74
74
|
|
75
|
-
add_debugging = @match.is_a?(
|
75
|
+
add_debugging = @match.is_a?(MatchData) && '-d' == @match[1]
|
76
76
|
$rdebug_state = @state if add_debugging
|
77
77
|
$rdebug_in_irb = true
|
78
78
|
cont = IRB.start_session(get_binding)
|
@@ -11,10 +11,10 @@ module Debugger
|
|
11
11
|
if @match[1] =~ /on|off/
|
12
12
|
onoff = 'on' == @match[1]
|
13
13
|
if @match[2]
|
14
|
-
Debugger.
|
14
|
+
Debugger.tracing = onoff
|
15
15
|
print "Tracing %s all threads.\n" % (onoff ? 'on' : 'off')
|
16
16
|
else
|
17
|
-
Debugger.tracing = onoff
|
17
|
+
Debugger.current_context.tracing = onoff
|
18
18
|
print "Tracing %s on current thread.\n" % (onoff ? 'on' : 'off')
|
19
19
|
end
|
20
20
|
elsif @match[1] =~ /var(?:iable)?/
|
@@ -4,10 +4,10 @@ module Debugger
|
|
4
4
|
ary.sort!
|
5
5
|
for v in ary
|
6
6
|
begin
|
7
|
-
s = debug_eval(v, b).inspect
|
7
|
+
s = debug_eval(v.to_s, b).inspect
|
8
8
|
rescue
|
9
9
|
begin
|
10
|
-
s = debug_eval(v, b).to_s
|
10
|
+
s = debug_eval(v.to_s, b).to_s
|
11
11
|
rescue
|
12
12
|
s = "*Error in evaluation*"
|
13
13
|
end
|
@@ -78,7 +78,7 @@ module Debugger
|
|
78
78
|
|
79
79
|
def help(cmd)
|
80
80
|
%{
|
81
|
-
v[ar]
|
81
|
+
v[ar] co[nst] <object>\t\tshow constants of object
|
82
82
|
}
|
83
83
|
end
|
84
84
|
end
|
@@ -0,0 +1,365 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe "Breakpoints" do
|
4
|
+
include TestDsl
|
5
|
+
|
6
|
+
describe "setting breakpoint in the current file" do
|
7
|
+
before { enter 'break 10' }
|
8
|
+
subject { breakpoint }
|
9
|
+
|
10
|
+
def check_subject(field, value)
|
11
|
+
debug_file("breakpoint1") { subject.send(field).must_equal value }
|
12
|
+
end
|
13
|
+
|
14
|
+
it("must have correct pos") { check_subject(:pos, 10) }
|
15
|
+
it("must have correct source") { check_subject(:source, fullpath("breakpoint1")) }
|
16
|
+
it("must have correct expression") { check_subject(:expr, nil) }
|
17
|
+
it("must have correct hit count") { check_subject(:hit_count, 0) }
|
18
|
+
it("must have correct hit value") { check_subject(:hit_value, 0) }
|
19
|
+
it("must be enabled") { check_subject(:enabled?, true) }
|
20
|
+
it("must return right response") do
|
21
|
+
id = nil
|
22
|
+
debug_file('breakpoint1') { id = subject.id }
|
23
|
+
check_output_includes "Breakpoint #{id} file #{fullpath('breakpoint1')}, line 10"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
describe "using shortcut for the command" do
|
29
|
+
before { enter 'b 10' }
|
30
|
+
it "must set a breakpoint" do
|
31
|
+
debug_file("breakpoint1") { Debugger.breakpoints.size.must_equal 1 }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
describe "setting breakpoint to unexisted line" do
|
37
|
+
before { enter 'break 100' }
|
38
|
+
|
39
|
+
it "must not create a breakpoint" do
|
40
|
+
debug_file("breakpoint1") { Debugger.breakpoints.must_be_empty }
|
41
|
+
end
|
42
|
+
|
43
|
+
it "must show an error" do
|
44
|
+
debug_file("breakpoint1")
|
45
|
+
check_output_includes "There are only #{LineCache.size(fullpath('breakpoint1'))} lines in file \"breakpoint1.rb\".", interface.error_queue
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
describe "setting breakpoint to incorrect line" do
|
51
|
+
before { enter 'break 8' }
|
52
|
+
|
53
|
+
it "must not create a breakpoint" do
|
54
|
+
debug_file("breakpoint1") { Debugger.breakpoints.must_be_empty }
|
55
|
+
end
|
56
|
+
|
57
|
+
it "must show an error" do
|
58
|
+
debug_file("breakpoint1")
|
59
|
+
check_output_includes 'Line 8 is not a stopping point in file "breakpoint1.rb".', interface.error_queue
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
describe "stopping at breakpoint" do
|
65
|
+
it "must stop at the correct line" do
|
66
|
+
enter 'break 14', 'cont'
|
67
|
+
debug_file("breakpoint1") { state.line.must_equal 14 }
|
68
|
+
end
|
69
|
+
|
70
|
+
it "must stop at the correct file" do
|
71
|
+
enter 'break 14', 'cont'
|
72
|
+
debug_file("breakpoint1") { state.file.must_equal fullpath("breakpoint1") }
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "show a message" do
|
76
|
+
temporary_change_hash_value(Debugger::Command.settings, :basename, false)
|
77
|
+
|
78
|
+
it "must show a message with full filename" do
|
79
|
+
enter 'break 14', 'cont'
|
80
|
+
debug_file("breakpoint1")
|
81
|
+
check_output_includes "Breakpoint 1 at #{fullpath('breakpoint1')}:14"
|
82
|
+
end
|
83
|
+
|
84
|
+
it "must show a message with basename" do
|
85
|
+
enter 'set basename', 'break 14', 'cont'
|
86
|
+
debug_file("breakpoint1")
|
87
|
+
check_output_includes "Breakpoint 1 at breakpoint1.rb:14"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
describe "reloading source on change" do
|
94
|
+
temporary_change_hash_value(Debugger::Command.settings, :reload_source_on_change, false)
|
95
|
+
|
96
|
+
it "must not reload source if autoreload is not set" do
|
97
|
+
enter(
|
98
|
+
'set noautoreload',
|
99
|
+
->{change_line_in_file(fullpath('breakpoint1'), 14, ''); 'break 14'},
|
100
|
+
->{change_line_in_file(fullpath('breakpoint1'), 14, 'c = a + b'); 'cont'}
|
101
|
+
)
|
102
|
+
debug_file "breakpoint1"
|
103
|
+
check_output_includes "Breakpoint 1 at #{fullpath('breakpoint1')}:14"
|
104
|
+
end
|
105
|
+
|
106
|
+
it "must reload source if autoreload is set" do
|
107
|
+
enter(
|
108
|
+
'set autoreload',
|
109
|
+
->{change_line_in_file(fullpath('breakpoint1'), 14, ''); 'break 14'},
|
110
|
+
# Setting second breakpoint just to reload the source code after rolling the file changes back
|
111
|
+
->{change_line_in_file(fullpath('breakpoint1'), 14, 'c = a + b'); 'break 15'}, 'cont'
|
112
|
+
)
|
113
|
+
debug_file "breakpoint1"
|
114
|
+
check_output_includes "Line 14 is not a stopping point in file \"breakpoint1.rb\".", interface.error_queue
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
|
119
|
+
describe "set breakpoint in a file" do
|
120
|
+
describe "successfully" do
|
121
|
+
before do
|
122
|
+
enter "break #{fullpath('breakpoint2')}:3", 'cont'
|
123
|
+
end
|
124
|
+
|
125
|
+
it "must stop at the correct line" do
|
126
|
+
debug_file("breakpoint1") { state.line.must_equal 3 }
|
127
|
+
end
|
128
|
+
|
129
|
+
it "must stop at the correct file" do
|
130
|
+
debug_file("breakpoint1") { state.file.must_equal fullpath("breakpoint2") }
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
describe "when setting breakpoint to unexisted file" do
|
135
|
+
before do
|
136
|
+
enter "break asf:324"
|
137
|
+
debug_file("breakpoint1")
|
138
|
+
end
|
139
|
+
it "must show an error" do
|
140
|
+
check_output_includes "No source file named asf", interface.error_queue
|
141
|
+
end
|
142
|
+
|
143
|
+
it "must ask about setting breakpoint anyway" do
|
144
|
+
check_output_includes "Set breakpoint anyway? (y/n)", interface.confirm_queue
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
|
150
|
+
describe "set breakpoint to a method" do
|
151
|
+
describe "set breakpoint to an instance method" do
|
152
|
+
before do
|
153
|
+
enter 'break A#b', 'cont'
|
154
|
+
end
|
155
|
+
|
156
|
+
it "must stop at the correct line" do
|
157
|
+
debug_file("breakpoint1") { state.line.must_equal 5 }
|
158
|
+
end
|
159
|
+
|
160
|
+
it "must stop at the correct file" do
|
161
|
+
debug_file("breakpoint1") { state.file.must_equal fullpath("breakpoint1") }
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
describe "set breakpoint to a class method" do
|
166
|
+
before do
|
167
|
+
enter 'break A.a', 'cont'
|
168
|
+
end
|
169
|
+
|
170
|
+
it "must stop at the correct line" do
|
171
|
+
debug_file("breakpoint1") { state.line.must_equal 2 }
|
172
|
+
end
|
173
|
+
|
174
|
+
it "must stop at the correct file" do
|
175
|
+
debug_file("breakpoint1") { state.file.must_equal fullpath("breakpoint1") }
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
describe "set breakpoint to unexisted class" do
|
180
|
+
it "must show an error" do
|
181
|
+
enter "break B.a"
|
182
|
+
debug_file("breakpoint1")
|
183
|
+
check_output_includes "Unknown class B.", interface.error_queue
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
|
189
|
+
describe "set breakpoint to an invalid location" do
|
190
|
+
before { enter "break foo" }
|
191
|
+
|
192
|
+
it "must not create a breakpoint" do
|
193
|
+
debug_file("breakpoint1") { Debugger.breakpoints.must_be_empty }
|
194
|
+
end
|
195
|
+
|
196
|
+
it "must show an error" do
|
197
|
+
debug_file("breakpoint1")
|
198
|
+
check_output_includes 'Invalid breakpoint location: foo.', interface.error_queue
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
|
203
|
+
describe "disabling a breakpoint" do
|
204
|
+
describe "successfully" do
|
205
|
+
before { enter "break 14" }
|
206
|
+
|
207
|
+
describe "short syntax" do
|
208
|
+
before { enter ->{"disable #{breakpoint.id}"}, "break 15" }
|
209
|
+
it "must have a breakpoint with #enabled? returning false" do
|
210
|
+
debug_file("breakpoint1") { breakpoint.enabled?.must_equal false }
|
211
|
+
end
|
212
|
+
|
213
|
+
it "must not stop on the disabled breakpoint" do
|
214
|
+
enter "cont"
|
215
|
+
debug_file("breakpoint1") { state.line.must_equal 15 }
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
describe "full syntax" do
|
220
|
+
before { enter ->{"disable breakpoints #{breakpoint.id}"}, "break 15" }
|
221
|
+
it "must have a breakpoint with #enabled? returning false" do
|
222
|
+
debug_file("breakpoint1") { breakpoint.enabled?.must_equal false }
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
describe "errors" do
|
228
|
+
it "must show an error if syntax is incorrect" do
|
229
|
+
enter "disable"
|
230
|
+
debug_file("breakpoint1")
|
231
|
+
check_output_includes(
|
232
|
+
'"disable" must be followed "display", "breakpoints" or breakpoint numbers.',
|
233
|
+
interface.error_queue
|
234
|
+
)
|
235
|
+
end
|
236
|
+
|
237
|
+
it "must show an error if no breakpoints is set" do
|
238
|
+
enter "disable 1"
|
239
|
+
debug_file("breakpoint1")
|
240
|
+
check_output_includes 'No breakpoints have been set.', interface.error_queue
|
241
|
+
end
|
242
|
+
|
243
|
+
it "must show an error if not a number is provided as an argument to 'disable' command" do
|
244
|
+
enter "break 14", "disable foo"
|
245
|
+
debug_file("breakpoint1")
|
246
|
+
check_output_includes "Disable breakpoints argument 'foo' needs to be a number."
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
|
252
|
+
describe "enabling a breakpoint" do
|
253
|
+
describe "successfully" do
|
254
|
+
before { enter "break 14" }
|
255
|
+
describe "short syntax" do
|
256
|
+
before { enter ->{"enable #{breakpoint.id}"}, "break 15" }
|
257
|
+
|
258
|
+
it "must have a breakpoint with #enabled? returning true" do
|
259
|
+
debug_file("breakpoint1") { breakpoint.enabled?.must_equal true }
|
260
|
+
end
|
261
|
+
|
262
|
+
it "must stop on the enabled breakpoint" do
|
263
|
+
enter "cont"
|
264
|
+
debug_file("breakpoint1") { state.line.must_equal 14 }
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
describe "full syntax" do
|
269
|
+
before { enter ->{"enable breakpoints #{breakpoint.id}"}, "break 15" }
|
270
|
+
|
271
|
+
it "must have a breakpoint with #enabled? returning true" do
|
272
|
+
debug_file("breakpoint1") { breakpoint.enabled?.must_equal true }
|
273
|
+
end
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
describe "errors" do
|
278
|
+
it "must show an error if syntax is incorrect" do
|
279
|
+
enter "enable"
|
280
|
+
debug_file("breakpoint1")
|
281
|
+
check_output_includes(
|
282
|
+
'"enable" must be followed "display", "breakpoints" or breakpoint numbers.',
|
283
|
+
interface.error_queue
|
284
|
+
)
|
285
|
+
end
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
|
290
|
+
describe "deleting a breakpoint" do
|
291
|
+
before { enter "break 14", ->{"delete #{breakpoint.id}"}, "break 15" }
|
292
|
+
|
293
|
+
it "must have only one breakpoint" do
|
294
|
+
debug_file("breakpoint1") { Debugger.breakpoints.size.must_equal 1 }
|
295
|
+
end
|
296
|
+
|
297
|
+
it "must not stop on the disabled breakpoint" do
|
298
|
+
enter "cont"
|
299
|
+
debug_file("breakpoint1") { state.line.must_equal 15 }
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
|
304
|
+
describe "Conditional breakpoints" do
|
305
|
+
it "must stop if the condition is correct" do
|
306
|
+
enter "break 14 if b == 5", "break 15", "cont"
|
307
|
+
debug_file("breakpoint1") { state.line.must_equal 14 }
|
308
|
+
end
|
309
|
+
|
310
|
+
it "must skip if the condition is incorrect" do
|
311
|
+
enter "break 14 if b == 3", "break 15", "cont"
|
312
|
+
debug_file("breakpoint1") { state.line.must_equal 15 }
|
313
|
+
end
|
314
|
+
|
315
|
+
it "must show an error when conditional syntax is wrong" do
|
316
|
+
enter "break 14 ifa b == 3", "break 15", "cont"
|
317
|
+
debug_file("breakpoint1") { state.line.must_equal 15 }
|
318
|
+
check_output_includes "Expecting 'if' in breakpoint condition; got: ifa b == 3.", interface.error_queue
|
319
|
+
end
|
320
|
+
|
321
|
+
describe "enabling with wrong conditional syntax" do
|
322
|
+
before do
|
323
|
+
enter(
|
324
|
+
"break 14",
|
325
|
+
->{"disable #{breakpoint.id}"},
|
326
|
+
->{"cond #{breakpoint.id} b -=( 3"},
|
327
|
+
->{"enable #{breakpoint.id}"}
|
328
|
+
)
|
329
|
+
end
|
330
|
+
|
331
|
+
it "must not enable a breakpoint" do
|
332
|
+
debug_file("breakpoint1") { breakpoint.enabled?.must_equal false }
|
333
|
+
end
|
334
|
+
|
335
|
+
it "must show an error" do
|
336
|
+
debug_file("breakpoint1")
|
337
|
+
check_output_includes(
|
338
|
+
'Expression "b -=( 3" syntactically incorrect; breakpoint remains disabled.',
|
339
|
+
interface.error_queue
|
340
|
+
)
|
341
|
+
end
|
342
|
+
end
|
343
|
+
|
344
|
+
it "must show an error if no file or line is specified" do
|
345
|
+
enter "break ifa b == 3", "break 15", "cont"
|
346
|
+
debug_file("breakpoint1") { state.line.must_equal 15 }
|
347
|
+
check_output_includes "Invalid breakpoint location: ifa b == 3.", interface.error_queue
|
348
|
+
end
|
349
|
+
|
350
|
+
it "must show an error if expression syntax is invalid" do
|
351
|
+
enter "break if b -=) 3", "break 15", "cont"
|
352
|
+
debug_file("breakpoint1") { state.line.must_equal 15 }
|
353
|
+
check_output_includes 'Expression "b -=) 3" syntactically incorrect; breakpoint disabled.', interface.error_queue
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
357
|
+
|
358
|
+
describe "Post Mortem" do
|
359
|
+
it "must be able to set breakpoints in post-mortem mode" do
|
360
|
+
enter 'cont', 'break 12', 'cont'
|
361
|
+
debug_file("post_mortem") { state.line.must_equal 12 }
|
362
|
+
end
|
363
|
+
end
|
364
|
+
|
365
|
+
end
|