byebug 2.3.1 → 2.4.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 (58) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/README.md +3 -11
  4. data/Rakefile +10 -3
  5. data/bin/byebug +16 -2
  6. data/byebug.gemspec +1 -0
  7. data/ext/byebug/byebug.c +0 -54
  8. data/ext/byebug/byebug.h +3 -4
  9. data/ext/byebug/extconf.rb +1 -1
  10. data/lib/byebug.rb +15 -42
  11. data/lib/byebug/command.rb +12 -28
  12. data/lib/byebug/commands/breakpoints.rb +2 -0
  13. data/lib/byebug/commands/catchpoint.rb +1 -1
  14. data/lib/byebug/commands/condition.rb +1 -0
  15. data/lib/byebug/commands/display.rb +6 -0
  16. data/lib/byebug/commands/frame.rb +10 -3
  17. data/lib/byebug/commands/info.rb +5 -3
  18. data/lib/byebug/commands/reload.rb +1 -0
  19. data/lib/byebug/commands/set.rb +5 -1
  20. data/lib/byebug/commands/threads.rb +5 -4
  21. data/lib/byebug/commands/trace.rb +5 -5
  22. data/lib/byebug/context.rb +3 -3
  23. data/lib/byebug/interface.rb +3 -187
  24. data/lib/byebug/interfaces/local_interface.rb +88 -0
  25. data/lib/byebug/interfaces/remote_interface.rb +55 -0
  26. data/lib/byebug/interfaces/script_interface.rb +45 -0
  27. data/lib/byebug/processor.rb +15 -13
  28. data/lib/byebug/version.rb +1 -1
  29. data/test/breakpoints_test.rb +23 -25
  30. data/test/conditions_test.rb +6 -8
  31. data/test/continue_test.rb +4 -6
  32. data/test/debugger_alias_test.rb +5 -0
  33. data/test/display_test.rb +9 -11
  34. data/test/edit_test.rb +0 -2
  35. data/test/eval_test.rb +1 -3
  36. data/test/finish_test.rb +12 -12
  37. data/test/frame_test.rb +38 -40
  38. data/test/help_test.rb +1 -3
  39. data/test/info_test.rb +12 -14
  40. data/test/kill_test.rb +0 -2
  41. data/test/list_test.rb +1 -3
  42. data/test/method_test.rb +0 -2
  43. data/test/post_mortem_test.rb +77 -96
  44. data/test/quit_test.rb +0 -2
  45. data/test/reload_test.rb +0 -2
  46. data/test/repl_test.rb +3 -5
  47. data/test/restart_test.rb +0 -2
  48. data/test/save_test.rb +1 -3
  49. data/test/set_test.rb +3 -5
  50. data/test/show_test.rb +0 -2
  51. data/test/source_test.rb +0 -2
  52. data/test/stepping_test.rb +17 -19
  53. data/test/support/test_dsl.rb +21 -13
  54. data/test/test_helper.rb +23 -1
  55. data/test/thread_test.rb +19 -21
  56. data/test/trace_test.rb +12 -14
  57. data/test/variables_test.rb +6 -6
  58. metadata +22 -3
@@ -1,5 +1,3 @@
1
- require_relative 'test_helper'
2
-
3
1
  class TestEdit < TestDsl::TestCase
4
2
 
5
3
  describe 'open configured editor' do
@@ -1,5 +1,3 @@
1
- require_relative 'test_helper'
2
-
3
1
  class EvalTest
4
2
  def sum(a,b)
5
3
  a + b
@@ -31,7 +29,7 @@ class TestEval < TestDsl::TestCase
31
29
 
32
30
  it 'must work when inspect raises an exception' do
33
31
  enter 'c 4', 'p @foo'
34
- debug_file('eval') { $state.line.must_equal 4 }
32
+ debug_file('eval') { state.line.must_equal 4 }
35
33
  check_output_includes 'RuntimeError Exception: Broken'
36
34
  end
37
35
 
@@ -1,5 +1,3 @@
1
- require_relative 'test_helper'
2
-
3
1
  class FinishExample
4
2
  def a
5
3
  b
@@ -18,28 +16,30 @@ class FinishExample
18
16
  end
19
17
 
20
18
  class TestFinish < TestDsl::TestCase
19
+ before { enter "break #{__FILE__}:14", 'cont' }
20
+
21
21
  it 'must stop at the next frame by default' do
22
- enter "break #{__FILE__}:16", 'cont', 'finish'
23
- debug_file('finish') { $state.line.must_equal 13 }
22
+ enter 'finish'
23
+ debug_file('finish') { state.line.must_equal 11 }
24
24
  end
25
25
 
26
26
  it 'must stop at the #0 frame by default' do
