byebug 1.0.2 → 1.0.3
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 +11 -0
- data/README.md +1 -1
- data/bin/byebug +1 -2
- data/byebug.gemspec +1 -1
- data/ext/byebug/byebug.c +50 -35
- data/ext/byebug/context.c +99 -45
- data/lib/byebug.rb +5 -10
- data/lib/byebug/command.rb +20 -12
- data/lib/byebug/commands/breakpoints.rb +1 -1
- data/lib/byebug/commands/control.rb +14 -21
- data/lib/byebug/commands/display.rb +4 -4
- data/lib/byebug/commands/enable.rb +20 -19
- data/lib/byebug/commands/eval.rb +1 -1
- data/lib/byebug/commands/finish.rb +4 -5
- data/lib/byebug/commands/info.rb +118 -116
- data/lib/byebug/commands/list.rb +72 -48
- data/lib/byebug/commands/reload.rb +4 -3
- data/lib/byebug/commands/set.rb +7 -16
- data/lib/byebug/commands/show.rb +2 -2
- data/lib/byebug/commands/threads.rb +7 -6
- data/lib/byebug/context.rb +10 -2
- data/lib/byebug/helper.rb +3 -3
- data/lib/byebug/processor.rb +1 -1
- data/lib/byebug/version.rb +1 -1
- data/old_doc/byebug.texi +45 -51
- data/test/breakpoints_test.rb +180 -195
- data/test/display_test.rb +59 -53
- data/test/eval_test.rb +0 -2
- data/test/examples/info.rb +5 -5
- data/test/examples/info_threads.rb +1 -1
- data/test/finish_test.rb +16 -15
- data/test/info_test.rb +9 -10
- data/test/irb_test.rb +64 -65
- data/test/list_test.rb +76 -50
- data/test/method_test.rb +10 -5
- data/test/post_mortem_test.rb +27 -25
- data/test/reload_test.rb +31 -31
- data/test/restart_test.rb +106 -110
- data/test/show_test.rb +8 -16
- data/test/stepping_test.rb +4 -2
- data/test/support/test_dsl.rb +37 -76
- data/test/test_helper.rb +0 -1
- data/test/variables_test.rb +9 -12
- metadata +4 -4
data/test/display_test.rb
CHANGED
@@ -1,140 +1,146 @@
|
|
1
1
|
require_relative 'test_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe 'Display Command' do
|
4
4
|
include TestDsl
|
5
5
|
|
6
|
-
it
|
6
|
+
it 'must show expressions' do
|
7
7
|
enter 'break 3', 'cont', 'display d + 1'
|
8
8
|
debug_file('display')
|
9
|
-
check_output_includes
|
9
|
+
check_output_includes '1: ', 'd + 1 = 5'
|
10
10
|
end
|
11
11
|
|
12
|
-
it
|
12
|
+
it 'must work with shortcut' do
|
13
13
|
enter 'break 3', 'cont', 'disp d + 1'
|
14
14
|
debug_file('display')
|
15
|
-
check_output_includes
|
15
|
+
check_output_includes '1: ', 'd + 1 = 5'
|
16
16
|
end
|
17
17
|
|
18
|
-
it
|
18
|
+
it 'must save displayed expressions' do
|
19
19
|
enter 'display d + 1'
|
20
|
-
debug_file('display') { state.display.must_equal [[true,
|
20
|
+
debug_file('display') { state.display.must_equal [[true, 'd + 1']] }
|
21
21
|
end
|
22
22
|
|
23
|
-
it
|
23
|
+
it 'displays all expressions available' do
|
24
24
|
enter 'break 3', 'cont', -> do
|
25
|
-
Byebug.handler.display.concat([[true,
|
25
|
+
Byebug.handler.display.concat([[true, 'abc'], [true, 'd']]); 'display'
|
26
26
|
end
|
27
27
|
debug_file('display')
|
28
|
-
check_output_includes
|
28
|
+
check_output_includes '1: ', 'abc = ', '2: ', 'd = 4'
|
29
29
|
end
|
30
30
|
|
31
|
-
describe
|
32
|
-
describe
|
31
|
+
describe 'undisplay' do
|
32
|
+
describe 'undisplay all' do
|
33
33
|
before do
|
34
34
|
enter 'break 3', 'cont', -> do
|
35
|
-
Byebug.handler.display.concat([[true,
|
35
|
+
Byebug.handler.display.concat([[true, 'abc'], [true, 'd']])
|
36
36
|
'undisplay'
|
37
37
|
end, confirm_response, 'display'
|
38
38
|
end
|
39
39
|
|
40
|
-
describe
|
40
|
+
describe 'confirmation is successful' do
|
41
41
|
let(:confirm_response) { 'y' }
|
42
42
|
|
43
|
-
it
|
43
|
+
it 'must ask about confirmation' do
|
44
44
|
debug_file('display')
|
45
|
-
check_output_includes
|
45
|
+
check_output_includes \
|
46
|
+
'Clear all expressions? (y/n)', interface.confirm_queue
|
46
47
|
end
|
47
48
|
|
48
|
-
it
|
49
|
-
debug_file('display') {
|
49
|
+
it 'must set all expressions saved to "false"' do
|
50
|
+
debug_file('display') {
|
51
|
+
state.display.must_equal [[false, 'abc'], [false, 'd']] }
|
50
52
|
end
|
51
53
|
|
52
|
-
it
|
54
|
+
it 'must not show any output' do
|
53
55
|
debug_file('display')
|
54
|
-
check_output_doesnt_include
|
56
|
+
check_output_doesnt_include '1: ', 'abc = ', '2: ', 'd = 4'
|
55
57
|
end
|
56
58
|
end
|
57
59
|
|
58
|
-
describe
|
60
|
+
describe 'confirmation is unsuccessful' do
|
59
61
|
let(:confirm_response) { 'n' }
|
60
62
|
|
61
|
-
it
|
62
|
-
debug_file('display') {
|
63
|
+
it 'must set all expressions saved to "false"' do
|
64
|
+
debug_file('display') {
|
65
|
+
state.display.must_equal [[true, 'abc'], [true, 'd']] }
|
63
66
|
end
|
64
67
|
|
65
|
-
it
|
68
|
+
it 'must not show any output' do
|
66
69
|
debug_file('display')
|
67
|
-
check_output_includes
|
70
|
+
check_output_includes '1: ', 'abc = ', '2: ', 'd = 4'
|
68
71
|
end
|
69
72
|
end
|
70
73
|
end
|
71
74
|
|
72
|
-
describe
|
75
|
+
describe 'undisplay specific position' do
|
73
76
|
before do
|
74
77
|
enter 'break 3', 'cont', -> do
|
75
|
-
Byebug.handler.display.concat([[true,
|
78
|
+
Byebug.handler.display.concat([[true, 'abc'], [true, 'd']])
|
76
79
|
'undisplay 1'
|
77
80
|
end, 'display'
|
78
81
|
end
|
79
82
|
|
80
|
-
it
|
81
|
-
debug_file('display') {
|
83
|
+
it 'must set inactive positions' do
|
84
|
+
debug_file('display') {
|
85
|
+
state.display.must_equal [[nil, 'abc'], [true, 'd']] }
|
82
86
|
end
|
83
87
|
|
84
|
-
it
|
88
|
+
it 'must display only the active position' do
|
85
89
|
debug_file('display')
|
86
|
-
check_output_includes
|
90
|
+
check_output_includes '2: ', 'd = 4'
|
87
91
|
end
|
88
92
|
|
89
|
-
it
|
93
|
+
it 'must not display the disabled position' do
|
90
94
|
debug_file('display')
|
91
|
-
check_output_doesnt_include
|
95
|
+
check_output_doesnt_include '1: ', 'abc'
|
92
96
|
end
|
93
97
|
end
|
94
98
|
end
|
95
99
|
|
96
|
-
describe
|
97
|
-
it
|
100
|
+
describe 'disable' do
|
101
|
+
it 'must disable a position' do
|
98
102
|
enter 'display d', 'disable display 1'
|
99
|
-
debug_file('display') { state.display.must_equal [[false,
|
103
|
+
debug_file('display') { state.display.must_equal [[false, 'd']] }
|
100
104
|
end
|
101
105
|
|
102
|
-
it
|
106
|
+
it 'must show an error if no displays are set' do
|
103
107
|
enter 'disable display 1'
|
104
108
|
debug_file('display')
|
105
|
-
check_output_includes
|
109
|
+
check_output_includes \
|
110
|
+
'No display expressions have been set.', interface.error_queue
|
106
111
|
end
|
107
112
|
|
108
|
-
it
|
113
|
+
it 'must show an error if there is no such display position' do
|
109
114
|
enter 'display d', 'disable display 4'
|
110
115
|
debug_file('display')
|
111
|
-
check_output_includes
|
116
|
+
check_output_includes \
|
117
|
+
'Disable display argument "4" needs to be at most 1.'
|
112
118
|
end
|
113
119
|
end
|
114
120
|
|
115
|
-
describe
|
116
|
-
it
|
121
|
+
describe 'enable' do
|
122
|
+
it 'must enable a position' do
|
117
123
|
enter 'display d', 'disable display 1', 'enable display 1'
|
118
|
-
debug_file('display') { state.display.must_equal [[true,
|
124
|
+
debug_file('display') { state.display.must_equal [[true, 'd']] }
|
119
125
|
end
|
120
126
|
end
|
121
127
|
|
122
|
-
describe
|
123
|
-
|
128
|
+
describe 'annotate' do
|
129
|
+
after { Byebug.annotate = 0 }
|
124
130
|
|
125
|
-
it
|
131
|
+
it 'must show display expression in annotation' do
|
126
132
|
enter 'display 2 + 2', 'set annotate 3', 'next', 'next'
|
127
133
|
debug_file 'display'
|
128
|
-
check_output_includes "\
|
134
|
+
check_output_includes "\u001A\u001Adisplay", '1:', '2 + 2 = 4'
|
129
135
|
end
|
130
136
|
end
|
131
137
|
|
132
|
-
describe
|
133
|
-
it
|
134
|
-
skip(
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
+
describe 'Post Mortem' do
|
139
|
+
it 'must be able to set display expressions in post-mortem mode' do
|
140
|
+
skip('No post morten mode for now')
|
141
|
+
enter 'cont', 'display 2 + 2', 'cont'
|
142
|
+
debug_file('post_mortem')
|
143
|
+
check_output_includes '1:', '2 + 2 = 4'
|
138
144
|
end
|
139
145
|
end
|
140
146
|
|
data/test/eval_test.rb
CHANGED
@@ -38,8 +38,6 @@ describe 'Eval Command' do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
describe 'stack trace on error' do
|
41
|
-
temporary_change_hash_value(Byebug::Command.settings, :stack_trace_on_error, false)
|
42
|
-
|
43
41
|
it 'must show a stack trace if showing trace on error is enabled' do
|
44
42
|
enter 'set notrace', 'eval 2 / 0'
|
45
43
|
debug_file 'eval'
|
data/test/examples/info.rb
CHANGED
data/test/finish_test.rb
CHANGED
@@ -1,47 +1,48 @@
|
|
1
1
|
require_relative 'test_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe 'Finish Command' do
|
4
4
|
include TestDsl
|
5
5
|
|
6
|
-
it
|
6
|
+
it 'must stop at the next frame by default' do
|
7
7
|
enter 'break 16', 'cont', 'finish'
|
8
8
|
debug_file('finish') { state.line.must_equal 13 }
|
9
9
|
end
|
10
10
|
|
11
|
-
it
|
11
|
+
it 'must stop at the #0 frame by default' do
|
12
12
|
enter 'break 16', 'cont', 'finish 0'
|
13
13
|
debug_file('finish') { state.line.must_equal 13 }
|
14
14
|
end
|
15
15
|
|
16
|
-
it
|
16
|
+
it 'must stop at the specified frame' do
|
17
17
|
enter 'break 16', 'cont', 'finish 1'
|
18
18
|
debug_file('finish') { state.line.must_equal 9 }
|
19
19
|
end
|
20
20
|
|
21
|
-
it
|
21
|
+
it 'must stop at the next frame if the current frame was changed' do
|
22
22
|
enter 'break 16', 'cont', 'up', 'finish'
|
23
23
|
debug_file('finish') { state.line.must_equal 9 }
|
24
24
|
end
|
25
25
|
|
26
|
-
describe
|
26
|
+
describe 'not a number is specified for frame' do
|
27
27
|
before { enter 'break 16', 'cont', 'finish foo' }
|
28
28
|
|
29
|
-
it
|
29
|
+
it 'must show an error' do
|
30
30
|
debug_file('finish')
|
31
|
-
check_output_includes
|
31
|
+
check_output_includes 'Finish argument "foo" needs to be a number.'
|
32
32
|
end
|
33
33
|
|
34
|
-
it
|
34
|
+
it 'must be on the same line' do
|
35
35
|
debug_file('finish') { state.line.must_equal 16 }
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
describe
|
40
|
-
it
|
41
|
-
skip(
|
42
|
-
|
43
|
-
|
44
|
-
|
39
|
+
describe 'Post Mortem' do
|
40
|
+
it 'must not work in post-mortem mode' do
|
41
|
+
skip('No post morten mode for now')
|
42
|
+
enter 'cont', 'finish'
|
43
|
+
debug_file 'post_mortem'
|
44
|
+
check_output_includes 'Unknown command: "finish". Try "help".',
|
45
|
+
interface.error_queue
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
data/test/info_test.rb
CHANGED
@@ -19,16 +19,16 @@ describe "Info Command" do
|
|
19
19
|
enter 'break 7', 'break 9 if a == b', 'info breakpoints'
|
20
20
|
debug_file 'info'
|
21
21
|
check_output_includes "Num Enb What",
|
22
|
-
/\d+ y at #{fullpath('info')}:7/,
|
23
|
-
/\d+ y at #{fullpath('info')}:9 if a == b/
|
22
|
+
/\d+ +y at #{fullpath('info')}:7/,
|
23
|
+
/\d+ +y at #{fullpath('info')}:9 if a == b/
|
24
24
|
end
|
25
25
|
|
26
26
|
it "must show info about specific breakpoint" do
|
27
27
|
enter 'break 7', 'break 9',
|
28
28
|
->{"info breakpoints #{Byebug.breakpoints.first.id}"}
|
29
29
|
debug_file 'info'
|
30
|
-
check_output_includes "Num Enb What", /\d+ y at #{fullpath('info')}:7/
|
31
|
-
check_output_doesnt_include /\d+ y at #{fullpath('info')}:9/
|
30
|
+
check_output_includes "Num Enb What", /\d+ +y at #{fullpath('info')}:7/
|
31
|
+
check_output_doesnt_include /\d+ +y at #{fullpath('info')}:9/
|
32
32
|
end
|
33
33
|
|
34
34
|
it "must show an error if no breakpoints are found" do
|
@@ -47,8 +47,8 @@ describe "Info Command" do
|
|
47
47
|
it "must show hit count" do
|
48
48
|
enter 'break 9', 'cont', 'info breakpoints'
|
49
49
|
debug_file 'info'
|
50
|
-
check_output_includes /\d+ y at #{fullpath('info')}:9/
|
51
|
-
check_output_includes /\d+ y at #{fullpath('info')}:9/,
|
50
|
+
check_output_includes /\d+ +y at #{fullpath('info')}:9/
|
51
|
+
check_output_includes /\d+ +y at #{fullpath('info')}:9/,
|
52
52
|
"breakpoint already hit 1 time"
|
53
53
|
end
|
54
54
|
end
|
@@ -243,14 +243,13 @@ describe "Info Command" do
|
|
243
243
|
|
244
244
|
describe "Thread info" do
|
245
245
|
it "must show threads info when without args" do
|
246
|
-
skip("XXX: Unreliable due to race conditions, needs fix to be reliable")
|
247
246
|
enter 'break 48', 'cont', 'info threads'
|
248
|
-
debug_file '
|
249
|
-
check_output_includes /#<Thread:\S+ run
|
247
|
+
debug_file 'info_threads'
|
248
|
+
check_output_includes /#<Thread:\S+ run>/
|
250
249
|
end
|
251
250
|
|
252
251
|
it "must show thread info" do
|
253
|
-
skip("
|
252
|
+
skip("XXX: Unreliable due to race conditions, needs fix to be reliable")
|
254
253
|
thread_number = nil
|
255
254
|
enter ->{thread_number = context.thnum; "info thread #{context.thnum}"}
|
256
255
|
debug_file 'info'
|
data/test/irb_test.rb
CHANGED
@@ -3,84 +3,83 @@ require_relative 'test_helper'
|
|
3
3
|
describe "Irb Command" do
|
4
4
|
include TestDsl
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
12
|
-
after do
|
13
|
-
Signal.trap("SIGINT", "DEFAULT")
|
14
|
-
end
|
15
|
-
let(:irb) { stub(context: ->{}) }
|
6
|
+
def after_setup
|
7
|
+
interface.stubs(:kind_of?).with(Byebug::LocalInterface).returns(true)
|
8
|
+
IRB::Irb.stubs(:new).returns(irb)
|
9
|
+
Signal.trap("SIGINT", "IGNORE")
|
10
|
+
end
|
16
11
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
debug_file('irb') { state.line.must_equal 3 }
|
21
|
-
end
|
12
|
+
def after_teardown
|
13
|
+
Signal.trap("SIGINT", "DEFAULT")
|
14
|
+
end
|
22
15
|
|
23
|
-
|
24
|
-
irb.stubs(:eval_input).throws(:IRB_EXIT, :step)
|
25
|
-
enter 'irb'
|
26
|
-
debug_file('irb') { state.line.must_equal 3 }
|
27
|
-
end
|
16
|
+
let(:irb) { stub(context: ->{}) }
|
28
17
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
18
|
+
it "must support next command" do
|
19
|
+
irb.stubs(:eval_input).throws(:IRB_EXIT, :next)
|
20
|
+
enter 'irb'
|
21
|
+
debug_file('irb') { state.line.must_equal 3 }
|
22
|
+
end
|
34
23
|
|
35
|
-
|
36
|
-
|
24
|
+
it "must support step command" do
|
25
|
+
irb.stubs(:eval_input).throws(:IRB_EXIT, :step)
|
26
|
+
enter 'irb'
|
27
|
+
debug_file('irb') { state.line.must_equal 3 }
|
28
|
+
end
|
37
29
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
end
|
30
|
+
it "must support cont command" do
|
31
|
+
irb.stubs(:eval_input).throws(:IRB_EXIT, :cont)
|
32
|
+
enter 'break 4', 'irb'
|
33
|
+
debug_file('irb') { state.line.must_equal 4 }
|
34
|
+
end
|
44
35
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
end
|
36
|
+
#describe "autoirb" do
|
37
|
+
# it "must call irb automatically after breakpoint" do
|
38
|
+
# irb.expects(:eval_input)
|
39
|
+
# enter 'set autoirb', 'break 4', 'cont'
|
40
|
+
# debug_file 'irb'
|
41
|
+
# end
|
42
|
+
#end
|
53
43
|
|
54
|
-
|
55
|
-
|
56
|
-
|
44
|
+
# TODO: Can't reliably test the signal, from time to time Signal.trap, which
|
45
|
+
# is defined in IRBCommand, misses the SIGINT signal, which makes the test
|
46
|
+
# suite exit. Not sure how to fix that...
|
47
|
+
it "must translate SIGINT into 'cont' command" do
|
48
|
+
irb.stubs(:eval_input).calls { Process.kill("SIGINT", Process.pid) }
|
49
|
+
enter 'break 4', 'irb'
|
50
|
+
debug_file('irb') { state.line.must_equal 4 }
|
51
|
+
end
|
57
52
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
byebug_state.must_be_kind_of Byebug::CommandProcessor::State
|
64
|
-
end
|
53
|
+
describe "setting context to $byebug_state" do
|
54
|
+
before do
|
55
|
+
$byebug_state = nil
|
56
|
+
Byebug::Command.settings[:byebugtesting] = false
|
57
|
+
end
|
65
58
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
end
|
59
|
+
it "must set $byebug_state if irb is in the debug mode" do
|
60
|
+
byebug_state = nil
|
61
|
+
irb.stubs(:eval_input).calls { byebug_state = $byebug_state }
|
62
|
+
enter 'irb -d'
|
63
|
+
debug_file('irb')
|
64
|
+
byebug_state.must_be_kind_of Byebug::CommandProcessor::State
|
73
65
|
end
|
74
66
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
end
|
67
|
+
it "must not set $byebug_state if irb is not in the debug mode" do
|
68
|
+
byebug_state = nil
|
69
|
+
irb.stubs(:eval_input).calls { byebug_state = $byebug_state }
|
70
|
+
enter 'irb'
|
71
|
+
debug_file('irb')
|
72
|
+
byebug_state.must_be_nil
|
82
73
|
end
|
74
|
+
end
|
83
75
|
|
76
|
+
describe "Post Mortem" do
|
77
|
+
it "must work in post-mortem mode" do
|
78
|
+
skip("No post morten mode for now")
|
79
|
+
irb.stubs(:eval_input).throws(:IRB_EXIT, :cont)
|
80
|
+
enter 'cont', 'break 12', 'irb'
|
81
|
+
debug_file("post_mortem") { state.line.must_equal 12 }
|
82
|
+
end
|
84
83
|
end
|
85
84
|
|
86
85
|
end
|