byebug 1.0.3 → 1.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.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/README.md +13 -11
  4. data/Rakefile +0 -6
  5. data/bin/byebug +83 -136
  6. data/ext/byebug/byebug.c +182 -96
  7. data/ext/byebug/byebug.h +5 -7
  8. data/ext/byebug/context.c +52 -40
  9. data/lib/byebug.rb +81 -81
  10. data/lib/byebug/command.rb +18 -35
  11. data/lib/byebug/commands/control.rb +1 -1
  12. data/lib/byebug/commands/display.rb +0 -2
  13. data/lib/byebug/commands/enable.rb +4 -16
  14. data/lib/byebug/commands/eval.rb +5 -3
  15. data/lib/byebug/commands/frame.rb +68 -69
  16. data/lib/byebug/commands/help.rb +2 -1
  17. data/lib/byebug/commands/info.rb +43 -42
  18. data/lib/byebug/commands/method.rb +4 -3
  19. data/lib/byebug/commands/set.rb +10 -19
  20. data/lib/byebug/commands/show.rb +6 -13
  21. data/lib/byebug/interface.rb +1 -1
  22. data/lib/byebug/processor.rb +14 -17
  23. data/lib/byebug/version.rb +1 -2
  24. data/old_doc/byebug.texi +576 -847
  25. data/test/breakpoints_test.rb +0 -1
  26. data/test/conditions_test.rb +35 -33
  27. data/test/display_test.rb +14 -13
  28. data/test/edit_test.rb +28 -25
  29. data/test/eval_test.rb +0 -2
  30. data/test/finish_test.rb +4 -3
  31. data/test/frame_test.rb +20 -21
  32. data/test/help_test.rb +26 -23
  33. data/test/info_test.rb +105 -108
  34. data/test/irb_test.rb +26 -25
  35. data/test/kill_test.rb +19 -19
  36. data/test/list_test.rb +140 -156
  37. data/test/method_test.rb +21 -22
  38. data/test/post_mortem_test.rb +2 -5
  39. data/test/quit_test.rb +16 -17
  40. data/test/reload_test.rb +2 -2
  41. data/test/restart_test.rb +0 -1
  42. data/test/save_test.rb +31 -32
  43. data/test/set_test.rb +50 -47
  44. data/test/show_test.rb +67 -66
  45. data/test/source_test.rb +31 -34
  46. data/test/stepping_test.rb +32 -34
  47. data/test/support/test_dsl.rb +1 -1
  48. data/test/trace_test.rb +1 -2
  49. data/test/variables_test.rb +36 -34
  50. metadata +2 -4
  51. data/lib/byebug/commands/tmate.rb +0 -36
  52. data/test/tmate_test.rb +0 -44
@@ -1,48 +1,48 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- describe "Kill Command" do
3
+ describe 'Kill Command' do
4
4
  include TestDsl
5
5
 
6
- it "must send signal to some pid" do
7
- Process.expects(:kill).with("USR1", Process.pid)
6
+ it 'must send signal to some pid' do
7
+ Process.expects(:kill).with('USR1', Process.pid)
8
8
  enter 'kill USR1'
9
9
  debug_file('kill')
10
10
  end
11
11
 
12
- it "must finalize interface when sending KILL signal explicitly" do
13
- Process.stubs(:kill).with("KILL", Process.pid)
12
+ it 'must finalize interface when sending KILL signal explicitly' do
13
+ Process.stubs(:kill).with('KILL', Process.pid)
14
14
  interface.expects(:finalize)
15
15
  enter 'kill KILL'
16
16
  debug_file('kill')
17
17
  end
18
18
 
19
- it "must ask confirmation when sending KILL implicitly" do
20
- Process.expects(:kill).with("KILL", Process.pid)
19
+ it 'must ask confirmation when sending KILL implicitly' do
20
+ Process.expects(:kill).with('KILL', Process.pid)
21
21
  enter 'kill', 'y'
22
22
  debug_file('kill')
23
- check_output_includes "Really kill? (y/n)", interface.confirm_queue
23
+ check_output_includes 'Really kill? (y/n)', interface.confirm_queue
24
24
  end
25
25
 
26
- describe "unknown signal" do
27
- it "must not send the signal" do
28
- Process.expects(:kill).with("BLA", Process.pid).never
26
+ describe 'unknown signal' do
27
+ it 'must not send the signal' do
28
+ Process.expects(:kill).with('BLA', Process.pid).never
29
29
  enter 'kill BLA'
30
30
  debug_file('kill')
31
31
  end
32
32
 
