byebug 3.0.0 → 3.1.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/GUIDE.md +2 -2
- data/LICENSE +3 -3
- data/README.md +5 -4
- data/byebug.gemspec +1 -1
- data/ext/byebug/byebug.c +20 -19
- data/lib/byebug.rb +2 -53
- data/lib/byebug/command.rb +9 -109
- data/lib/byebug/commands/breakpoints.rb +1 -1
- data/lib/byebug/commands/control.rb +20 -21
- data/lib/byebug/commands/display.rb +2 -3
- data/lib/byebug/commands/eval.rb +6 -16
- data/lib/byebug/commands/finish.rb +1 -1
- data/lib/byebug/commands/frame.rb +9 -9
- data/lib/byebug/commands/help.rb +2 -3
- data/lib/byebug/commands/history.rb +28 -0
- data/lib/byebug/commands/info.rb +3 -3
- data/lib/byebug/commands/list.rb +2 -13
- data/lib/byebug/commands/method.rb +5 -45
- data/lib/byebug/commands/reload.rb +1 -12
- data/lib/byebug/commands/repl.rb +6 -15
- data/lib/byebug/commands/save.rb +2 -7
- data/lib/byebug/commands/set.rb +45 -116
- data/lib/byebug/commands/show.rb +22 -126
- data/lib/byebug/commands/stepping.rb +1 -1
- data/lib/byebug/commands/trace.rb +14 -25
- data/lib/byebug/commands/variables.rb +3 -41
- data/lib/byebug/helper.rb +11 -42
- data/lib/byebug/history.rb +5 -13
- data/lib/byebug/processors/command_processor.rb +6 -6
- data/lib/byebug/setting.rb +82 -0
- data/lib/byebug/settings/autoeval.rb +20 -0
- data/lib/byebug/settings/autoirb.rb +19 -0
- data/lib/byebug/settings/autolist.rb +19 -0
- data/lib/byebug/settings/autoreload.rb +11 -0
- data/lib/byebug/settings/autosave.rb +11 -0
- data/lib/byebug/settings/basename.rb +7 -0
- data/lib/byebug/settings/callstyle.rb +15 -0
- data/lib/byebug/settings/forcestep.rb +11 -0
- data/lib/byebug/settings/fullpath.rb +11 -0
- data/lib/byebug/settings/histfile.rb +16 -0
- data/lib/byebug/settings/histsize.rb +18 -0
- data/lib/byebug/settings/linetrace.rb +15 -0
- data/lib/byebug/settings/listsize.rb +15 -0
- data/lib/byebug/settings/post_mortem.rb +15 -0
- data/lib/byebug/settings/stack_on_error.rb +7 -0
- data/lib/byebug/settings/testing.rb +7 -0
- data/lib/byebug/settings/tracing_plus.rb +7 -0
- data/lib/byebug/settings/verbose.rb +7 -0
- data/lib/byebug/settings/width.rb +29 -0
- data/lib/byebug/version.rb +1 -1
- data/test/breakpoints_test.rb +345 -324
- data/test/conditions_test.rb +61 -48
- data/test/continue_test.rb +38 -27
- data/test/debugger_alias_test.rb +5 -3
- data/test/display_test.rb +103 -92
- data/test/edit_test.rb +42 -34
- data/test/eval_test.rb +91 -75
- data/test/finish_test.rb +51 -40
- data/test/frame_test.rb +197 -184
- data/test/help_test.rb +47 -38
- data/test/history_test.rb +54 -0
- data/test/info_test.rb +306 -293
- data/test/interrupt_test.rb +44 -38
- data/test/kill_test.rb +40 -31
- data/test/list_test.rb +166 -133
- data/test/method_test.rb +67 -60
- data/test/post_mortem_test.rb +56 -48
- data/test/quit_test.rb +44 -35
- data/test/reload_test.rb +36 -24
- data/test/repl_test.rb +57 -47
- data/test/restart_test.rb +56 -69
- data/test/save_test.rb +62 -53
- data/test/set_test.rb +140 -118
- data/test/show_test.rb +68 -201
- data/test/source_test.rb +39 -29
- data/test/stepping_test.rb +163 -136
- data/test/support/test_dsl.rb +9 -11
- data/test/test_helper.rb +2 -7
- data/test/thread_test.rb +121 -107
- data/test/trace_test.rb +86 -83
- data/test/variables_test.rb +104 -98
- metadata +27 -86
- data/test/examples/breakpoint.rb +0 -6
- data/test/examples/breakpoint_deep.rb +0 -4
- data/test/examples/conditions.rb +0 -4
- data/test/examples/continue.rb +0 -5
- data/test/examples/display.rb +0 -5
- data/test/examples/edit.rb +0 -4
- data/test/examples/eval.rb +0 -4
- data/test/examples/finish.rb +0 -3
- data/test/examples/frame.rb +0 -4
- data/test/examples/frame_deep.rb +0 -1
- data/test/examples/gcd.rb +0 -15
- data/test/examples/hanoi.rb +0 -34
- data/test/examples/help.rb +0 -1
- data/test/examples/info.rb +0 -6
- data/test/examples/info2.rb +0 -3
- data/test/examples/interrupt.rb +0 -8
- data/test/examples/kill.rb +0 -2
- data/test/examples/list.rb +0 -23
- data/test/examples/method.rb +0 -4
- data/test/examples/post_mortem.rb +0 -4
- data/test/examples/primes.rb +0 -25
- data/test/examples/quit.rb +0 -2
- data/test/examples/reload.rb +0 -6
- data/test/examples/repl.rb +0 -6
- data/test/examples/restart.rb +0 -6
- data/test/examples/save.rb +0 -3
- data/test/examples/set.rb +0 -3
- data/test/examples/settings.rb +0 -1
- data/test/examples/show.rb +0 -1
- data/test/examples/source.rb +0 -3
- data/test/examples/stepping.rb +0 -8
- data/test/examples/stepping_raise_from_c_method.rb +0 -3
- data/test/examples/stepping_raise_from_ruby_method.rb +0 -3
- data/test/examples/test-triangle.rb +0 -14
- data/test/examples/thread.rb +0 -5
- data/test/examples/tmate.rb +0 -10
- data/test/examples/trace.rb +0 -8
- data/test/examples/tri3.rb +0 -6
- data/test/examples/triangle.rb +0 -13
- data/test/examples/variables.rb +0 -4
- data/test/timeout_test.rb +0 -9
@@ -0,0 +1,29 @@
|
|
1
|
+
module Byebug
|
2
|
+
class WidthSetting < Setting
|
3
|
+
def initialize
|
4
|
+
if ENV['COLUMNS'] =~ /^\d+$/
|
5
|
+
@value = ENV['COLUMNS'].to_i
|
6
|
+
elsif STDIN.tty? && exists?('stty')
|
7
|
+
@value = `stty size`.scan(/\d+/)[1].to_i
|
8
|
+
else
|
9
|
+
@value = 160
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def help
|
14
|
+
"Number of characters per line in byebug's output"
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_s
|
18
|
+
"Maximum width of byebug's output is #{value}"
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def exists?(command)
|
24
|
+
ENV['PATH'].split(File::PATH_SEPARATOR).any? do |d|
|
25
|
+
File.exist?(File.join(d, command))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/byebug/version.rb
CHANGED
data/test/breakpoints_test.rb
CHANGED
@@ -1,453 +1,474 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
3
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
class BreakpointDeepExample
|
11
|
-
def a
|
12
|
-
z = 2
|
13
|
-
b(z)
|
14
|
-
end
|
15
|
-
|
16
|
-
def b(num)
|
17
|
-
v2 = 5 if 1 == num ; [1,2,v2].map { |a| a.to_f }
|
18
|
-
c
|
19
|
-
end
|
20
|
-
|
21
|
-
def c
|
22
|
-
z = 4
|
23
|
-
z += 5
|
24
|
-
byebug
|
25
|
-
end
|
26
|
-
end
|
1
|
+
module BreakpointsTest
|
2
|
+
class Example
|
3
|
+
def self.a(num)
|
4
|
+
4
|
5
|
+
end
|
27
6
|
|
28
|
-
|
29
|
-
|
30
|
-
|
7
|
+
def b
|
8
|
+
3
|
9
|
+
end
|
31
10
|
end
|
32
11
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
def check_subject(field, value)
|
39
|
-
debug_file('breakpoint') { subject.send(field).must_equal value }
|
12
|
+
class DeepExample
|
13
|
+
def a
|
14
|
+
z = 2
|
15
|
+
b(z)
|
40
16
|
end
|
41
17
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
it('must have correct hit count') { check_subject(:hit_count, 0) }
|
46
|
-
it('must have correct hit value') { check_subject(:hit_value, 0) }
|
47
|
-
it('must be enabled') { check_subject(:enabled?, true) }
|
48
|
-
|
49
|
-
it('must return right response') do
|
50
|
-
id = nil
|
51
|
-
debug_file('breakpoint') { id = subject.id }
|
52
|
-
check_output_includes "Created breakpoint #{id} at #{@tst_file}:1"
|
18
|
+
def b(num)
|
19
|
+
v2 = 5 if 1 == num ; [1,2,v2].map { |a| a.to_f }
|
20
|
+
c
|
53
21
|
end
|
54
|
-
end
|
55
22
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
23
|
+
def c
|
24
|
+
z = 4
|
25
|
+
z += 5
|
26
|
+
byebug
|
60
27
|
end
|
61
28
|
end
|
62
29
|
|
63
|
-
|
64
|
-
before
|
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
|
65
41
|
|
66
|
-
|
67
|
-
|
42
|
+
def first
|
43
|
+
Byebug.breakpoints.first
|
68
44
|
end
|
69
45
|
|
70
|
-
|
71
|
-
|
72
|
-
check_error_includes \
|
73
|
-
"There are only #{LineCache.size(@tst_file)} lines in file #{@tst_file}"
|
46
|
+
def last
|
47
|
+
Byebug.breakpoints.last
|
74
48
|
end
|
75
|
-
end
|
76
49
|
|
77
|
-
|
78
|
-
|
50
|
+
describe 'setting breakpoint in the current file' do
|
51
|
+
before { enter 'break 33' }
|
79
52
|
|
80
|
-
|
81
|
-
|
82
|
-
|
53
|
+
def check_first(field, value)
|
54
|
+
debug_proc(@example) { first.send(field).must_equal value }
|
55
|
+
end
|
83
56
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
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) }
|
90
63
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
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
|
95
69
|
end
|
96
70
|
|
97
|
-
|
98
|
-
enter '
|
99
|
-
|
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
|
100
76
|
end
|
101
77
|
|
102
|
-
describe '
|
103
|
-
|
104
|
-
it 'must show a message with full filename' do
|
105
|
-
enter 'break 5', 'cont'
|
106
|
-
debug_file('breakpoint') { @id = Byebug.breakpoints.first.id }
|
107
|
-
check_output_includes "Created breakpoint #{@id} at #{@tst_file}:5"
|
108
|
-
end
|
109
|
-
end
|
78
|
+
describe 'setting breakpoint to unexistent line' do
|
79
|
+
before { enter 'break 1000' }
|
110
80
|
|
111
|
-
|
112
|
-
|
81
|
+
it 'must not create a breakpoint' do
|
82
|
+
debug_proc(@example) { Byebug.breakpoints.must_be_empty }
|
83
|
+
end
|
113
84
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
end
|
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__}"
|
119
89
|
end
|
120
90
|
end
|
121
|
-
end
|
122
91
|
|
123
|
-
|
124
|
-
|
125
|
-
temporary_change_hash Byebug.settings, :autoreload, false
|
92
|
+
describe 'setting breakpoint to incorrect line' do
|
93
|
+
before { enter 'break 6' }
|
126
94
|
|
127
|
-
it 'must not
|
128
|
-
|
129
|
-
enter ->{ change_line_in_file(@tst_file, 5, ''); 'break 5' },
|
130
|
-
->{ change_line_in_file(@tst_file, 5, 'BreakpointExample.new.b');
|
131
|
-
cont }
|
132
|
-
debug_file('breakpoint') { id = Byebug.breakpoints.first.id }
|
133
|
-
check_output_includes "Created breakpoint #{id} at #{@tst_file}:5"
|
95
|
+
it 'must not create a breakpoint' do
|
96
|
+
debug_proc(@example) { Byebug.breakpoints.must_be_empty }
|
134
97
|
end
|
135
|
-
end
|
136
98
|
|
137
|
-
|
138
|
-
|
139
|
-
enter \
|
140
|
-
->{change_line_in_file(@tst_file, 5, ''); 'break 5'},
|
141
|
-
->{change_line_in_file(@tst_file, 5, 'BreakpointExample.new.b');
|
142
|
-
'next'}
|
143
|
-
debug_file 'breakpoint'
|
99
|
+
it 'must show an error' do
|
100
|
+
debug_proc(@example)
|
144
101
|
check_error_includes \
|
145
|
-
"Line
|
102
|
+
"Line 6 is not a stopping point in file #{__FILE__}"
|
146
103
|
end
|
147
104
|
end
|
148
|
-
end
|
149
105
|
|
150
|
-
|
151
|
-
|
152
|
-
before { enter "break #{__FILE__}:3", 'cont' }
|
106
|
+
describe 'stopping at breakpoint' do
|
107
|
+
before { enter 'break 37', 'cont' }
|
153
108
|
|
154
109
|
it 'must stop at the correct line' do
|
155
|
-
|
110
|
+
debug_proc(@example) { state.line.must_equal 37 }
|
156
111
|
end
|
157
112
|
|
158
113
|
it 'must stop at the correct file' do
|
159
|
-
|
114
|
+
debug_proc(@example) { state.file.must_equal __FILE__ }
|
160
115
|
end
|
161
|
-
end
|
162
116
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
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
|
168
124
|
|
169
|
-
|
170
|
-
|
171
|
-
end
|
125
|
+
describe 'with basename' do
|
126
|
+
temporary_change_hash Byebug::Setting, :basename, true
|
172
127
|
|
173
|
-
|
174
|
-
|
175
|
-
|
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
|
176
134
|
end
|
177
135
|
end
|
178
|
-
end
|
179
136
|
|
180
|
-
|
181
|
-
|
182
|
-
|
137
|
+
describe 'reloading source on change' do
|
138
|
+
describe 'autoreload not set' do
|
139
|
+
temporary_change_hash Byebug::Setting, :autoreload, false
|
183
140
|
|
184
|
-
|
185
|
-
|
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
|
186
151
|
end
|
187
152
|
|
188
|
-
|
189
|
-
|
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
|
190
164
|
end
|
191
165
|
end
|
192
166
|
|
193
|
-
describe 'set breakpoint
|
194
|
-
|
167
|
+
describe 'set breakpoint in a file' do
|
168
|
+
describe 'successfully' do
|
169
|
+
before { enter "break #{__FILE__}:4", 'cont' }
|
195
170
|
|
196
|
-
|
197
|
-
|
198
|
-
|
171
|
+
it 'must stop at the correct line' do
|
172
|
+
debug_proc(@example) { state.line.must_equal 4 }
|
173
|
+
end
|
199
174
|
|
200
|
-
|
201
|
-
|
175
|
+
it 'must stop at the correct file' do
|
176
|
+
debug_proc(@example) { state.file.must_equal __FILE__ }
|
177
|
+
end
|
202
178
|
end
|
203
|
-
end
|
204
179
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
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
|
210
194
|
end
|
211
195
|
end
|
212
|
-
end
|
213
196
|
|
214
|
-
|
215
|
-
|
197
|
+
describe 'set breakpoint to a method' do
|
198
|
+
describe 'set breakpoint to an instance method' do
|
199
|
+
before { enter 'break Example#b', 'cont' }
|
216
200
|
|
217
|
-
|
218
|
-
|
219
|
-
|
201
|
+
it 'must stop at the correct line' do
|
202
|
+
debug_proc(@example) { state.line.must_equal 7 }
|
203
|
+
end
|
220
204
|
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
end
|
205
|
+
it 'must stop at the correct file' do
|
206
|
+
debug_proc(@example) { state.file.must_equal __FILE__ }
|
207
|
+
end
|
208
|
+
end
|
226
209
|
|
227
|
-
|
228
|
-
|
229
|
-
before { enter 'break 5', 'break 6' }
|
210
|
+
describe 'set breakpoint to a class method' do
|
211
|
+
before { enter 'break Example.a', 'cont' }
|
230
212
|
|
231
|
-
|
232
|
-
|
213
|
+
it 'must stop at the correct line' do
|
214
|
+
debug_proc(@example) { state.line.must_equal 3 }
|
215
|
+
end
|
233
216
|
|
234
|
-
it 'must
|
235
|
-
|
236
|
-
Byebug.breakpoints.first.enabled?.must_equal false }
|
217
|
+
it 'must stop at the correct file' do
|
218
|
+
debug_proc(@example) { state.file.must_equal __FILE__ }
|
237
219
|
end
|
220
|
+
end
|
238
221
|
|
239
|
-
|
240
|
-
|
241
|
-
|
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.'
|
242
227
|
end
|
243
228
|
end
|
229
|
+
end
|
244
230
|
|
245
|
-
|
246
|
-
|
247
|
-
before { enter 'disable breakpoints' }
|
231
|
+
describe 'set breakpoint to an invalid location' do
|
232
|
+
before { enter 'break foo' }
|
248
233
|
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
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 }
|
254
253
|
end
|
255
254
|
|
256
|
-
it 'must not stop on
|
255
|
+
it 'must not stop on the disabled breakpoint' do
|
257
256
|
enter 'cont'
|
258
|
-
|
259
|
-
# Obscure assert to check for program termination
|
260
|
-
state.proceed.must_equal true
|
257
|
+
debug_proc(@example) { state.line.must_equal 38 }
|
261
258
|
end
|
262
259
|
end
|
263
260
|
|
264
|
-
describe '
|
265
|
-
|
266
|
-
|
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
|
267
278
|
end
|
268
279
|
|
269
|
-
|
270
|
-
|
271
|
-
|
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
|
272
289
|
end
|
273
290
|
end
|
274
291
|
end
|
275
|
-
end
|
276
292
|
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
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
|
284
300
|
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
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
|
290
306
|
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
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
|
296
313
|
end
|
297
314
|
end
|
298
|
-
end
|
299
315
|
|
300
|
-
|
301
|
-
|
302
|
-
|
316
|
+
describe 'enabling breakpoints' do
|
317
|
+
describe 'successfully' do
|
318
|
+
before { enter 'break 37', 'break 38', 'disable breakpoints' }
|
303
319
|
|
304
|
-
|
305
|
-
|
320
|
+
describe 'short syntax' do
|
321
|
+
before { enter ->{ "enable #{first.id}" } }
|
306
322
|
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
end
|
323
|
+
it 'must have a breakpoint with #enabled? returning true' do
|
324
|
+
debug_proc(@example) { first.enabled?.must_equal true }
|
325
|
+
end
|
311
326
|
|
312
|
-
|
313
|
-
|
314
|
-
|
327
|
+
it 'must stop on the enabled breakpoint' do
|
328
|
+
enter 'cont'
|
329
|
+
debug_proc(@example) { state.line.must_equal 37 }
|
330
|
+
end
|
315
331
|
end
|
316
|
-
end
|
317
332
|
|
318
|
-
|
319
|
-
|
320
|
-
|
333
|
+
describe 'full syntax' do
|
334
|
+
describe 'with no args' do
|
335
|
+
before { enter 'enable breakpoints' }
|
321
336
|
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
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
|
326
342
|
end
|
327
|
-
end
|
328
343
|
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
344
|
+
it 'must stop on the first breakpoint' do
|
345
|
+
enter 'cont'
|
346
|
+
debug_proc(@example) { state.line.must_equal 37 }
|
347
|
+
end
|
333
348
|
|
334
|
-
|
335
|
-
|
336
|
-
|
349
|
+
it 'must stop on the last breakpoint' do
|
350
|
+
enter 'cont', 'cont'
|
351
|
+
debug_proc(@example) { state.line.must_equal 38 }
|
352
|
+
end
|
337
353
|
end
|
338
|
-
end
|
339
354
|
|
340
|
-
|
341
|
-
|
342
|
-
enter ->{ "enable breakpoints #{Byebug.breakpoints.last.id}" }
|
343
|
-
end
|
355
|
+
describe 'with specific breakpoint' do
|
356
|
+
before { enter ->{ "enable breakpoints #{last.id}" } }
|
344
357
|
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
end
|
358
|
+
it 'must have a breakpoint with #enabled? returning true' do
|
359
|
+
debug_proc(@example) { last.enabled?.must_equal true }
|
360
|
+
end
|
349
361
|
|
350
|
-
|
351
|
-
|
352
|
-
|
362
|
+
it 'must stop only on the enabled breakpoint' do
|
363
|
+
enter 'cont'
|
364
|
+
debug_proc(@example) { state.line.must_equal 38 }
|
365
|
+
end
|
353
366
|
end
|
354
367
|
end
|
355
368
|
end
|
356
|
-
end
|
357
369
|
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
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
|
364
377
|
end
|
365
378
|
end
|
366
|
-
end
|
367
379
|
|
368
|
-
|
369
|
-
|
370
|
-
'break 6' }
|
380
|
+
describe 'deleting a breakpoint' do
|
381
|
+
before { enter 'break 37', -> { "delete #{first.id}" }, 'break 38' }
|
371
382
|
|
372
|
-
|
373
|
-
|
374
|
-
|
383
|
+
it 'must have only one breakpoint' do
|
384
|
+
debug_proc(@example) { Byebug.breakpoints.size.must_equal 1 }
|
385
|
+
end
|
375
386
|
|
376
|
-
|
377
|
-
|
378
|
-
|
387
|
+
it 'must not stop on the disabled breakpoint' do
|
388
|
+
enter 'cont'
|
389
|
+
debug_proc(@example) { state.line.must_equal 38 }
|
390
|
+
end
|
379
391
|
end
|
380
|
-
end
|
381
392
|
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
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
|
387
398
|
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
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
|
392
403
|
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
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
|
399
410
|
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
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
|
405
417
|
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
end
|
418
|
+
it 'must not enable a breakpoint' do
|
419
|
+
debug_proc(@example) { first.enabled?.must_equal false }
|
420
|
+
end
|
410
421
|
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
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
|
415
427
|
end
|
416
|
-
end
|
417
428
|
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
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
|
423
434
|
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
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
|
429
441
|
end
|
430
|
-
end
|
431
442
|
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
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
|
436
448
|
end
|
437
|
-
end
|
438
449
|
|
439
|
-
|
440
|
-
|
441
|
-
|
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
|
442
463
|
end
|
443
464
|
end
|
444
|
-
end
|
445
465
|
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
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
|
451
472
|
end
|
452
473
|
end
|
453
474
|
end
|