27
- enter "break #{__FILE__}:16", 'cont', 'finish 0'
28
- debug_file('finish') { $state.line.must_equal 13 }
27
+ enter 'finish 0'
28
+ debug_file('finish') { state.line.must_equal 11 }
29
29
  end
30
30
 
31
31
  it 'must stop at the specified frame' do
32
- enter "break #{__FILE__}:16", 'cont', 'finish 1'
33
- debug_file('finish') { $state.line.must_equal 9 }
32
+ enter 'finish 1'
33
+ debug_file('finish') { state.line.must_equal 7 }
34
34
  end
35
35
 
36
36
  it 'must stop at the next frame if the current frame was changed' do
37
- enter "break #{__FILE__}:16", 'cont', 'up', 'finish'
38
- debug_file('finish') { $state.line.must_equal 9 }
37
+ enter 'up', 'finish'
38
+ debug_file('finish') { state.line.must_equal 7 }
39
39
  end
40
40
 
41
41
  describe 'not a number is specified for frame' do
42
- before { enter "break #{__FILE__}:16", 'cont', 'finish foo' }
42
+ before { enter 'finish foo' }
43
43
 
44
44
  it 'must show an error' do
45
45
  debug_file('finish')
@@ -47,7 +47,7 @@ class TestFinish < TestDsl::TestCase
47
47
  end
48
48
 
49
49
  it 'must be on the same line' do
50
- debug_file('finish') { $state.line.must_equal 16 }
50
+ debug_file('finish') { state.line.must_equal 14 }
51
51
  end
52
52
  end
53
53
  end
@@ -1,5 +1,3 @@
1
- require_relative 'test_helper'
2
-
3
1
  class FrameExample
4
2
  def initialize(f)
5
3
  @f = f
@@ -47,60 +45,60 @@ class TestFrame < TestDsl::TestCase
47
45
  describe 'when byebug started at the beginning' do
48
46
  before do
49
47
  @tst_file = fullpath('frame')
50
- enter "break #{__FILE__}:23", 'cont'
48
+ enter "break #{__FILE__}:21", 'cont'
51
49
  end
52
50
 
53
51
  it 'must go up' do
54
52
  enter 'up'
55
- debug_file('frame') { $state.line.must_equal 18 }
53
+ debug_file('frame') { state.line.must_equal 16 }
56
54
  end
57
55
 
58
56
  it 'must go up by specific number of frames' do
59
57
  enter 'up 2'
60
- debug_file('frame') { $state.line.must_equal 13 }
58
+ debug_file('frame') { state.line.must_equal 11 }
61
59
  end
62
60
 
63
61
  it 'must go down' do
64
62
  enter 'up', 'down'
65
- debug_file('frame') { $state.line.must_equal 23 }
63
+ debug_file('frame') { state.line.must_equal 21 }
66
64
  end
67
65
 
68
66
  it 'must go down by specific number of frames' do
69
67
  enter 'up 3', 'down 2'
70
- debug_file('frame') { $state.line.must_equal 18 }
68
+ debug_file('frame') { state.line.must_equal 16 }
71
69
  end
72
70
 
73
71
  it 'must set frame' do
74
72
  enter 'frame 2'
75
- debug_file('frame') { $state.line.must_equal 13 }
73
+ debug_file('frame') { state.line.must_equal 11 }
76
74
  end
77
75
 
78
76
  it 'must print current stack frame when without arguments' do
79
77
  enter 'up', 'frame'
80
78
  debug_file('frame')