33
- it "must show an error" do
33
+ it 'must show an error' do
34
34
  enter 'kill BLA'
35
35
  debug_file('kill')
36
- check_output_includes "signal name BLA is not a signal I know about", interface.error_queue
36
+ check_output_includes \
37
+ 'signal name BLA is not a signal I know about', interface.error_queue
37
38
  end
38
39
  end
39
40
 
40
- describe "Post Mortem" do
41
- it "must work in post-mortem mode" do
42
- skip("No post morten mode for now")
43
- #Process.expects(:kill).with("USR1", Process.pid)
44
- #enter 'cont', 'kill USR1'
45
- #debug_file "post_mortem"
41
+ describe 'Post Mortem' do
42
+ it 'must work in post-mortem mode' do
43
+ Process.expects(:kill).with('USR1', Process.pid)
44
+ enter 'cont', 'kill USR1'
45
+ debug_file 'post_mortem'
46
46
  end
47
47
  end
48
48
  end
@@ -3,196 +3,180 @@ require_relative 'test_helper'
3
3
  describe 'List Command' do
4
4
  include TestDsl
5
5
 
6
- describe 'List Command (Setup)' do
7
-
8
- before { LineCache.clear_file_cache }
9
-
10
- describe 'listsize' do
11
- before do
12
- Byebug::Command.settings[:listsize] = 3
13
- Byebug::Command.settings[:autolist] = 0
14
- end
15
-
16
- it 'must show lines according to :listsize setting' do
17
- enter 'set listsize 4', 'break 5', 'cont', 'list'
18
- debug_file 'list'
19
- check_output_includes "[3, 6] in #{fullpath('list')}"
20
- end
21
-
22
- it 'must not set it if the param is not an integer' do
23
- enter 'set listsize 4.0', 'break 5', 'cont', 'list'
24
- debug_file 'list'
25
- check_output_includes "[4, 6] in #{fullpath('list')}"
26
- end
27
-
28
- it 'must move range up when it goes before begining of file' do
29
- enter 'set listsize 10', 'break 3', 'cont', 'list'
30
- debug_file 'list'
31
- check_output_includes "[1, 10] in #{fullpath('list')}"
32
- end
33
-
34
- it 'must move range down when it goes after end of file' do
35
- enter 'set listsize 10', 'break 10', 'cont', 'list'
36
- debug_file 'list'
37
- check_output_includes "[3, 12] in #{fullpath('list')}"
38
- end
39
-
40
- it 'must list whole file if number of lines is smaller than listsize' do
41
- enter 'set listsize 13', 'list'
42
- debug_file 'list'
43
- check_output_includes "[1, 12] in #{fullpath('list')}"
44
- end
6
+ def after_setup
7
+ LineCache.clear_file_cache
8
+ Byebug::Command.settings[:listsize] = 3
9
+ Byebug::Command.settings[:autolist] = 0
10
+ end
45
11
 
12
+ describe 'listsize' do
13
+ it 'must show lines according to :listsize setting' do
14
+ enter 'set listsize 4', 'break 5', 'cont', 'list'
15
+ debug_file 'list'
16
+ check_output_includes "[3, 6] in #{fullpath('list')}"
46
17
  end
47
18
 
48
- describe 'without arguments' do
49
- before { Byebug::Command.settings[:listsize] = 3 }
50
-
51
- it 'must show surrounding lines with the first call' do
52
- enter 'break 5', 'cont', 'list'
53
- debug_file 'list'
54
- check_output_includes \
55
- "[4, 6] in #{fullpath('list')}", '4 4', '=> 5 5', '6 6'
56
- end
57
-
58
- it 'must list forward after second call' do
59
- enter 'break 5', 'cont', 'list', 'list'
60
- debug_file 'list'
61
- check_output_includes \
62
- "[7, 9] in #{fullpath('list')}", '7 7', '8 8', '9 9'
63
- end
19
+ it 'must not set it if the param is not an integer' do
20
+ enter 'set listsize 4.0', 'break 5', 'cont', 'list'
21
+ debug_file 'list'
22
+ check_output_includes "[4, 6] in #{fullpath('list')}"
64
23
  end
65
24
 
66
- describe 'list backward' do
67
- before { Byebug::Command.settings[:listsize] = 3 }
25
+ it 'must move range up when it goes before begining of file' do
26
+ enter 'set listsize 10', 'break 3', 'cont', 'list'
27
+ debug_file 'list'
28
+ check_output_includes "[1, 10] in #{fullpath('list')}"
29
+ end
68
30
 
