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