byebug 2.7.0 → 3.0.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 (56) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -6
  3. data/.travis.yml +1 -0
  4. data/CHANGELOG.md +23 -0
  5. data/Gemfile +9 -0
  6. data/README.md +35 -32
  7. data/Rakefile +1 -3
  8. data/byebug.gemspec +0 -6
  9. data/ext/byebug/byebug.c +64 -51
  10. data/ext/byebug/byebug.h +12 -13
  11. data/ext/byebug/context.c +28 -43
  12. data/ext/byebug/extconf.rb +6 -6
  13. data/lib/byebug.rb +34 -38
  14. data/lib/byebug/command.rb +4 -2
  15. data/lib/byebug/commands/continue.rb +0 -1
  16. data/lib/byebug/commands/control.rb +0 -1
  17. data/lib/byebug/commands/edit.rb +1 -1
  18. data/lib/byebug/commands/finish.rb +10 -16
  19. data/lib/byebug/commands/help.rb +1 -1
  20. data/lib/byebug/commands/kill.rb +1 -1
  21. data/lib/byebug/commands/quit.rb +1 -1
  22. data/lib/byebug/commands/repl.rb +3 -3
  23. data/lib/byebug/commands/set.rb +24 -39
  24. data/lib/byebug/commands/show.rb +39 -112
  25. data/lib/byebug/commands/stepping.rb +0 -2
  26. data/lib/byebug/commands/threads.rb +0 -5
  27. data/lib/byebug/commands/trace.rb +1 -1
  28. data/lib/byebug/commands/variables.rb +1 -1
  29. data/lib/byebug/context.rb +8 -12
  30. data/lib/byebug/helper.rb +1 -1
  31. data/lib/byebug/history.rb +46 -0
  32. data/lib/byebug/interface.rb +5 -5
  33. data/lib/byebug/interfaces/local_interface.rb +11 -62
  34. data/lib/byebug/interfaces/remote_interface.rb +6 -22
  35. data/lib/byebug/interfaces/script_interface.rb +2 -17
  36. data/lib/byebug/processor.rb +4 -4
  37. data/lib/byebug/{command_processor.rb → processors/command_processor.rb} +7 -14
  38. data/lib/byebug/{control_command_processor.rb → processors/control_command_processor.rb} +3 -7
  39. data/lib/byebug/version.rb +1 -1
  40. data/test/edit_test.rb +6 -6
  41. data/test/examples/breakpoint_deep.rb +1 -1
  42. data/test/finish_test.rb +6 -6
  43. data/test/help_test.rb +1 -1
  44. data/test/info_test.rb +0 -1
  45. data/test/kill_test.rb +2 -2
  46. data/test/post_mortem_test.rb +35 -219
  47. data/test/quit_test.rb +2 -2
  48. data/test/restart_test.rb +12 -33
  49. data/test/set_test.rb +80 -107
  50. data/test/show_test.rb +42 -77
  51. data/test/stepping_test.rb +1 -1
  52. data/test/support/test_dsl.rb +4 -25
  53. data/test/support/test_interface.rb +40 -48
  54. data/test/test_helper.rb +1 -3
  55. data/test/timeout_test.rb +9 -0
  56. metadata +8 -75
@@ -27,9 +27,9 @@ class TestQuit < TestDsl::TestCase
27
27
  check_output_doesnt_include 'Really quit? (y/n)', interface.confirm_queue
28
28
  end
29
29
 
30
- it 'must finalize interface before quitting' do
30
+ it 'must close interface before quitting' do
31
31
  Byebug::QuitCommand.any_instance.stubs(:exit!)
32
- interface.expects(:finalize)
32
+ interface.expects(:close)
33
33
  enter 'quit!'
34
34
  debug_file 'quit'
35
35
  end
@@ -60,47 +60,26 @@ class TestRestart < TestDsl::TestCase
60
60
  describe 'no script specified' do
61
61
  temporary_change_const Byebug, 'PROG_SCRIPT', :__undefined__
62
62
 
