byebug 3.1.2 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -2
- data/CHANGELOG.md +15 -0
- data/GUIDE.md +17 -35
- data/Gemfile +8 -5
- data/LICENSE +1 -1
- data/README.md +10 -22
- data/Rakefile +1 -1
- data/ext/byebug/byebug.c +3 -2
- data/lib/byebug.rb +3 -38
- data/lib/byebug/commands/break.rb +83 -0
- data/lib/byebug/commands/catchpoint.rb +0 -1
- data/lib/byebug/commands/condition.rb +10 -6
- data/lib/byebug/commands/continue.rb +3 -6
- data/lib/byebug/commands/delete.rb +38 -0
- data/lib/byebug/commands/edit.rb +0 -2
- data/lib/byebug/commands/enable.rb +7 -8
- data/lib/byebug/commands/finish.rb +0 -2
- data/lib/byebug/commands/frame.rb +13 -15
- data/lib/byebug/commands/help.rb +1 -3
- data/lib/byebug/commands/history.rb +3 -3
- data/lib/byebug/commands/info.rb +4 -13
- data/lib/byebug/commands/interrupt.rb +25 -0
- data/lib/byebug/commands/kill.rb +0 -2
- data/lib/byebug/commands/list.rb +2 -4
- data/lib/byebug/commands/method.rb +2 -8
- data/lib/byebug/commands/quit.rb +0 -2
- data/lib/byebug/commands/reload.rb +2 -15
- data/lib/byebug/commands/repl.rb +0 -3
- data/lib/byebug/commands/{control.rb → restart.rb} +2 -26
- data/lib/byebug/commands/save.rb +0 -1
- data/lib/byebug/commands/set.rb +4 -7
- data/lib/byebug/commands/show.rb +0 -3
- data/lib/byebug/commands/source.rb +0 -3
- data/lib/byebug/commands/stepping.rb +3 -4
- data/lib/byebug/commands/trace.rb +0 -1
- data/lib/byebug/commands/variables.rb +3 -4
- data/lib/byebug/context.rb +0 -1
- data/lib/byebug/helper.rb +23 -0
- data/lib/byebug/interfaces/script_interface.rb +1 -1
- data/lib/byebug/processors/command_processor.rb +9 -9
- data/lib/byebug/remote.rb +2 -2
- data/lib/byebug/setting.rb +3 -1
- data/lib/byebug/settings/autoeval.rb +3 -1
- data/lib/byebug/settings/autoirb.rb +3 -1
- data/lib/byebug/settings/autolist.rb +3 -1
- data/lib/byebug/settings/autoreload.rb +1 -3
- data/lib/byebug/settings/autosave.rb +1 -3
- data/lib/byebug/settings/callstyle.rb +2 -4
- data/lib/byebug/settings/fullpath.rb +1 -3
- data/lib/byebug/settings/histfile.rb +1 -3
- data/lib/byebug/settings/histsize.rb +0 -4
- data/lib/byebug/settings/listsize.rb +1 -3
- data/lib/byebug/settings/post_mortem.rb +14 -1
- data/lib/byebug/settings/width.rb +1 -17
- data/lib/byebug/version.rb +1 -1
- data/test/break_test.rb +376 -0
- data/test/condition_test.rb +82 -0
- data/test/continue_test.rb +27 -30
- data/test/debugger_alias_test.rb +4 -4
- data/test/delete_test.rb +26 -0
- data/test/display_test.rb +80 -102
- data/test/edit_test.rb +28 -31
- data/test/eval_test.rb +50 -80
- data/test/finish_test.rb +23 -23
- data/test/frame_test.rb +172 -186
- data/test/help_test.rb +27 -37
- data/test/history_test.rb +32 -41
- data/test/info_test.rb +198 -230
- data/test/interrupt_test.rb +17 -36
- data/test/irb_test.rb +47 -0
- data/test/kill_test.rb +19 -19
- data/test/list_test.rb +126 -133
- data/test/method_test.rb +21 -54
- data/test/post_mortem_test.rb +44 -46
- data/test/pry_test.rb +42 -0
- data/test/quit_test.rb +17 -15
- data/test/reload_test.rb +23 -28
- data/test/restart_test.rb +35 -63
- data/test/save_test.rb +46 -62
- data/test/set_test.rb +93 -144
- data/test/show_test.rb +50 -71
- data/test/source_test.rb +23 -26
- data/test/stepping_test.rb +125 -153
- data/test/support/matchers.rb +1 -6
- data/test/support/test_interface.rb +1 -1
- data/test/support/{test_dsl.rb → utils.rb} +17 -64
- data/test/test_helper.rb +25 -7
- data/test/thread_test.rb +101 -89
- data/test/trace_test.rb +48 -85
- data/test/variables_test.rb +43 -80
- metadata +18 -13
- data/lib/byebug/commands/breakpoints.rb +0 -137
- data/lib/byebug/commands/skip.rb +0 -30
- data/test/breakpoints_test.rb +0 -474
- data/test/conditions_test.rb +0 -82
- data/test/repl_test.rb +0 -75
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: byebug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Rodriguez
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-08-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: columnize
|
@@ -75,11 +75,11 @@ files:
|
|
75
75
|
- ext/byebug/threads.c
|
76
76
|
- lib/byebug.rb
|
77
77
|
- lib/byebug/command.rb
|
78
|
-
- lib/byebug/commands/
|
78
|
+
- lib/byebug/commands/break.rb
|
79
79
|
- lib/byebug/commands/catchpoint.rb
|
80
80
|
- lib/byebug/commands/condition.rb
|
81
81
|
- lib/byebug/commands/continue.rb
|
82
|
-
- lib/byebug/commands/
|
82
|
+
- lib/byebug/commands/delete.rb
|
83
83
|
- lib/byebug/commands/display.rb
|
84
84
|
- lib/byebug/commands/edit.rb
|
85
85
|
- lib/byebug/commands/enable.rb
|
@@ -89,16 +89,17 @@ files:
|
|
89
89
|
- lib/byebug/commands/help.rb
|
90
90
|
- lib/byebug/commands/history.rb
|
91
91
|
- lib/byebug/commands/info.rb
|
92
|
+
- lib/byebug/commands/interrupt.rb
|
92
93
|
- lib/byebug/commands/kill.rb
|
93
94
|
- lib/byebug/commands/list.rb
|
94
95
|
- lib/byebug/commands/method.rb
|
95
96
|
- lib/byebug/commands/quit.rb
|
96
97
|
- lib/byebug/commands/reload.rb
|
97
98
|
- lib/byebug/commands/repl.rb
|
99
|
+
- lib/byebug/commands/restart.rb
|
98
100
|
- lib/byebug/commands/save.rb
|
99
101
|
- lib/byebug/commands/set.rb
|
100
102
|
- lib/byebug/commands/show.rb
|
101
|
-
- lib/byebug/commands/skip.rb
|
102
103
|
- lib/byebug/commands/source.rb
|
103
104
|
- lib/byebug/commands/stepping.rb
|
104
105
|
- lib/byebug/commands/threads.rb
|
@@ -136,10 +137,11 @@ files:
|
|
136
137
|
- lib/byebug/settings/verbose.rb
|
137
138
|
- lib/byebug/settings/width.rb
|
138
139
|
- lib/byebug/version.rb
|
139
|
-
- test/
|
140
|
-
- test/
|
140
|
+
- test/break_test.rb
|
141
|
+
- test/condition_test.rb
|
141
142
|
- test/continue_test.rb
|
142
143
|
- test/debugger_alias_test.rb
|
144
|
+
- test/delete_test.rb
|
143
145
|
- test/display_test.rb
|
144
146
|
- test/edit_test.rb
|
145
147
|
- test/eval_test.rb
|
@@ -149,13 +151,14 @@ files:
|
|
149
151
|
- test/history_test.rb
|
150
152
|
- test/info_test.rb
|
151
153
|
- test/interrupt_test.rb
|
154
|
+
- test/irb_test.rb
|
152
155
|
- test/kill_test.rb
|
153
156
|
- test/list_test.rb
|
154
157
|
- test/method_test.rb
|
155
158
|
- test/post_mortem_test.rb
|
159
|
+
- test/pry_test.rb
|
156
160
|
- test/quit_test.rb
|
157
161
|
- test/reload_test.rb
|
158
|
-
- test/repl_test.rb
|
159
162
|
- test/restart_test.rb
|
160
163
|
- test/save_test.rb
|
161
164
|
- test/set_test.rb
|
@@ -164,8 +167,8 @@ files:
|
|
164
167
|
- test/stepping_test.rb
|
165
168
|
- test/support/breakpoint.rb
|
166
169
|
- test/support/matchers.rb
|
167
|
-
- test/support/test_dsl.rb
|
168
170
|
- test/support/test_interface.rb
|
171
|
+
- test/support/utils.rb
|
169
172
|
- test/test_helper.rb
|
170
173
|
- test/thread_test.rb
|
171
174
|
- test/trace_test.rb
|
@@ -195,10 +198,11 @@ signing_key:
|
|
195
198
|
specification_version: 4
|
196
199
|
summary: Ruby 2.0 fast debugger - base + cli
|
197
200
|
test_files:
|
198
|
-
- test/
|
199
|
-
- test/
|
201
|
+
- test/break_test.rb
|
202
|
+
- test/condition_test.rb
|
200
203
|
- test/continue_test.rb
|
201
204
|
- test/debugger_alias_test.rb
|
205
|
+
- test/delete_test.rb
|
202
206
|
- test/display_test.rb
|
203
207
|
- test/edit_test.rb
|
204
208
|
- test/eval_test.rb
|
@@ -208,13 +212,14 @@ test_files:
|
|
208
212
|
- test/history_test.rb
|
209
213
|
- test/info_test.rb
|
210
214
|
- test/interrupt_test.rb
|
215
|
+
- test/irb_test.rb
|
211
216
|
- test/kill_test.rb
|
212
217
|
- test/list_test.rb
|
213
218
|
- test/method_test.rb
|
214
219
|
- test/post_mortem_test.rb
|
220
|
+
- test/pry_test.rb
|
215
221
|
- test/quit_test.rb
|
216
222
|
- test/reload_test.rb
|
217
|
-
- test/repl_test.rb
|
218
223
|
- test/restart_test.rb
|
219
224
|
- test/save_test.rb
|
220
225
|
- test/set_test.rb
|
@@ -223,8 +228,8 @@ test_files:
|
|
223
228
|
- test/stepping_test.rb
|
224
229
|
- test/support/breakpoint.rb
|
225
230
|
- test/support/matchers.rb
|
226
|
-
- test/support/test_dsl.rb
|
227
231
|
- test/support/test_interface.rb
|
232
|
+
- test/support/utils.rb
|
228
233
|
- test/test_helper.rb
|
229
234
|
- test/thread_test.rb
|
230
235
|
- test/trace_test.rb
|
@@ -1,137 +0,0 @@
|
|
1
|
-
module Byebug
|
2
|
-
|
3
|
-
# Implements byebug "break" command.
|
4
|
-
class BreakCommand < Command
|
5
|
-
self.allow_in_post_mortem = false
|
6
|
-
self.allow_in_control = true
|
7
|
-
|
8
|
-
def regexp
|
9
|
-
/^\s* b(?:reak)? (?:\s+#{Position_regexp})? (?:\s+(.+))? \s*$/x
|
10
|
-
end
|
11
|
-
|
12
|
-
def execute
|
13
|
-
return print BreakCommand.help(nil) if BreakCommand.names.include?(@match[0])
|
14
|
-
|
15
|
-
if @match[1]
|
16
|
-
line, _, _, expr = @match.captures
|
17
|
-
else
|
18
|
-
_, file, line, expr = @match.captures
|
19
|
-
end
|
20
|
-
if expr
|
21
|
-
if expr !~ /^\s*if\s+(.+)/
|
22
|
-
if file or line
|
23
|
-
errmsg "Expecting \"if\" in breakpoint condition; got: #{expr}.\n"
|
24
|
-
else
|
25
|
-
errmsg "Invalid breakpoint location: #{expr}.\n"
|
26
|
-
end
|
27
|
-
return
|
28
|
-
else
|
29
|
-
expr = $1
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
brkpt_filename = file
|
34
|
-
if file.nil?
|
35
|
-
unless @state.context
|
36
|
-
errmsg "We are not in a state that has an associated file.\n"
|
37
|
-
return
|
38
|
-
end
|
39
|
-
brkpt_filename = @state.file
|
40
|
-
if line.nil?
|
41
|
-
# Set breakpoint at current line
|
42
|
-
line = @state.line.to_s
|
43
|
-
end
|
44
|
-
elsif line !~ /^\d+$/
|
45
|
-
# See if "line" is a method/function name
|
46
|
-
klass = bb_warning_eval(file)
|
47
|
-
if klass && klass.kind_of?(Module)
|
48
|
-
class_name = klass.name if klass
|
49
|
-
else
|
50
|
-
errmsg "Unknown class #{file}.\n"
|
51
|
-
throw :debug_error
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
if line =~ /^\d+$/
|
56
|
-
line = line.to_i
|
57
|
-
if LineCache.cache(brkpt_filename, Setting[:autoreload])
|
58
|
-
last_line = LineCache.size(brkpt_filename)
|
59
|
-
return errmsg "There are only #{last_line} lines in file " \
|
60
|
-
"#{brkpt_filename}\n" if line > last_line
|
61
|
-
|
62
|
-
return errmsg "Line #{line} is not a stopping point in file " \
|
63
|
-
"#{brkpt_filename}\n" unless
|
64
|
-
LineCache.trace_line_numbers(brkpt_filename).member?(line)
|
65
|
-
else
|
66
|
-
errmsg "No source file named #{brkpt_filename}\n"
|
67
|
-
return unless confirm("Set breakpoint anyway? (y/n) ")
|
68
|
-
end
|
69
|
-
|
70
|
-
b = Byebug.add_breakpoint brkpt_filename, line, expr
|
71
|
-
print "Created breakpoint #{b.id} at " \
|
72
|
-
"#{CommandProcessor.canonic_file(brkpt_filename)}:#{line.to_s}\n"
|
73
|
-
unless syntax_valid?(expr)
|
74
|
-
errmsg "Expression \"#{expr}\" syntactically incorrect; breakpoint" \
|
75
|
-
" disabled.\n"
|
76
|
-
b.enabled = false
|
77
|
-
end
|
78
|
-
else
|
79
|
-
method = line.intern
|
80
|
-
b = Byebug.add_breakpoint class_name, method, expr
|
81
|
-
print "Created breakpoint #{b.id} at #{class_name}::#{method.to_s}\n"
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
class << self
|
86
|
-
def names
|
87
|
-
%w(break)
|
88
|
-
end
|
89
|
-
|
90
|
-
def description
|
91
|
-
%{b[reak] file:line [if expr]
|
92
|
-
b[reak] class(.|#)method [if expr]
|
93
|
-
|
94
|
-
Set breakpoint to some position, (optionally) if expr == true}
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
# Implements byebug "delete" command.
|
100
|
-
class DeleteCommand < Command
|
101
|
-
self.allow_in_post_mortem = false
|
102
|
-
self.allow_in_control = true
|
103
|
-
|
104
|
-
def regexp
|
105
|
-
/^\s* del(?:ete)? (?:\s+(.*))?$/x
|
106
|
-
end
|
107
|
-
|
108
|
-
def execute
|
109
|
-
return errmsg "We are not in a state we can delete breakpoints.\n" unless
|
110
|
-
@state.context
|
111
|
-
|
112
|
-
if not @match[1]
|
113
|
-
Byebug.breakpoints.clear if confirm("Delete all breakpoints? (y or n) ")
|
114
|
-
else
|
115
|
-
@match[1].split(/[ \t]+/).each do |pos|
|
116
|
-
return unless pos = get_int(pos, "Delete", 1)
|
117
|
-
errmsg "No breakpoint number %d\n", pos unless
|
118
|
-
Byebug.remove_breakpoint(pos)
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
class << self
|
124
|
-
def names
|
125
|
-
%w(delete)
|
126
|
-
end
|
127
|
-
|
128
|
-
def description
|
129
|
-
%{del[ete][ nnn...]
|
130
|
-
|
131
|
-
Without and argument, deletes all breakpoints. With integer arguments,
|
132
|
-
it deletes specific breakpoints.}
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
end
|
data/lib/byebug/commands/skip.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
module Byebug
|
2
|
-
|
3
|
-
# Implements byebug "skip" command
|
4
|
-
class SkipCommand < Command
|
5
|
-
self.allow_in_control = true
|
6
|
-
|
7
|
-
def regexp
|
8
|
-
/^\s* sk(?:ip)? \s*$/x
|
9
|
-
end
|
10
|
-
|
11
|
-
def execute
|
12
|
-
Byebug::skip_next_exception
|
13
|
-
print "ok\n"
|
14
|
-
end
|
15
|
-
|
16
|
-
class << self
|
17
|
-
def names
|
18
|
-
%w(skip)
|
19
|
-
end
|
20
|
-
|
21
|
-
def description
|
22
|
-
%{sk[ip]\tskip the next thrown exception
|
23
|
-
|
24
|
-
This is useful if you've explicitly caught an exception through the
|
25
|
-
"catch" command, and wish to pass the exception on to the code that
|
26
|
-
you're debugging.}
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
data/test/breakpoints_test.rb
DELETED
@@ -1,474 +0,0 @@
|
|
1
|
-
module BreakpointsTest
|
2
|
-
class Example
|
3
|
-
def self.a(num)
|
4
|
-
4
|
5
|
-
end
|
6
|
-
|
7
|
-
def b
|
8
|
-
3
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
class DeepExample
|
13
|
-
def a
|
14
|
-
z = 2
|
15
|
-
b(z)
|
16
|
-
end
|
17
|
-
|
18
|
-
def b(num)
|
19
|
-
v2 = 5 if 1 == num ; [1,2,v2].map { |a| a.to_f }
|
20
|
-
c
|
21
|
-
end
|
22
|
-
|
23
|
-
def c
|
24
|
-
z = 4
|
25
|
-
z += 5
|
26
|
-
byebug
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
class BreakpointsTestCase < TestDsl::TestCase
|
31
|
-
before do
|
32
|
-
@example = -> do
|
33
|
-
y = 3
|
34
|
-
# A comment
|
35
|
-
byebug
|
36
|
-
z = 5
|
37
|
-
Example.new.b
|
38
|
-
Example.a(y+z)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def first
|
43
|
-
Byebug.breakpoints.first
|
44
|
-
end
|
45
|
-
|
46
|
-
def last
|
47
|
-
Byebug.breakpoints.last
|
48
|
-
end
|
49
|
-
|
50
|
-
describe 'setting breakpoint in the current file' do
|
51
|
-
before { enter 'break 33' }
|
52
|
-
|
53
|
-
def check_first(field, value)
|
54
|
-
debug_proc(@example) { first.send(field).must_equal value }
|
55
|
-
end
|
56
|
-
|
57
|
-
it('must have correct pos') { check_first(:pos, 33) }
|
58
|
-
it('must have correct source') { check_first(:source, __FILE__) }
|
59
|
-
it('must have correct expression') { check_first(:expr, nil) }
|
60
|
-
it('must have correct hit count') { check_first(:hit_count, 0) }
|
61
|
-
it('must have correct hit value') { check_first(:hit_value, 0) }
|
62
|
-
it('must be enabled') { check_first(:enabled?, true) }
|
63
|
-
|
64
|
-
it('must return right response') do
|
65
|
-
id = nil
|
66
|
-
debug_proc(@example) { id = first.id }
|
67
|
-
check_output_includes "Created breakpoint #{id} at #{__FILE__}:33"
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
describe 'using shortcut for the command' do
|
72
|
-
before { enter 'b 33' }
|
73
|
-
it 'must set a breakpoint' do
|
74
|
-
debug_proc(@example) { Byebug.breakpoints.size.must_equal 1 }
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe 'setting breakpoint to unexistent line' do
|
79
|
-
before { enter 'break 1000' }
|
80
|
-
|
81
|
-
it 'must not create a breakpoint' do
|
82
|
-
debug_proc(@example) { Byebug.breakpoints.must_be_empty }
|
83
|
-
end
|
84
|
-
|
85
|
-
it 'must show an error' do
|
86
|
-
debug_proc(@example)
|
87
|
-
check_error_includes \
|
88
|
-
"There are only #{LineCache.size(__FILE__)} lines in file #{__FILE__}"
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
describe 'setting breakpoint to incorrect line' do
|
93
|
-
before { enter 'break 6' }
|
94
|
-
|
95
|
-
it 'must not create a breakpoint' do
|
96
|
-
debug_proc(@example) { Byebug.breakpoints.must_be_empty }
|
97
|
-
end
|
98
|
-
|
99
|
-
it 'must show an error' do
|
100
|
-
debug_proc(@example)
|
101
|
-
check_error_includes \
|
102
|
-
"Line 6 is not a stopping point in file #{__FILE__}"
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
describe 'stopping at breakpoint' do
|
107
|
-
before { enter 'break 37', 'cont' }
|
108
|
-
|
109
|
-
it 'must stop at the correct line' do
|
110
|
-
debug_proc(@example) { state.line.must_equal 37 }
|
111
|
-
end
|
112
|
-
|
113
|
-
it 'must stop at the correct file' do
|
114
|
-
debug_proc(@example) { state.file.must_equal __FILE__ }
|
115
|
-
end
|
116
|
-
|
117
|
-
describe 'show a message' do
|
118
|
-
describe 'with full filename' do
|
119
|
-
it 'must show a message with full filename' do
|
120
|
-
debug_proc(@example) { @id = first.id }
|
121
|
-
check_output_includes "Created breakpoint #{@id} at #{__FILE__}:37"
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
describe 'with basename' do
|
126
|
-
temporary_change_hash Byebug::Setting, :basename, true
|
127
|
-
|
128
|
-
it 'must show a message with basename' do
|
129
|
-
debug_proc(@example) { @id = first.id }
|
130
|
-
check_output_includes \
|
131
|
-
"Created breakpoint #{@id} at #{File.basename(__FILE__)}:37"
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
describe 'reloading source on change' do
|
138
|
-
describe 'autoreload not set' do
|
139
|
-
temporary_change_hash Byebug::Setting, :autoreload, false
|
140
|
-
|
141
|
-
it 'must not reload source' do
|
142
|
-
id = nil
|
143
|
-
enter \
|
144
|
-
-> { change_line_in_file(__FILE__, 37, ''); 'break 37' },
|
145
|
-
-> { change_line_in_file(__FILE__, 37, ' Example.new.b');
|
146
|
-
cont }
|
147
|
-
|
148
|
-
debug_proc(@example) { id = first.id }
|
149
|
-
check_output_includes "Created breakpoint #{id} at #{__FILE__}:37"
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
describe 'autoreload set' do
|
154
|
-
it 'must reload source' do
|
155
|
-
enter \
|
156
|
-
-> { change_line_in_file(__FILE__, 37, ''); 'break 37' },
|
157
|
-
-> { change_line_in_file(__FILE__, 37, ' Example.new.b');
|
158
|
-
'next' }
|
159
|
-
|
160
|
-
debug_proc(@example)
|
161
|
-
check_error_includes \
|
162
|
-
"Line 37 is not a stopping point in file #{__FILE__}"
|
163
|
-
end
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
describe 'set breakpoint in a file' do
|
168
|
-
describe 'successfully' do
|
169
|
-
before { enter "break #{__FILE__}:4", 'cont' }
|
170
|
-
|
171
|
-
it 'must stop at the correct line' do
|
172
|
-
debug_proc(@example) { state.line.must_equal 4 }
|
173
|
-
end
|
174
|
-
|
175
|
-
it 'must stop at the correct file' do
|
176
|
-
debug_proc(@example) { state.file.must_equal __FILE__ }
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
describe 'when setting breakpoint to unexisted file' do
|
181
|
-
before do
|
182
|
-
enter 'break asf:324'
|
183
|
-
debug_proc(@example)
|
184
|
-
end
|
185
|
-
|
186
|
-
it 'must show an error' do
|
187
|
-
check_error_includes 'No source file named asf'
|
188
|
-
end
|
189
|
-
|
190
|
-
it 'must ask about setting breakpoint anyway' do
|
191
|
-
check_output_includes \
|
192
|
-
'Set breakpoint anyway? (y/n)', interface.confirm_queue
|
193
|
-
end
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
describe 'set breakpoint to a method' do
|
198
|
-
describe 'set breakpoint to an instance method' do
|
199
|
-
before { enter 'break Example#b', 'cont' }
|
200
|
-
|
201
|
-
it 'must stop at the correct line' do
|
202
|
-
debug_proc(@example) { state.line.must_equal 7 }
|
203
|
-
end
|
204
|
-
|
205
|
-
it 'must stop at the correct file' do
|
206
|
-
debug_proc(@example) { state.file.must_equal __FILE__ }
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
describe 'set breakpoint to a class method' do
|
211
|
-
before { enter 'break Example.a', 'cont' }
|
212
|
-
|
213
|
-
it 'must stop at the correct line' do
|
214
|
-
debug_proc(@example) { state.line.must_equal 3 }
|
215
|
-
end
|
216
|
-
|
217
|
-
it 'must stop at the correct file' do
|
218
|
-
debug_proc(@example) { state.file.must_equal __FILE__ }
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
describe 'set breakpoint to unexisted class' do
|
223
|
-
it 'must show an error' do
|
224
|
-
enter 'break B.a'
|
225
|
-
debug_proc(@example)
|
226
|
-
check_error_includes 'Unknown class B.'
|
227
|
-
end
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
describe 'set breakpoint to an invalid location' do
|
232
|
-
before { enter 'break foo' }
|
233
|
-
|
234
|
-
it 'must not create a breakpoint' do
|
235
|
-
debug_proc(@example) { Byebug.breakpoints.must_be_empty }
|
236
|
-
end
|
237
|
-
|
238
|
-
it 'must show an error' do
|
239
|
-
debug_proc(@example)
|
240
|
-
check_error_includes 'Invalid breakpoint location: foo.'
|
241
|
-
end
|
242
|
-
end
|
243
|
-
|
244
|
-
describe 'disabling breakpoints' do
|
245
|
-
describe 'successfully' do
|
246
|
-
before { enter 'break 37', 'break 38' }
|
247
|
-
|
248
|
-
describe 'short syntax' do
|
249
|
-
before { enter ->{ "disable #{first.id}" } }
|
250
|
-
|
251
|
-
it 'must have a breakpoint with #enabled? returning false' do
|
252
|
-
debug_proc(@example) { first.enabled?.must_equal false }
|
253
|
-
end
|
254
|
-
|
255
|
-
it 'must not stop on the disabled breakpoint' do
|
256
|
-
enter 'cont'
|
257
|
-
debug_proc(@example) { state.line.must_equal 38 }
|
258
|
-
end
|
259
|
-
end
|
260
|
-
|
261
|
-
describe 'full syntax' do
|
262
|
-
describe 'with no args' do
|
263
|
-
before { enter 'disable breakpoints' }
|
264
|
-
|
265
|
-
it 'must have all breakoints with #enabled? returning false' do
|
266
|
-
debug_proc(@example) do
|
267
|
-
first.enabled?.must_equal false
|
268
|
-
last.enabled?.must_equal false
|
269
|
-
end
|
270
|
-
end
|
271
|
-
|
272
|
-
it 'must not stop on any disabled breakpoint' do
|
273
|
-
enter 'cont'
|
274
|
-
debug_proc(@example)
|
275
|
-
# Obscure assert to check for program termination
|
276
|
-
state.proceed.must_equal true
|
277
|
-
end
|
278
|
-
end
|
279
|
-
|
280
|
-
describe 'with specific breakpoint' do
|
281
|
-
before do
|
282
|
-
enter ->{ "disable breakpoints #{first.id}" }
|
283
|
-
end
|
284
|
-
|
285
|
-
it 'must have a breakpoint with #enabled? returning false' do
|
286
|
-
debug_proc(@example) {
|
287
|
-
first.enabled?.must_equal false }
|
288
|
-
end
|
289
|
-
end
|
290
|
-
end
|
291
|
-
end
|
292
|
-
|
293
|
-
describe 'unsuccesfully' do
|
294
|
-
it 'must show an error if syntax is incorrect' do
|
295
|
-
enter 'disable'
|
296
|
-
debug_proc(@example)
|
297
|
-
check_error_includes '"disable" must be followed by "display", ' \
|
298
|
-
'"breakpoints" or breakpoint numbers.'
|
299
|
-
end
|
300
|
-
|
301
|
-
it 'must show an error if no breakpoints are set' do
|
302
|
-
enter 'disable 1'
|
303
|
-
debug_proc(@example)
|
304
|
-
check_error_includes 'No breakpoints have been set.'
|
305
|
-
end
|
306
|
-
|
307
|
-
it 'must show an error if a number is not provided as an argument' do
|
308
|
-
enter 'break 5', 'disable foo'
|
309
|
-
debug_proc(@example)
|
310
|
-
check_output_includes \
|
311
|
-
'"disable breakpoints" argument "foo" needs to be a number'
|
312
|
-
end
|
313
|
-
end
|
314
|
-
end
|
315
|
-
|
316
|
-
describe 'enabling breakpoints' do
|
317
|
-
describe 'successfully' do
|
318
|
-
before { enter 'break 37', 'break 38', 'disable breakpoints' }
|
319
|
-
|
320
|
-
describe 'short syntax' do
|
321
|
-
before { enter ->{ "enable #{first.id}" } }
|
322
|
-
|
323
|
-
it 'must have a breakpoint with #enabled? returning true' do
|
324
|
-
debug_proc(@example) { first.enabled?.must_equal true }
|
325
|
-
end
|
326
|
-
|
327
|
-
it 'must stop on the enabled breakpoint' do
|
328
|
-
enter 'cont'
|
329
|
-
debug_proc(@example) { state.line.must_equal 37 }
|
330
|
-
end
|
331
|
-
end
|
332
|
-
|
333
|
-
describe 'full syntax' do
|
334
|
-
describe 'with no args' do
|
335
|
-
before { enter 'enable breakpoints' }
|
336
|
-
|
337
|
-
it 'must have all breakoints with #enabled? returning true' do
|
338
|
-
debug_proc(@example) do
|
339
|
-
first.enabled?.must_equal true
|
340
|
-
last.enabled?.must_equal true
|
341
|
-
end
|
342
|
-
end
|
343
|
-
|
344
|
-
it 'must stop on the first breakpoint' do
|
345
|
-
enter 'cont'
|
346
|
-
debug_proc(@example) { state.line.must_equal 37 }
|
347
|
-
end
|
348
|
-
|
349
|
-
it 'must stop on the last breakpoint' do
|
350
|
-
enter 'cont', 'cont'
|
351
|
-
debug_proc(@example) { state.line.must_equal 38 }
|
352
|
-
end
|
353
|
-
end
|
354
|
-
|
355
|
-
describe 'with specific breakpoint' do
|
356
|
-
before { enter ->{ "enable breakpoints #{last.id}" } }
|
357
|
-
|
358
|
-
it 'must have a breakpoint with #enabled? returning true' do
|
359
|
-
debug_proc(@example) { last.enabled?.must_equal true }
|
360
|
-
end
|
361
|
-
|
362
|
-
it 'must stop only on the enabled breakpoint' do
|
363
|
-
enter 'cont'
|
364
|
-
debug_proc(@example) { state.line.must_equal 38 }
|
365
|
-
end
|
366
|
-
end
|
367
|
-
end
|
368
|
-
end
|
369
|
-
|
370
|
-
describe 'errors' do
|
371
|
-
it 'must show an error if syntax is incorrect' do
|
372
|
-
enter 'enable'
|
373
|
-
debug_proc(@example)
|
374
|
-
check_error_includes '"enable" must be followed by "display", ' \
|
375
|
-
'"breakpoints" or breakpoint numbers.'
|
376
|
-
end
|
377
|
-
end
|
378
|
-
end
|
379
|
-
|
380
|
-
describe 'deleting a breakpoint' do
|
381
|
-
before { enter 'break 37', -> { "delete #{first.id}" }, 'break 38' }
|
382
|
-
|
383
|
-
it 'must have only one breakpoint' do
|
384
|
-
debug_proc(@example) { Byebug.breakpoints.size.must_equal 1 }
|
385
|
-
end
|
386
|
-
|
387
|
-
it 'must not stop on the disabled breakpoint' do
|
388
|
-
enter 'cont'
|
389
|
-
debug_proc(@example) { state.line.must_equal 38 }
|
390
|
-
end
|
391
|
-
end
|
392
|
-
|
393
|
-
describe 'Conditional breakpoints' do
|
394
|
-
it 'must stop if the condition is true' do
|
395
|
-
enter 'break 37 if z == 5', 'break 38', 'cont'
|
396
|
-
debug_proc(@example) { state.line.must_equal 37 }
|
397
|
-
end
|
398
|
-
|
399
|
-
it 'must skip if the condition is false' do
|
400
|
-
enter 'break 37 if z == 3', 'break 38', 'cont'
|
401
|
-
debug_proc(@example) { state.line.must_equal 38 }
|
402
|
-
end
|
403
|
-
|
404
|
-
it 'must show an error when conditional syntax is wrong' do
|
405
|
-
enter 'break 37 ifa z == 3', 'break 38', 'cont'
|
406
|
-
debug_proc(@example) { state.line.must_equal 38 }
|
407
|
-
check_error_includes \
|
408
|
-
'Expecting "if" in breakpoint condition; got: ifa z == 3.'
|
409
|
-
end
|
410
|
-
|
411
|
-
describe 'enabling with wrong conditional syntax' do
|
412
|
-
before do
|
413
|
-
enter 'break 37', -> { "disable #{first.id}" },
|
414
|
-
-> { "cond #{first.id} z -=( 3" },
|
415
|
-
-> { "enable #{first.id}"}
|
416
|
-
end
|
417
|
-
|
418
|
-
it 'must not enable a breakpoint' do
|
419
|
-
debug_proc(@example) { first.enabled?.must_equal false }
|
420
|
-
end
|
421
|
-
|
422
|
-
it 'must show an error' do
|
423
|
-
debug_proc(@example)
|
424
|
-
check_error_includes 'Expression "z -=( 3" syntactically incorrect; ' \
|
425
|
-
'breakpoint remains disabled.'
|
426
|
-
end
|
427
|
-
end
|
428
|
-
|
429
|
-
it 'must show an error if no file or line is specified' do
|
430
|
-
enter 'break ifa z == 3', 'break 38', 'cont'
|
431
|
-
debug_proc(@example) { state.line.must_equal 38 }
|
432
|
-
check_error_includes 'Invalid breakpoint location: ifa z == 3.'
|
433
|
-
end
|
434
|
-
|
435
|
-
it 'must show an error if expression syntax is invalid' do
|
436
|
-
enter 'break if z -=) 3', 'break 38', 'cont'
|
437
|
-
debug_proc(@example) { state.line.must_equal 38 }
|
438
|
-
check_error_includes \
|
439
|
-
'Expression "z -=) 3" syntactically incorrect; breakpoint disabled.'
|
440
|
-
end
|
441
|
-
end
|
442
|
-
|
443
|
-
describe 'Stopping through `byebug` keyword' do
|
444
|
-
describe 'when not the last instruction of a method' do
|
445
|
-
it 'must stop in the next line' do
|
446
|
-
debug_proc(@example) { state.line.must_equal 36 }
|
447
|
-
end
|
448
|
-
end
|
449
|
-
|
450
|
-
describe 'when last instruction of a method' do
|
451
|
-
before do
|
452
|
-
@deep_example = lambda do
|
453
|
-
ex = DeepExample.new.a
|
454
|
-
2.times do
|
455
|
-
ex = ex ? ex : 1
|
456
|
-
end
|
457
|
-
end
|
458
|
-
end
|
459
|
-
|
460
|
-
it 'must stop right before returning from the frame' do
|
461
|
-
debug_proc(@deep_example) { state.line.must_equal 27 }
|
462
|
-
end
|
463
|
-
end
|
464
|
-
end
|
465
|
-
|
466
|
-
describe 'Help' do
|
467
|
-
it 'must show info about setting breakpoints when using just "break"' do
|
468
|
-
enter 'break', 'cont'
|
469
|
-
debug_proc(@example)
|
470
|
-
check_output_includes(/b\[reak\] file:line \[if expr\]/)
|
471
|
-
end
|
472
|
-
end
|
473
|
-
end
|
474
|
-
end
|