69
- it 'must show surrounding lines with the first call' do
70
- enter 'break 5', 'cont', 'list -'
71
- debug_file 'list'
72
- check_output_includes \
73
- "[4, 6] in #{fullpath('list')}", '4 4', '=> 5 5', '6 6'
74
- end
31
+ it 'must move range down when it goes after end of file' do
32
+ enter 'set listsize 10', 'break 10', 'cont', 'list'
33
+ debug_file 'list'
34
+ check_output_includes "[3, 12] in #{fullpath('list')}"
35
+ end
75
36
 
76
- it 'must list backward after second call' do
77
- enter 'break 5', 'cont', 'list -', 'list -'
78
- debug_file 'list'
79
- check_output_includes \
80
- "[1, 3] in #{fullpath('list')}", '1 byebug', '2 2', '3 3'
81
- end
37
+ it 'must list whole file if number of lines is smaller than listsize' do
38
+ enter 'set listsize 13', 'list'
39
+ debug_file 'list'
40
+ check_output_includes "[1, 12] in #{fullpath('list')}"
82
41
  end
83
42
 
43
+ end
84
44
 
85
- describe 'list surrounding' do
86
- before { Byebug::Command.settings[:listsize] = 3 }
45
+ describe 'without arguments' do
46
+ it 'must show surrounding lines with the first call' do
47
+ enter 'break 5', 'cont', 'list'
48
+ debug_file 'list'
49
+ check_output_includes \
50
+ "[4, 6] in #{fullpath('list')}", '4 4', '=> 5 5', '6 6'
51
+ end
87
52
 
88
- it 'must show the surrounding lines with =' do
89
- enter 'break 5', 'cont', 'list ='
90
- debug_file 'list'
91
- check_output_includes \
92
- "[4, 6] in #{fullpath('list')}", '4 4', '=> 5 5', '6 6'
93
- end
53
+ it 'must list forward after second call' do
54
+ enter 'break 5', 'cont', 'list', 'list'
55
+ debug_file 'list'
56
+ check_output_includes \
57
+ "[7, 9] in #{fullpath('list')}", '7 7', '8 8', '9 9'
94
58
  end
59
+ end
95
60
 
96
- describe 'autolist' do
97
- before { Byebug::Command.settings[:listsize] = 3 }
61
+ describe 'list backward' do
62
+ it 'must show surrounding lines with the first call' do
63
+ enter 'break 5', 'cont', 'list -'
64
+ debug_file 'list'
65
+ check_output_includes \
66
+ "[4, 6] in #{fullpath('list')}", '4 4', '=> 5 5', '6 6'
67
+ end
98
68
 
99
- it 'must show the surronding lines after stop if autolist is enabled' do
100
- enter 'set autolist', 'break 5', 'cont'
101
- debug_file 'list'
102
- check_output_includes \
103
- "[4, 6] in #{fullpath('list')}", '4 4', '=> 5 5', '6 6'
104
- end
69
+ it 'must list backward after second call' do
70
+ enter 'break 5', 'cont', 'list -', 'list -'
71
+ debug_file 'list'
72
+ check_output_includes \
73
+ "[1, 3] in #{fullpath('list')}", '1 byebug', '2 2', '3 3'
105
74
  end
75
+ end
106
76
 
107
- describe 'specified lines' do
108
- before { Byebug::Command.settings[:listsize] = 3 }
109
77
 
110
- it 'must show with mm-nn' do
111
- enter 'list 4-6'
112
- debug_file 'list'
113
- check_output_includes \
114
- "[4, 6] in #{fullpath('list')}", '4 4', '5 5', '6 6'
115
- end
78
+ describe 'list surrounding' do
79
+ it 'must show the surrounding lines with =' do
80
+ enter 'break 5', 'cont', 'list ='
81
+ debug_file 'list'
82
+ check_output_includes \
83
+ "[4, 6] in #{fullpath('list')}", '4 4', '=> 5 5', '6 6'
84
+ end
85
+ end
116
86
 
117
- it 'must show with mm,nn' do
118
- enter 'list 4,6'
119
- debug_file 'list'
120
- check_output_includes \
121
- "[4, 6] in #{fullpath('list')}", '4 4', '5 5', '6 6'
122
- end
87
+ describe 'autolist' do
88
+ it 'must show the surronding lines after stop if autolist is enabled' do
89
+ enter 'set autolist', 'break 5', 'cont'
90
+ debug_file 'list'
91
+ check_output_includes \
92
+ "[4, 6] in #{fullpath('list')}", '4 4', '=> 5 5', '6 6'
93
+ end
94
+ end
123
95
 