63
- describe 'and no $0 used' do
64
- temporary_change_const Byebug, 'DEFAULT_START_SETTINGS',
65
- { init: false, post_mortem: false, tracing: nil }
66
-
67
- it 'must not restart and show error messages instead' do
68
- must_restart.never
69
- debug_file 'restart'
70
- check_output_includes 'Don\'t know name of debugged program',
71
- interface.error_queue
72
- end
73
- end
74
-
75
- describe 'but initialized from $0' do
76
- it 'must use prog_script from $0' do
77
- old_prog_name = $0
78
- $0 = 'prog-0'
79
- debug_file 'restart'
80
- check_output_includes 'Ruby program prog-0 doesn\'t exist',
63
+ it 'must not restart and show error messages instead' do
64
+ must_restart.never
65
+ debug_file 'restart'
66
+ check_output_includes 'Don\'t know name of debugged program',
81
67
  interface.error_queue
82
- $0 = old_prog_name
83
- end
84
68
  end
85
69
  end
86
70
 
87
71
  describe 'no script at the specified path' do
88
72
  temporary_change_const Byebug, 'PROG_SCRIPT', 'blabla'
89
73
 
90
- describe 'and no restart params set' do
91
- temporary_change_const Byebug, 'DEFAULT_START_SETTINGS',
92
- init: false, post_mortem: false, tracing: nil
93
-
94
- it 'must not restart' do
95
- must_restart.never
96
- debug_file 'restart'
97
- end
74
+ it 'must not restart' do
75
+ must_restart.never
76
+ debug_file 'restart'
77
+ end
98
78
 
99
- it 'must show an error message' do
100
- debug_file 'restart'
101
- check_output_includes 'Ruby program blabla doesn\'t exist',
102
- interface.error_queue
103
- end
79
+ it 'must show an error message' do
80
+ debug_file 'restart'
81
+ check_output_includes 'Ruby program blabla doesn\'t exist',
82
+ interface.error_queue
104
83
  end
105
84
  end
106
85
 
@@ -1,58 +1,64 @@
1
1
  class TestSet < TestDsl::TestCase
2
2
 
3
- describe 'setting to on' do
4
- temporary_change_hash Byebug.settings, :autolist, 0
3
+ [:autoeval, :autoreload, :autosave, :basename, :forcestep, :fullpath,
4
+ :linetrace_plus, :stack_on_error].each do |setting|
5
5
 
6
- it 'must set a setting to on' do
7
- enter 'set autolist on'
8
- debug_file 'set'
9
- Byebug.settings[:autolist].must_equal 1
10
- end
6
+ describe "setting #{setting} to on" do
7
+ temporary_change_hash Byebug.settings, setting, false
11
8
 
12
- it 'must set a setting to on by 1' do
13
- enter 'set autolist 1'
14
- debug_file 'set'
15
- Byebug.settings[:autolist].must_equal 1
16
- end
9
+ it "must set #{setting} to on using on" do
10
+ enter "set #{setting} on"
11
+ debug_file 'set'
12
+ Byebug.settings[setting].must_equal true
13
+ end
17
14
 
18
- it 'must set a setting to on by default' do
19
- enter 'set autolist'
20
- debug_file 'set'
21
- Byebug.settings[:autolist].must_equal 1
22
- end
15
+ it "must set #{setting} to on using 1" do
16
+ enter "set #{setting} 1"
17
+ debug_file 'set'
18
+ Byebug.settings[setting].must_equal true
19
+ end
23
20
 
24
- it 'must set a setting using shortcut' do
25
- enter 'set autol'
26
- debug_file 'set'
27
- Byebug.settings[:autolist].must_equal 1
21
+ it "must set #{setting} to on by default" do
22
+ enter "set #{setting}"
23
+ debug_file 'set'
24
+ Byebug.settings[setting].must_equal true
25
+ end
26
+
27
+ it "must set #{setting} using shortcut" do
28
+ skip 'it for now until I make it work'
29
+ enter "set autol"
30
+ debug_file 'set'
31
+ Byebug.settings[setting].must_equal 1
32
+ end
28
33
  end
29
- end
30
34
 
31
- describe 'setting to off' do
32
- temporary_change_hash Byebug.settings, :autolist, 1
35
+ describe "setting #{setting} to off" do
36
+ temporary_change_hash Byebug.settings, setting, true
33
37
 