81
- check_output_includes(/#1 FrameExample\.c\s+at #{__FILE__}:18/)
79
+ check_output_includes(/#1 FrameExample\.c\s+at #{__FILE__}:16/)
82
80
  end
83
81
 
84
82
  it 'must set frame to the first one' do
85
83
  enter 'up', 'frame 0'
86
- debug_file('frame') { $state.line.must_equal 23 }
84
+ debug_file('frame') { state.line.must_equal 21 }
87
85
  end
88
86
 
89
87
  it 'must set frame to the last one' do
90
88
  enter 'frame -1'
91
- debug_file('frame') { $state.file.must_match(/test_dsl.rb/) }
89
+ debug_file('frame') { File.basename(state.file).must_equal 'test_helper.rb' }
92
90
  end
93
91
 
94
92
  it 'must not set frame if the frame number is too low' do
95
93
  enter 'down'
96
- debug_file('frame') { $state.line.must_equal 23 }
94
+ debug_file('frame') { state.line.must_equal 21 }
97
95
  check_output_includes \
98
96
  "Can't navigate beyond the newest frame", interface.error_queue
99
97
  end
100
98
 
101
99
  it 'must not set frame if the frame number is too high' do
102
100
  enter 'up 100'
103
- debug_file('frame') { $state.line.must_equal 23 }
101
+ debug_file('frame') { state.line.must_equal 21 }
104
102
  check_output_includes \
105
103
  "Can't navigate beyond the oldest frame", interface.error_queue
106
104
  end
@@ -113,9 +111,9 @@ class TestFrame < TestDsl::TestCase
113
111
  enter 'where'
114
112
  debug_file 'frame'
115
113
  check_output_includes(
116
- /--> #0 FrameExample\.d\(e#String\)\s+at #{__FILE__}:23/,
117
- /#1 FrameExample\.c\s+at #{__FILE__}:18/,
118
- /#2 FrameExample\.b\s+at #{__FILE__}:13/)
114
+ /--> #0 FrameExample\.d\(e#String\)\s+at #{__FILE__}:21/,
115
+ /#1 FrameExample\.c\s+at #{__FILE__}:16/,
116
+ /#2 FrameExample\.b\s+at #{__FILE__}:11/)
119
117
  end
120
118
  end
121
119
 
@@ -126,10 +124,10 @@ class TestFrame < TestDsl::TestCase
126
124
  enter 'where'
127
125
  debug_file 'frame'
128
126
  check_output_includes(
129
- /--> #0 FrameExample\.d\(e#String\)\s+at #{shortpath(__FILE__)}:23/,
130
- /#1 FrameExample\.c\s+at #{shortpath(__FILE__)}:18/,
131
- /#2 FrameExample\.b\s+at #{shortpath(__FILE__)}:13/,
132
- /#3 FrameExample\.a\s+at #{shortpath(__FILE__)}:9/)
127
+ /--> #0 FrameExample\.d\(e#String\)\s+at #{shortpath(__FILE__)}:21/,
128
+ /#1 FrameExample\.c\s+at #{shortpath(__FILE__)}:16/,
129
+ /#2 FrameExample\.b\s+at #{shortpath(__FILE__)}:11/,
130
+ /#3 FrameExample\.a\s+at #{shortpath(__FILE__)}:7/)
133
131
  end
134
132
  end
135
133
  end
@@ -142,10 +140,10 @@ class TestFrame < TestDsl::TestCase
142
140
  enter 'where'
143
141
  debug_file 'frame'
144
142
  check_output_includes(
145
- /--> #0 FrameExample\.d\(e#String\)\s+at #{__FILE__}:23/,
146
- /#1 FrameExample\.c\s+at #{__FILE__}:18/,
147
- /#2 FrameExample\.b\s+at #{__FILE__}:13/,
148
- /#3 FrameExample\.a\s+at #{__FILE__}:9/)
143
+ /--> #0 FrameExample\.d\(e#String\)\s+at #{__FILE__}:21/,
144
+ /#1 FrameExample\.c\s+at #{__FILE__}:16/,
145
+ /#2 FrameExample\.b\s+at #{__FILE__}:11/,
146
+ /#3 FrameExample\.a\s+at #{__FILE__}:7/)
149
147
  end
150
148
  end
151
149
 
@@ -155,40 +153,40 @@ class TestFrame < TestDsl::TestCase
155
153
  it 'displays current backtrace with callstyle "short"' do
156
154
  enter 'where'
157
155
  debug_file 'frame'
158
- check_output_includes(/--> #0 d\(e\)\s+at #{__FILE__}:23/,
159
- /#1 c\s+at #{__FILE__}:18/,
160
- /#2 b\s+at #{__FILE__}:13/,
161
- /#3 a\s+at #{__FILE__}:9/)
156
+ check_output_includes(/--> #0 d\(e\)\s+at #{__FILE__}:21/,
157
+ /#1 c\s+at #{__FILE__}:16/,
158
+ /#2 b\s+at #{__FILE__}:11/,
159
+ /#3 a\s+at #{__FILE__}:7/)
162
160
  end
163
161
  end
164
162
  end
165
163
  end
166
164
 
167
165
  describe 'when byebug is started deep in the callstack' do
168
- before { enter "break #{__FILE__}:42", 'cont' }
166
+ before { enter "break #{__FILE__}:40", 'cont' }
169
167
 
170
168
  it 'must print backtrace' do
171
169
  enter 'where'
172
170
  debug_file 'frame_deep'
173
171
  check_output_includes(
174
- /--> #0 FrameDeepExample\.d\(e#String\)\s+at #{__FILE__}:42/,
175
- /#1 FrameDeepExample\.c\s+at #{__FILE__}:39/,
176
- /#2 FrameDeepExample\.b\s+at #{__FILE__}:34/)
172
+ /--> #0 FrameDeepExample\.d\(e#String\)\s+at #{__FILE__}:40/,
173
+ /#1 FrameDeepExample\.c\s+at #{__FILE__}:37/,
174
+ /#2 FrameDeepExample\.b\s+at #{__FILE__}:32/)
177
175
  end
178
176
 
179
177
  it 'must go up' do
180
178
  enter 'up'
181
- debug_file('frame_deep') { $state.line.must_equal 39 }
179
+ debug_file('frame_deep') { state.line.must_equal 37 }
182
180
  end
183
181
 
184
182
  it 'must go down' do
185
183
  enter 'up', 'down'
186
- debug_file('frame_deep') { $state.line.must_equal 42 }
184
+ debug_file('frame_deep') { state.line.must_equal 40 }
187
185
  end
188
186
 
189
187
  it 'must set frame' do
190
188
  enter 'frame 2'
191
- debug_file('frame_deep') { $state.line.must_equal 34 }
189
+ debug_file('frame_deep') { state.line.must_equal 32 }
192
190
  end
193
191
 
194
192
  it 'must eval properly when scaling the stack' do
@@ -200,29 +198,29 @@ class TestFrame < TestDsl::TestCase
200
198
 
201
199
  describe 'c-frames' do
202
200
  it 'must mark c-frames when printing the stack' do
203
- enter "break #{__FILE__}:5", 'cont', 'where'
201
+ enter "break #{__FILE__}:3", 'cont', 'where'
204
202
  enter 'where'
205
203
  debug_file 'frame'
206
204
  check_output_includes(
207
- /--> #0 FrameExample.initialize\(f#String\)\s+at #{__FILE__}:5/,
205
+ /--> #0 FrameExample.initialize\(f#String\)\s+at #{__FILE__}:3/,
208
206
  /ͱ-- #1 Class.new\(\*args\)\s+at #{fullpath('frame')}:3/,
209
207
  /#2 <top \(required\)>\s+at #{fullpath('frame')}:3/)
210
208
  end
211
209
 
212
210
  it '"up" skips c-frames' do
213
- enter "break #{__FILE__}:9", 'cont', 'up', 'eval fr_ex.class.to_s'
211
+ enter "break #{__FILE__}:7", 'cont', 'up', 'eval fr_ex.class.to_s'
214
212
  debug_file 'frame'
215
213
  check_output_includes '"FrameExample"'
216
214
  end
217
215
 
218
216
  it '"down" skips c-frames' do
219
- enter "break #{__FILE__}:9", 'cont', 'up', 'down', 'eval @f'
217
+ enter "break #{__FILE__}:7", 'cont', 'up', 'down', 'eval @f'
220
218
  debug_file 'frame'
221
219
  check_output_includes '"f"'
222
220
  end
223
221
 
224
222
  it 'must not jump straigh to c-frames' do
225
- enter "break #{__FILE__}:5", 'cont', 'frame 1'
223
+ enter "break #{__FILE__}:3", 'cont', 'frame 1'
226
224
  debug_file 'frame'
227
225
  check_output_includes "Can't navigate to c-frame", interface.error_queue
228
226
  end
@@ -1,10 +1,8 @@
1
- require_relative 'test_helper'
2
-
3
1
  class TestHelp < TestDsl::TestCase
4
2
  include Columnize
5
3
 
6
4
  let(:available_commands) {
7
- Byebug::Command.commands.select(&:event).map(&:names).flatten.uniq.sort }
5
+ Byebug::Command.commands.map(&:names).flatten.uniq.sort }
8
6
 
9
7
  describe 'when typed alone' do
10
8
  temporary_change_hash Byebug.settings, :width, 50
@@ -1,5 +1,3 @@
1
- require_relative 'test_helper'
2
-
3
1
  class InfoExample
4
2
  def initialize
5
3
  @foo = "bar"
@@ -35,7 +33,7 @@ class TestInfo < TestDsl::TestCase
35
33
 
36
34
  describe 'Args info' do
37
35
  it 'must show info about all args' do
38
- enter "break #{__FILE__}:12", 'cont', 'info args'
36
+ enter "break #{__FILE__}:10", 'cont', 'info args'
39
37
  debug_file 'info'
40
38
  check_output_includes 'y = "a"', 'z = "b"'
41
39
  end
@@ -182,7 +180,7 @@ class TestInfo < TestDsl::TestCase
182
180
 
183
181
  describe 'Instance variables info' do
184
182
  it 'must show instance variables' do
185
- enter "break #{__FILE__}:12", 'cont', 'info instance_variables'
183
+ enter "break #{__FILE__}:10", 'cont', 'info instance_variables'
186
184
  debug_file 'info'
187
185
  check_output_includes '@bla = "blabla"', '@foo = "bar"'
188
186
  end
@@ -190,9 +188,9 @@ class TestInfo < TestDsl::TestCase
190
188
 
191
189
  describe 'Line info' do
192
190
  it 'must show the current line' do
193
- enter "break #{__FILE__}:12", 'cont', 'info line'
191
+ enter "break #{__FILE__}:10", 'cont', 'info line'
194
192
  debug_file 'info'
195
- check_output_includes "Line 12 of \"#{__FILE__}\""
193
+ check_output_includes "Line 10 of \"#{__FILE__}\""
196
194
  end
197
195
  end
198
196
 
@@ -200,13 +198,13 @@ class TestInfo < TestDsl::TestCase
200
198
  temporary_change_hash Byebug.settings, :width, 28
201
199
 
202
200
  it 'must show the current local variables' do
203
- enter "break #{__FILE__}:12", 'cont', 'info locals'
201
+ enter "break #{__FILE__}:10", 'cont', 'info locals'
204
202
  debug_file 'info'
205
203
  check_output_includes 'w = "11111111111111111111...', 'x = 2'
206
204
  end
207
205
 
208
206
  it 'must fail if local variable doesn\'t respond to #to_s or to #inspect' do
209
- enter "break #{__FILE__}:17", 'cont', 'info locals'
207
+ enter "break #{__FILE__}:15", 'cont', 'info locals'
210
208
  debug_file 'info'
211
209
  check_output_includes 'a = *Error in evaluation*'
212
210
  end
@@ -254,11 +252,11 @@ class TestInfo < TestDsl::TestCase
254
252
 
255
253
  describe 'Stack info' do
256
254
  it 'must show stack info' do
257
- enter 'set fullpath', "break #{__FILE__}:10", 'cont', 'info stack'
255
+ enter 'set fullpath', "break #{__FILE__}:8", 'cont', 'info stack'
258
256
  debug_file 'info'
259
257
  check_output_includes(
260
- /--> #0 InfoExample.a\(y\#String, z\#String\)\s+at #{__FILE__}:10/,
261
- /#1 InfoExample.b\s+at #{__FILE__}:21/,
258
+ /--> #0 InfoExample.a\(y\#String, z\#String\)\s+at #{__FILE__}:8/,
259
+ /#1 InfoExample.b\s+at #{__FILE__}:19/,
262
260
  /#2 <top \(required\)>\s+at #{fullpath('info')}:4/)
263
261
  end
264
262
  end
@@ -275,7 +273,7 @@ class TestInfo < TestDsl::TestCase
275
273
  temporary_change_hash Byebug.settings, :width, 30
276
274
 
277
275
  it 'must show all variables' do
278
- enter "break #{__FILE__}:12", 'cont', 'info variables'
276
+ enter "break #{__FILE__}:10", 'cont', 'info variables'
279
277
  debug_file 'info'
280
278
  check_output_includes(/self = #<InfoExample:\S+.../,
281
279
  'w = "1111111111111111111111...',
@@ -285,7 +283,7 @@ class TestInfo < TestDsl::TestCase
285
283
  end
286
284
 
287
285
  it 'must fail if the variable doesn\'t respond to #to_s or to #inspect' do
288
- enter "break #{__FILE__}:17", 'cont', 'info variables'
286
+ enter "break #{__FILE__}:15", 'cont', 'info variables'
289
287
  debug_file 'info'
290
288
  check_output_includes 'a = *Error in evaluation*',
291
289
  /self = #<InfoExample:\S+.../,
@@ -294,7 +292,7 @@ class TestInfo < TestDsl::TestCase
294
292
  end
295
293
 
296
294
  it 'must correctly print variables containing % sign' do
297
- enter "break #{__FILE__}:23", 'cont', 'info variables'
295
+ enter "break #{__FILE__}:21", 'cont', 'info variables'
298
296
  debug_file 'info'
299
297
  check_output_includes 'e = "%.2f"'
300
298
  end
@@ -1,5 +1,3 @@
1
- require_relative 'test_helper'
2
-
3
1
  class KillExample
4
2
  def self.kill_me
5
3
  'dieeee'
@@ -1,5 +1,3 @@
1
- require_relative 'test_helper'
2
-
3
1
  class TestList < TestDsl::TestCase
4
2
  describe 'listsize' do
5
3
  it 'must show lines according to :listsize setting' do
@@ -160,7 +158,7 @@ class TestList < TestDsl::TestCase
160
158
  end
161
159
 
162
160
  it 'must show an error when there is no such file' do
163
- enter -> { $state.file = 'blabla'; 'list 4-4' }
161
+ enter -> { state.file = 'blabla'; 'list 4-4' }
164
162
  debug_file 'list'
165
163
  check_error_includes 'No sourcefile available for blabla'
166
164
  end
@@ -1,5 +1,3 @@
1
- require_relative 'test_helper'
2
-
3
1
  class MethodExample
4
2
  def initialize
5
3
  @a = 'b'
@@ -1,40 +1,25 @@
1
- require_relative 'test_helper'
2
-
3
1
  class PostMortemExample
4
2
  def a
5
- begin
6
- Byebug.post_mortem do
7
- z = 4
8
- raise 'blabla'
9
- x = 6
10
- x + z
11
- end
12
- rescue => e
13
- e
14
- end
3
+ z = 4
4
+ raise 'blabla'
5
+ x = 6
6
+ x + z
15
7
  end
16
8
  end
17
9
 
18
10
  class TestPostMortem < TestDsl::TestCase
11
+
19
12
  describe 'Features' do
20
- before { enter 'cont' }
13
+ before { enter 'set post_mortem', 'cont' }
21
14
 
22
15
  it 'must enter into post-mortem mode' do
23
- debug_file('post_mortem') { Byebug.post_mortem?.must_equal true }
16
+ debug_file('post_mortem', rescue: true) do
17
+ Byebug.post_mortem?.must_equal true
18
+ end
24
19
  end
25
20
 
26
21
  it 'must stop at the correct line' do
27
- debug_file('post_mortem') { $state.line.must_equal 8 }
28
- end
29
-
30
- it 'must exit from post-mortem mode after stepping command' do
31
- enter 'break 13', 'cont'
32
- debug_file('post_mortem') { Byebug.post_mortem?.must_equal false }
33
- end
34
-
35
- it 'must save the raised exception' do
36
- debug_file('post_mortem') {
37
- Byebug.last_exception.must_be_kind_of RuntimeError }
22
+ debug_file('post_mortem', rescue: true) { assert_equal 4, state.line }
38
23
  end
39
24
  end
40
25
 
@@ -43,69 +28,81 @@ class TestPostMortem < TestDsl::TestCase
43
28
 
44
29
  describe 'step' do
45
30
  it 'must not work in post-mortem mode' do
46
- enter 'cont', 'step'
47
- debug_file 'post_mortem'
31
+ enter 'set post_mortem', 'cont', 'step'
32
+ debug_file 'post_mortem', rescue: true
48
33
  check_error_includes 'Unknown command: "step". Try "help".'
49
34
  end
50
35
  end
51
36
 
52
37
  describe 'next' do
53
38
  it 'must not work in post-mortem mode' do
54
- enter 'cont', 'next'
55
- debug_file 'post_mortem'
39
+ enter 'set post_mortem', 'cont', 'next'
40
+ debug_file 'post_mortem', rescue: true
56
41
  check_error_includes 'Unknown command: "next". Try "help".'
57
42
  end
58
43
  end
59
44
 
60
45
  describe 'finish' do
61
46
  it 'must not work in post-mortem mode' do
62
- enter 'cont', 'finish'
63
- debug_file 'post_mortem'
47
+ enter 'set post_mortem', 'cont', 'finish'
48
+ debug_file 'post_mortem', rescue: true
64
49
  check_error_includes 'Unknown command: "finish". Try "help".'
65
50
  end
66
51
  end
67
- end
68
52
 
69
- describe 'Available commands' do
70
- before { @tst_file = fullpath('post_mortem') }
53
+ describe 'break' do
54
+ it 'must not be able to set breakpoints in post-mortem mode' do
55
+ enter 'set post_mortem', 'cont', "break #{__FILE__}:6"
56
+ debug_file 'post_mortem', rescue: true
57
+ check_error_includes "Unknown command: \"break #{__FILE__}:6\". " \
58
+ 'Try "help".'
59
+ end
60
+ end
71
61
 
72
- describe 'restart' do
73
- it 'must work in post-mortem mode' do
74
- must_restart
75
- enter 'cont', 'restart'
76
- debug_file 'post_mortem'
62
+ describe 'condition' do
63
+ it 'must not be able to set conditions in post-mortem mode' do
64
+ enter "break #{__FILE__}:6", 'set post_mortem', 'cont',
65
+ ->{ "cond #{Byebug.breakpoints.last.id} true" }
66
+ debug_file 'post_mortem', rescue: true
67
+ check_error_includes \
68
+ "Unknown command: \"cond #{Byebug.breakpoints.last.id} true\". " \
69
+ "Try \"help\"."
77
70
  end
78
71
  end
79
72
 
80
73
  describe 'display' do
81
- it 'must be able to set display expressions in post-mortem mode' do
82
- enter 'cont', 'display 2 + 2'
83
- debug_file 'post_mortem'
84
- check_output_includes '1:', '2 + 2 = 4'
74
+ it 'must be not able to set display expressions in post-mortem mode' do
75
+ enter 'set post_mortem', 'cont', 'display 2 + 2'
76
+ debug_file 'post_mortem', rescue: true
77
+ check_error_includes 'Unknown command: "display 2 + 2". Try "help".'
85
78
  end
86
79
  end
87
80
 
88
- describe 'frame' do
81
+ describe 'reload' do
89
82
  it 'must work in post-mortem mode' do
90
- enter 'cont', 'frame'
91
- debug_file('post_mortem') { $state.line.must_equal 8 }
92
- check_output_includes(
93
- /--> #0 block in PostMortemExample\.a\s+at #{__FILE__}:8/)
83
+ enter 'set post_mortem', 'cont', 'reload'
84
+ debug_file 'post_mortem', rescue: true
85
+ check_error_includes 'Unknown command: "reload". Try "help".'
94
86
  end
95
87
  end
96
88
 
97
- describe 'condition' do
98
- it 'must be able to set conditions in post-mortem mode' do
99
- enter 'cont', 'break 13',
100
- ->{ "cond #{Byebug.breakpoints.first.id} true" }, 'cont'
101
- debug_file('post_mortem') { $state.line.must_equal 13 }
89
+
90
+ end
91
+
92
+ describe 'Available commands' do
93
+ describe 'restart' do
94
+ it 'must work in post-mortem mode' do
95
+ must_restart
96
+ enter 'cont', 'restart'
97
+ debug_file 'post_mortem', rescue: true
102
98
  end
103
99
  end
104
100
 
105
- describe 'break' do
106
- it 'must be able to set breakpoints in post-mortem mode' do
107
- enter 'cont', 'break 13', 'cont'
108
- debug_file('post_mortem') { $state.line.must_equal 13 }
101
+ describe 'frame' do
102
+ it 'must work in post-mortem mode' do
103
+ enter 'cont', 'frame'
104
+ debug_file('post_mortem', rescue: true) { state.line.must_equal 4 }
105
+ check_output_includes(/--> #0 PostMortemExample\.a\s+at #{__FILE__}:4/)
109
106
  end
110
107
  end
111
108
 
@@ -113,20 +110,7 @@ class TestPostMortem < TestDsl::TestCase
113
110
  it 'must work in post-mortem mode' do
114
111
  Byebug::QuitCommand.any_instance.expects(:exit!)
115
112
  enter 'cont', 'exit!'
116
- debug_file 'post_mortem'
117
- end
118
- end
119
-
120
- describe 'reload' do
121
- after { change_line_in_file(@tst_file, 4, 'c.a') }
122
-
123
- it 'must work in post-mortem mode' do
124
- enter 'cont', -> do
125
- change_line_in_file(@tst_file, 4, 'bo = BasicObject.new')
126
- 'reload'
127
- end, 'up 3', 'l 4-4'
128
- debug_file 'post_mortem'
129
- check_output_includes '=> 4: bo = BasicObject.new'
113
+ debug_file 'post_mortem', rescue: true
130
114
  end
131
115
  end
132
116
 
@@ -137,15 +121,15 @@ class TestPostMortem < TestDsl::TestCase
137
121
  Byebug::Edit.any_instance.
138
122
  expects(:system).with("editr +2 #{fullpath('edit')}")
139
123
  enter 'cont', "edit #{fullpath('edit')}:2", 'cont'
140
- debug_file 'post_mortem'
124
+ debug_file 'post_mortem', rescue: true
141
125
  end
142
126
  end
143
127
 
144
128
  describe 'info' do
145
129
  it 'must work in post-mortem mode' do
146
130
  enter 'cont', 'info line'
147
- debug_file 'post_mortem'
148
- check_output_includes "Line 8 of \"#{__FILE__}\""
131
+ debug_file 'post_mortem', rescue: true
132
+ check_output_includes "Line 4 of \"#{__FILE__}\""
149
133
  end
150
134
  end
151
135
 
@@ -155,30 +139,27 @@ class TestPostMortem < TestDsl::TestCase
155
139
  it 'must work in post-mortem mode' do
156
140
  skip "Don't know why this is failing now..."
157
141
  irb.stubs(:eval_input).throws(:IRB_EXIT, :cont)
158
- enter 'cont', 'break 13', 'irb'
159
- debug_file('post_mortem') { $state.line.must_equal 13 }
142
+ enter 'cont', 'break 11', 'irb'
143
+ debug_file('post_mortem', rescue: true) { state.line.must_equal 11 }
160
144
  end
161
145
  end
162
146
 
163
147
  describe 'source' do
164
- before { File.open(filename, 'w') do |f|
165
- f.puts 'break 2'
166
- f.puts 'break 3 if true'
167
- end }
168
- after { FileUtils.rm(filename) }
169
-
170
148
  let(:filename) { 'source_example.txt' }
171
149
 
150
+ before { File.open(filename, 'w') { |f| f.puts 'frame' } }
151
+
172
152
  it 'must work in post-mortem mode' do
173
153
  enter 'cont', "so #{filename}"
174
- debug_file('post_mortem') { Byebug.breakpoints[0].pos.must_equal 3 }
154
+ debug_file('post_mortem', rescue: true)
155
+ check_output_includes(/--> #0 PostMortemExample\.a\s+at #{__FILE__}:4/)
175
156
  end
176
157
  end
177
158
 
178
159
  describe 'help' do
179
160
  it 'must work in post-mortem mode' do
180
161
  enter 'cont', 'help'
181
- debug_file 'post_mortem'
162
+ debug_file 'post_mortem', rescue: true
182
163
  check_output_includes 'Available commands:'
183
164
  end
184
165
  end
@@ -186,7 +167,7 @@ class TestPostMortem < TestDsl::TestCase
186
167
  describe 'var' do
187
168
  it 'must work in post-mortem mode' do
188
169
  enter 'cont', 'var local'
189
- debug_file 'post_mortem'
170
+ debug_file 'post_mortem', rescue: true
190
171
  check_output_includes 'x => nil', 'z => 4'
191
172
  end
192
173
  end
@@ -194,15 +175,15 @@ class TestPostMortem < TestDsl::TestCase
194
175
  describe 'list' do
195
176
  it 'must work in post-mortem mode' do
196
177
  enter 'cont'
197
- debug_file 'post_mortem'
198
- check_output_includes "[3, 12] in #{__FILE__}"
178
+ debug_file 'post_mortem', rescue: true
179
+ check_output_includes "[1, 10] in #{__FILE__}"
199
180
  end
200
181
  end
201
182
 
202
183
  describe 'method' do
203
184
  it 'must work in post-mortem mode' do
204
185
  enter 'cont', 'm i self'
205
- debug_file 'post_mortem'
186
+ debug_file 'post_mortem', rescue: true
206
187
  check_output_includes(/to_s/)
207
188
  end
208
189
  end
@@ -211,14 +192,14 @@ class TestPostMortem < TestDsl::TestCase
211
192
  it 'must work in post-mortem mode' do
212
193
  Process.expects(:kill).with('USR1', Process.pid)
213
194
  enter 'cont', 'kill USR1'
214
- debug_file 'post_mortem'
195
+ debug_file 'post_mortem', rescue: true
215
196
  end
216
197
  end
217
198
 
218
199
  describe 'eval' do
219
200
  it 'must work in post-mortem mode' do
220
201
  enter 'cont', 'eval 2 + 2'
221
- debug_file 'post_mortem'
202
+ debug_file 'post_mortem', rescue: true
222
203
  check_output_includes '4'
223
204
  end
224
205
  end
@@ -228,7 +209,7 @@ class TestPostMortem < TestDsl::TestCase
228
209
 
229
210
  it 'must work in post-mortem mode' do
230
211
  enter 'cont', 'set autolist on'
231
- debug_file 'post_mortem'
212
+ debug_file 'post_mortem', rescue: true
232
213
  check_output_includes 'autolist is on.'
233
214
  end
234
215
  end
@@ -236,11 +217,11 @@ class TestPostMortem < TestDsl::TestCase
236
217
  describe 'save' do
237
218
  let(:file_name) { 'save_output.txt' }
238
219
  let(:file_contents) { File.read(file_name) }
239
- after { FileUtils.rm(file_name) }
220
+ after { File.delete(file_name) }
240
221
 
241
222
  it 'must work in post-mortem mode' do
242
223
  enter 'cont', "save #{file_name}"
243
- debug_file 'post_mortem'
224
+ debug_file 'post_mortem', rescue: true
244
225
  file_contents.must_include 'set autoirb off'
245
226
  end
246
227
  end
@@ -248,7 +229,7 @@ class TestPostMortem < TestDsl::TestCase
248
229
  describe 'show' do
249
230
  it 'must work in post-mortem mode' do
250
231
  enter 'cont', 'show autolist'
251
- debug_file 'post_mortem'
232
+ debug_file 'post_mortem', rescue: true
252
233
  check_output_includes 'autolist is on.'
253
234
  end
254
235
  end
@@ -256,7 +237,7 @@ class TestPostMortem < TestDsl::TestCase
256
237
  describe 'trace' do
257
238
  it 'must work in post-mortem mode' do
258
239
  enter 'cont', 'trace on'
259
- debug_file 'post_mortem'
240
+ debug_file 'post_mortem', rescue: true
260
241
  check_output_includes 'line tracing is on.'
261
242
  end
262
243
  end
@@ -264,7 +245,7 @@ class TestPostMortem < TestDsl::TestCase
264
245
  describe 'thread' do
265
246
  it "must work in post-mortem mode" do
266
247
  enter 'cont', 'thread list'
267
- debug_file('post_mortem')
248
+ debug_file 'post_mortem', rescue: true
268
249
  check_output_includes(/\+ \d+ #<Thread:(\S+) run/)
269
250
  end
270
251
  end