124
- it 'must show surroundings with mm-' do
125
- enter 'list 4-'
126
- debug_file 'list'
127
- check_output_includes \
128
- "[3, 5] in #{fullpath('list')}", '3 3', '4 4', '5 5'
129
- end
96
+ describe 'specified lines' do
97
+ it 'must show with mm-nn' do
98
+ enter 'list 4-6'
99
+ debug_file 'list'
100
+ check_output_includes \
101
+ "[4, 6] in #{fullpath('list')}", '4 4', '5 5', '6 6'
102
+ end
130
103
 
131
- it 'must show surroundings with mm,' do
132
- enter 'list 4,'
133
- debug_file 'list'
134
- check_output_includes \
135
- "[3, 5] in #{fullpath('list')}", '3 3', '4 4', '5 5'
136
- end
104
+ it 'must show with mm,nn' do
105
+ enter 'list 4,6'
106
+ debug_file 'list'
107
+ check_output_includes \
108
+ "[4, 6] in #{fullpath('list')}", '4 4', '5 5', '6 6'
109
+ end
137
110
 
138
- it 'must show nothing if there is no such lines' do
139
- enter 'list 44,44'
140
- debug_file 'list'
141
- check_error_includes 'Invalid line range'
142
- check_output_doesnt_include "[44, 44] in #{fullpath('list')}"
143
- check_output_doesnt_include /^44 \S/
144
- end
111
+ it 'must show surroundings with mm-' do
112
+ enter 'list 4-'
113
+ debug_file 'list'
114
+ check_output_includes \
115
+ "[3, 5] in #{fullpath('list')}", '3 3', '4 4', '5 5'
116
+ end
145
117
 
146
- it 'must show nothing if range is incorrect' do
147
- enter 'list 5,4'
148
- debug_file 'list'
149
- check_output_includes "[5, 4] in #{fullpath('list')}"
150
- check_output_doesnt_include '5 5'
151
- check_output_doesnt_include '4 4'
152
- end
118
+ it 'must show surroundings with mm,' do
119
+ enter 'list 4,'
120
+ debug_file 'list'
121
+ check_output_includes \
122
+ "[3, 5] in #{fullpath('list')}", '3 3', '4 4', '5 5'
153
123
  end
154
124
 
155
- describe 'reload source' do
156
- after do
157
- change_line_in_file(fullpath('list'), 4, '4')
158
- Byebug::Command.settings[:reload_source_on_change] = true
159
- end
125
+ it 'must show nothing if there is no such lines' do
126
+ enter 'list 44,44'
127
+ debug_file 'list'
128
+ check_error_includes 'Invalid line range'
129
+ check_output_doesnt_include "[44, 44] in #{fullpath('list')}"
130
+ check_output_doesnt_include /^44 \S/
131
+ end
160
132
 
161
- it 'must not reload if setting is false' do
162
- enter 'set noautoreload', -> do
163
- change_line_in_file(fullpath('list'), 4, '100')
164
- 'list 4-4'
165
- end
166
- debug_file 'list'
167
- check_output_includes '4 4'
168
- end
133
+ it 'must show nothing if range is incorrect' do
134
+ enter 'list 5,4'
135
+ debug_file 'list'
136
+ check_output_includes "[5, 4] in #{fullpath('list')}"
137
+ check_output_doesnt_include '5 5'
138
+ check_output_doesnt_include '4 4'
139
+ end
140
+ end
169
141
 
170
- it 'must reload if setting is true' do
171
- enter 'set autoreload', -> do
172
- change_line_in_file(fullpath('list'), 4, '100')
173
- 'list 4-4'
174
- end
175
- debug_file 'list'
176
- check_output_includes '4 100'
177
- end
142
+ describe 'reload source' do
143
+ after do
144
+ change_line_in_file(fullpath('list'), 4, '4')
145
+ Byebug::Command.settings[:reload_source_on_change] = true
178
146
  end
179
147
 
180
- it 'must show an error when there is no such file' do
181
- enter ->{state.file = 'blabla'; 'list 4-4'}
148
+ it 'must not reload if setting is false' do
149
+ enter 'set noautoreload', -> do
150
+ change_line_in_file(fullpath('list'), 4, '100')
151
+ 'list 4-4'
152
+ end
182
153
  debug_file 'list'
183
- check_output_includes 'No sourcefile available for blabla',
184
- interface.error_queue
154
+ check_output_includes '4 4'
185
155
  end
186
156
 