34
- it 'must set a setting to off' do
35
- enter 'set autolist off'
36
- debug_file 'set'
37
- Byebug.settings[:autolist].must_equal 0
38
- end
38
+ it "must set #{setting} to off using off" do
39
+ enter "set #{setting} off"
40
+ debug_file 'set'
41
+ Byebug.settings[setting].must_equal false
42
+ end
39
43
 
40
- it 'must set a setting to off by 0' do
41
- enter 'set autolist 0'
42
- debug_file 'set'
43
- Byebug.settings[:autolist].must_equal 0
44
- end
44
+ it "must set #{setting} to on using 0" do
45
+ enter "set #{setting} 0"
46
+ debug_file 'set'
47
+ Byebug.settings[setting].must_equal false
48
+ end
45
49
 
46
- it 'must set a setting to off by "no" prefix' do
47
- enter 'set noautolist'
48
- debug_file 'set'
49
- Byebug.settings[:autolist].must_equal 0
50
- end
50
+ it "must set #{setting} to off using 'no' prefix" do
51
+ enter "set no#{setting}"
52
+ debug_file 'set'
53
+ Byebug.settings[setting].must_equal false
54
+ end
51
55
 
52
- it 'must set a setting to off by "no" prefix and shortcut' do
53
- enter 'set noautol'
54
- debug_file 'set'
55
- Byebug.settings[:autolist].must_equal 0
56
+ it "must set #{setting} off using 'no' prefix and shortcut" do
57
+ skip 'it for now until I make it work'
58
+ enter 'set noautol'
59
+ debug_file 'set'
60
+ Byebug.settings[setting].must_equal 0
61
+ end
56
62
  end
57
63
  end
58
64
 
@@ -89,82 +95,49 @@ class TestSet < TestDsl::TestCase
89
95
  end
90
96
  end
91
97
 
92
- describe 'history' do
93
- describe 'save' do
94
- it 'must set history save to on' do
95
- enter 'set history save on'
96
- debug_file 'set'
97
- interface.history_save.must_equal true
98
- end
99
-
100
- it 'must set history save to on when no param' do
101
- enter 'set history save'
102
- debug_file 'set'
103
- interface.history_save.must_equal true
104
- end
105
-
106
- it 'must show a message' do
107
- enter 'set history save on'
108
- debug_file 'set'
109
- check_output_includes 'Saving of history save is on.'
110
- end
98
+ describe 'histsize' do
99
+ after { Byebug::History.max_size = Byebug::History::DEFAULT_MAX_SIZE }
111
100
 
112
- it 'must set history save to off' do
113
- enter 'set history save off'
114
- debug_file 'set'
115
- interface.history_save.must_equal false
116
- end
101
+ it 'must set maximum history size' do
102
+ enter 'set histsize 250'
103
+ debug_file 'set'
104
+ Byebug::History.max_size.must_equal 250
117
105
  end
118
106
 
119
- describe 'size' do
120
- it 'must set history size' do
121
- enter 'set history size 250'
122
- debug_file 'set'
123
- interface.history_length.must_equal 250
124
- end
125
-
126
- it 'must show a message' do
127
- enter 'set history size 250'
128
- debug_file 'set'
129
- check_output_includes 'Byebug history size is 250'
130
- end
131
-
132
- it 'must show an error message if no size provided' do
133
- enter 'set history size'
134
- debug_file 'set'
135
- check_output_includes 'You need to specify the history size'
136
- end
107
+ it 'must show a message' do
108
+ enter 'set histsize 250'
109
+ debug_file 'set'
110
+ check_output_includes "Byebug history's maximum size is 250"
137
111
  end
138
112
 
139
- describe 'filename' do
140
- let(:filename) {
141
- File.join(ENV['HOME']||ENV['HOMEPATH']||'.', '.byebug-hist') }
113
+ it 'must show an error message if no size provided' do
114
+ enter 'set histsize'
115
+ debug_file 'set'
116
+ check_output_includes 'You need to specify the history size'
117
+ end
118
+ end
142
119
 
143
- it 'must set history filename' do
144
- enter 'set history filename .byebug-hist'
145
- debug_file 'set'
146
- interface.histfile.must_equal filename
147
- end
120
+ describe 'histfile' do
121
+ let(:filename) { File.expand_path('./.custom-byebug-hist') }
148
122
 
149
- it 'must show a message' do
150
- enter 'set history filename .byebug-hist'
151
- debug_file 'set'
152
- check_output_includes "The command history file is \"#{filename}\""
153
- end
123
+ after { Byebug::History.file = Byebug::History::DEFAULT_FILE }
154
124
 
155
- it 'must show an error message if no filenmae provided' do
156
- enter 'set history filename'
157
- debug_file 'set'
158
- check_output_includes 'You need to specify a filename'
159
- end
125
+ it 'must set history filename' do
126
+ enter "set histfile #{filename}"
127
+ debug_file 'set'
128
+ Byebug::History.file.must_equal filename
129
+ end
160
130
 
131
+ it 'must show a message' do
132
+ enter "set histfile #{filename}"
133
+ debug_file 'set'
134
+ check_output_includes "The command history file is \"#{filename}\""
161
135
  end
162
136
 
163
- it 'must show an error message if used wrong subcommand' do
164
- enter 'set history bla 2'
137
+ it 'must show an error message if no filename provided' do
138
+ enter 'set histfile'
165
139
  debug_file 'set'
166
- check_output_includes \
167
- 'Invalid history parameter bla. Should be "filename", "save" or "size"'
140
+ check_output_includes 'You need to specify a filename'
168
141
  end
169
142
  end
170
143
 
@@ -48,7 +48,7 @@ class TestShow < TestDsl::TestCase
48
48
  end
49
49
 
50
50
  describe 'autoirb' do
51
- before { Byebug::IRBCommand.any_instance.stubs(:execute) }
51
+ before { Byebug::IrbCommand.any_instance.stubs(:execute) }
52
52
 
53
53
  it 'must show default value' do
54
54
  enter 'show autoirb'
@@ -135,7 +135,7 @@ class TestShow < TestDsl::TestCase
135
135
  it 'must show default width' do
136
136
  enter 'show width'
137
137
  debug_file 'show'
138
- check_output_includes "width is #{cols}."
138
+ check_output_includes "Width is #{cols}."
139
139
  end
140
140
  end
141
141
 
@@ -147,109 +147,74 @@ class TestShow < TestDsl::TestCase
147
147
  end
148
148
  end
149
149
 
150
- describe 'history' do
151
- describe 'without arguments' do
152
- before do
153
- interface.histfile = 'hist_file.txt'
154
- interface.history_save = true
155
- interface.history_length = 25
156
- enter 'show history'
157
- debug_file 'show'
158
- end
159
-
160
- it 'must show history file' do
161
- check_output_includes(
162
- /filename: The command history file is "hist_file\.txt"/)
163
- end
150
+ describe 'autosave' do
151
+ it 'must show default value' do
152
+ enter 'show autosave'
153
+ debug_file 'show'
154
+ check_output_includes 'Saving history is on.'
155
+ end
156
+ end
164
157
 
165
- it 'must show history save setting' do
166
- check_output_includes(/save: Saving of history save is on\./)
167
- end
158
+ describe 'histfile' do
159
+ before { @filename = Byebug::History::DEFAULT_FILE }
168
160
 
169
- it 'must show history length' do
170
- check_output_includes(/size: Byebug history size is 25/)
171
- end
161
+ it 'must show history filename' do
162
+ enter 'show histfile'
163
+ debug_file 'show'
164
+ check_output_includes "The command history file is \"#{@filename}\""
172
165
  end
166
+ end
173
167
 
174
- describe 'with "filename" argument' do
175
- it 'must show history filename' do
176
- interface.histfile = 'hist_file.txt'
177
- enter 'show history filename'
178
- debug_file 'show'
179
- check_output_includes 'The command history file is "hist_file.txt"'
180
- end
181
-
182
- it 'must show history save setting' do
183
- interface.history_save = true
184
- enter 'show history save'
185
- debug_file 'show'
186
- check_output_includes 'Saving of history save is on.'
187
- end
168
+ describe 'histsize' do
169
+ before { @max_size = Byebug::History::DEFAULT_MAX_SIZE }
188
170
 