187
- describe 'Post Mortem' do
188
- it 'must work in post-mortem mode' do
189
- skip('No post morten mode for now')
190
- enter 'cont', 'list'
191
- debug_file 'post_mortem'
192
- check_output_includes "[7, 9] in #{fullpath('post_mortem')}"
157
+ it 'must reload if setting is true' do
158
+ enter 'set autoreload', -> do
159
+ change_line_in_file(fullpath('list'), 4, '100')
160
+ 'list 4-4'
193
161
  end
162
+ debug_file 'list'
163
+ check_output_includes '4 100'
194
164
  end
165
+ end
166
+
167
+ it 'must show an error when there is no such file' do
168
+ enter ->{state.file = 'blabla'; 'list 4-4'}
169
+ debug_file 'list'
170
+ check_output_includes 'No sourcefile available for blabla',
171
+ interface.error_queue
172
+ end
195
173
 
174
+ describe 'Post Mortem' do
175
+ it 'must work in post-mortem mode' do
176
+ enter 'cont', 'list'
177
+ debug_file 'post_mortem'
178
+ check_output_includes "[7, 9] in #{fullpath('post_mortem')}"
179
+ end
196
180
  end
197
181
 
198
182
  end
@@ -1,71 +1,70 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- describe "Method Command" do
3
+ describe 'Method Command' do
4
4
  include TestDsl
5
5
 
6
- # TODO: Need to write tests for 'method signature' command, but I can't
7
- # install the 'ruby-internal' gem on my machine, it fails to build gem native
8
- # extension.
9
-
10
6
  def after_setup
11
7
  Byebug::Command.settings[:autolist] = 0
12
8
  end
13
9
 
14
- describe "show instance method of a class" do
15
- it "must show using full command name" do
16
- enter 'break 15', 'cont', 'm MethodEx'
10
+ describe 'show instance method of a class' do
11
+ it 'must show using full command name' do
12
+ enter 'break 15', 'cont', 'method MethodEx'
17
13
  debug_file 'method'
18
14
  check_output_includes /bla/
19
15
  check_output_doesnt_include /foo/
20
16
  end
21
17
 
22
- it "must show using shortcut" do
23
- enter 'break 15', 'cont', 'method MethodEx'
18
+ it 'must show using shortcut' do
19
+ enter 'break 15', 'cont', 'm MethodEx'
24
20
  debug_file 'method'
25
21
  check_output_includes /bla/
26
22
  end
27
23
 
28
- it "must show an error if specified object is not a class or module" do
24
+ it 'must show an error if specified object is not a class or module' do
29
25
  enter 'break 15', 'cont', 'm a'
30
26
  debug_file 'method'
31
- check_output_includes "Should be Class/Module: a"
27
+ check_output_includes 'Should be Class/Module: a'
32
28
  end
33
29
  end
34
30
 
35
-
36
- describe "show methods of an object" do
37
- it "must show using full command name" do
31
+ describe 'show methods of an object' do
32
+ it 'must show using full command name' do
38
33
  enter 'break 15', 'cont', 'method instance a'
39
34
  debug_file 'method'
40
35
  check_output_includes /bla/
41
36
  check_output_doesnt_include /foo/
42
37
  end
43
38
 
44
- it "must show using shortcut" do
39
+ it 'must show using shortcut' do
45
40
  enter 'break 15', 'cont', 'm i a'
46
41
  debug_file 'method'
47
42
  check_output_includes /bla/
48
43
  end
49
44
  end
50
45
 
46
+ describe 'show signature of a method' do
47
+ it 'must work' do
48
+ skip('TODO, can\'t install ruby-internal gem')
49
+ end
50
+ end
51
51
 
52
- describe "show instance variables of an object" do
53
- it "must show using full name command" do
52
+ describe 'show instance variables of an object' do
53
+ it 'must show using full name command' do
54
54
  enter 'break 15', 'cont', 'method iv a'
55
55
  debug_file 'method'
56
56
  check_output_includes '@a = "b"', '@c = "d"'
57
57
  end
58
58
 
59
- it "must show using shortcut" do
59
+ it 'must show using shortcut' do
60
60
  enter 'break 15', 'cont', 'm iv a'
61
61
  debug_file 'method'
62
62
  check_output_includes '@a = "b"', '@c = "d"'
63
63
  end
64
64
  end
65
65
 
66
- describe "Post Mortem" do
67
- it "must work in post-mortem mode" do
68
- skip("No post morten mode for now")
66
+ describe 'Post Mortem' do
67
+ it 'must work in post-mortem mode' do
69
68
  enter 'cont', 'm i self'
70
69
  debug_file 'post_mortem'
71
70
  check_output_includes /to_s/