189
- it 'must show history length' do
190
- interface.history_length = 30
191
- enter 'show history size'
192
- debug_file 'show'
193
- check_output_includes 'Byebug history size is 30'
194
- end
171
+ it "must show history's max size" do
172
+ enter 'show histsize'
173
+ debug_file 'show'
174
+ check_output_includes "Byebug history's maximum size is #{@max_size}"
195
175
  end
196
176
  end
197
177
 
198
178
  describe 'commands' do
199
- describe 'no readline support' do
200
- before { interface.readline_support = false }
179
+ temporary_change_const Readline, 'HISTORY', %w(aaa bbb ccc ddd)
180
+
181
+ describe 'with history disabled' do
182
+ temporary_change_hash Byebug.settings, :autosave, false
201
183
 
202
184
  it 'must not show records from readline' do
203
185
  enter 'show commands'
204
186
  debug_file 'show'
205
- check_output_includes 'No readline support'
187
+ check_output_includes "Not currently saving history. " \
188
+ 'Enable it with "set autosave"'
206
189
  end
207
190
  end
208
191
 
209
- describe 'readline support' do
210
- before { interface.readline_support = true }
192
+ describe 'with history enabled' do
193
+ temporary_change_hash Byebug.settings, :autosave, true
211
194
 
212
195
  describe 'show records' do
213
- temporary_change_const Readline, 'HISTORY', %w{aaa bbb ccc ddd eee fff}
214
-
215
- it 'must show records from readline history' do
216
- enter 'show commands'
196
+ it 'displays last max_size records from readline history' do
197
+ enter 'set histsize 3', 'show commands'
217
198
  debug_file 'show'
218
- check_output_includes(/1 aaa/)
219
- check_output_includes(/6 fff/)
199
+ check_output_includes(/2 bbb\n 3 ccc\n 4 ddd/)
200
+ check_output_doesnt_include(/1 aaa/)
220
201
  end
221
202
  end
222
203
 
223
204
  describe 'max records' do
224
- temporary_change_const Readline, 'HISTORY', %w{aaa bbb ccc ddd eee fff ggg hhh iii jjj kkk lll mmm nnn}
225
-
226
- it 'must show last 10 records from readline history' do
227
- enter 'show commands'
205
+ it 'displays whole history if max_size is bigger than Readline::HISTORY' do
206
+ enter 'set histsize 7', 'show commands'
228
207
  debug_file 'show'
229
- check_output_doesnt_include(/3 ddd/)
230
- check_output_includes(/4 eee/)
231
- check_output_includes(/13 nnn/)
208
+ check_output_includes(/1 aaa\n 2 bbb\n 3 ccc\n 4 ddd/)
232
209
  end
233
210
  end
234
211
 
235
- describe 'with specified positions' do
236
- temporary_change_const Readline, 'HISTORY', %w{aaa bbb ccc ddd eee fff ggg hhh iii jjj kkk lll mmm nnn}
237
-
238
- it 'must show records within boundaries' do
239
- # Really don't know why it substracts 4, and shows starting from position 6
240
- enter 'show commands 10'
241
- debug_file 'show'
242
- check_output_doesnt_include(/5 fff/)
243
- check_output_includes(/6 ggg/)
244
- check_output_includes(/13 nnn/)
245
- end
246
-
247
- it 'must adjust first line if it is < 0' do
248
- enter 'show commands 3'
212
+ describe 'with specified size' do
213
+ it 'displays the specified number of entries most recent first' do
214
+ enter 'show commands 2'
249
215
  debug_file 'show'
250
- check_output_includes(/1 bbb/)
251
- check_output_includes(/8 iii/)
252
- check_output_doesnt_include(/9 jjj/)
216
+ check_output_includes(/3 ccc\n 4 ddd/)
217
+ check_output_doesnt_include(/1 aaa\n 2 bbb/)
253
218
  end
254
219
  end
255
220
  end