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
@@ -1,9 +1,9 @@
1
1
  module Byebug
2
2
  class Interface
3
- attr_writer :have_readline
3
+ attr_accessor :command_queue, :restart_file
4
4
 
5
5
  def initialize
6
- @have_readline = false
6
+ @command_queue, @restart_file = [], nil
7
7
  end
8
8
 
9
9
  # Common routine for reporting byebug error messages.
@@ -28,7 +28,7 @@ module Byebug
28
28
  end
29
29
  end
30
30
 
31
- require_relative 'interfaces/local_interface'
32
- require_relative 'interfaces/script_interface'
33
- require_relative 'interfaces/remote_interface'
31
+ require 'byebug/interfaces/local_interface'
32
+ require 'byebug/interfaces/script_interface'
33
+ require 'byebug/interfaces/remote_interface'
34
34
  end
@@ -1,24 +1,12 @@
1
+ require 'byebug/history'
2
+
1
3
  module Byebug
2
4
  class LocalInterface < Interface
3
- attr_accessor :command_queue, :history_length, :history_save, :histfile
4
- attr_accessor :restart_file
5
-
6
- FILE_HISTORY = ".byebug_hist" unless defined?(FILE_HISTORY)
5
+ attr_reader :history
7
6
 
8
- def initialize()
7
+ def initialize
9
8
  super
10
- @command_queue = []
11
- @have_readline = false
12
- @history_save = true
13
- @history_length = ENV["HISTSIZE"] ? ENV["HISTSIZE"].to_i : 256
14
- @histfile = File.join(ENV["HOME"]||ENV["HOMEPATH"]||".", FILE_HISTORY)
15
- open(@histfile, 'r') do |file|
16
- file.each do |line|
17
- line.chomp!
18
- Readline::HISTORY << line
19
- end
20
- end if File.exist?(@histfile)
21
- @restart_file = nil
9
+ History.load
22
10
  end
23
11
 
24
12
  def read_command(prompt)
@@ -34,55 +22,16 @@ module Byebug
34
22
  end
35
23
 
36
24
  def close
37
- end
38
-
39
- # Things to do before quitting
40
- def finalize
41
- if Byebug.respond_to?(:save_history)
42
- Byebug.save_history
43
- end
44
- end
45
-
46
- def readline_support?
47
- @have_readline
25
+ History.save
48
26
  end
49
27
 
50
28
  private
51
29
 
52
- begin
53
- require 'readline'
54
- class << Byebug
55
- @have_readline = true
56
- define_method(:save_history) do
57
- iface = self.handler.interface
58
- iface.histfile ||= File.join(ENV["HOME"]||ENV["HOMEPATH"]||".",
59
- FILE_HISTORY)
60
- open(iface.histfile, 'w') do |file|
61
- Readline::HISTORY.to_a.last(iface.history_length).each do |line|
62
- file.puts line unless line.strip.empty?
63
- end if defined?(iface.history_save) and iface.history_save
64
- end rescue nil
65
- end
66
- public :save_history
67
- end
68
-
69
- def readline(prompt, hist)
70
- Readline::readline(prompt, hist)
71
- rescue Interrupt
72
- print "^C\n"
73
- retry
74
- end
75
- rescue LoadError
76
- def readline(prompt, hist)
77
- @histfile = ''
78
- @hist_save = false
79
- STDOUT.print prompt
80
- STDOUT.flush
81
- line = STDIN.gets
82
- exit unless line
83
- line.chomp!
84
- line
85
- end
30
+ def readline(prompt, hist)
31
+ Readline::readline(prompt, hist)
32
+ rescue Interrupt
33
+ print "^C\n"
34
+ retry
86
35
  end
87
36
  end
88
37
  end
@@ -1,44 +1,28 @@
1
+ require 'byebug/history'
2
+
1
3
  module Byebug
2
4
  class RemoteInterface < Interface
3
- attr_accessor :command_queue, :history_length, :history_save, :histfile
4
- attr_accessor :restart_file
5
+ attr_reader :history
5
6
 
6
7
  def initialize(socket)
7
- @command_queue = []
8
+ super()
8
9
  @socket = socket
9
- @history_save = false
10
- @history_length = 256
11
- @histfile = ''
12
- # Do we read the histfile?
13
- # open(@histfile, 'r') do |file|
14
- # file.each do |line|
15
- # line.chomp!
16
- # Readline::HISTORY << line
17
- # end
18
- # end if File.exist?(@histfile)
19
- @restart_file = nil
10
+ @history = History.new
20
11
  end
21
12
 
22
13
  def close
23
14
  @socket.close
24
- rescue Exception
15
+ rescue IOError
25
16
  end
26
17
 
27
18
  def confirm(prompt)
28
19
  send_command "CONFIRM #{prompt}"
29
20
  end
30
21
 
31
- def finalize
32
- end
33
-
34
22
  def read_command(prompt)
35
23
  send_command "PROMPT #{prompt}"
36
24
  end
37
25
 
38
- def readline_support?
39
- false
40
- end
41
-
42
26
  def print(*args)
43
27
  @socket.printf(escape(format(*args)))
44
28
  end
@@ -1,20 +1,9 @@
1
1
  module Byebug
2
- class ScriptInterface < Interface
3
- attr_accessor :command_queue, :history_length, :history_save, :histfile
4
- attr_accessor :restart_file
5
-
2
+ class ScriptInterface < Byebug::Interface
6
3
  def initialize(file, out, verbose=false)
7
4
  super()
8
- @command_queue = []
9
5
  @file = file.respond_to?(:gets) ? file : open(file)
10
- @out = out
11
- @verbose = verbose
12
- @history_save = false
13
- @history_length = 256
14
- @histfile = ''
15
- end
16
-
17
- def finalize
6
+ @out, @verbose = out, verbose
18
7
  end
19
8
 
20
9
  def read_command(prompt)
@@ -26,10 +15,6 @@ module Byebug
26
15
  end
27
16
  end
28
17
 
29
- def readline_support?
30
- false
31
- end
32
-
33
18
  def confirm(prompt)
34
19
  'y'
35
20
  end
@@ -1,9 +1,6 @@
1
1
  require 'forwardable'
2
- require_relative 'interface'
3
2
 
4
3
  module Byebug
5
-
6
- # Should this be a mixin?
7
4
  class Processor
8
5
  attr_accessor :interface
9
6
 
@@ -14,5 +11,8 @@ module Byebug
14
11
  @interface = interface
15
12
  end
16
13
  end
17
-
18
14
  end
15
+
16
+ require 'byebug/command'
17
+ require 'byebug/processors/command_processor'
18
+ require 'byebug/processors/control_command_processor'
@@ -1,7 +1,3 @@
1
- require 'forwardable'
2
- require_relative 'interface'
3
- require_relative 'command'
4
-
5
1
  module Byebug
6
2
 
7
3
  class CommandProcessor < Processor
@@ -52,11 +48,11 @@ module Byebug
52
48
  return unless @interface
53
49
  __#{mname}(*args)
54
50
  end
55
- rescue IOError, Errno::EPIPE
56
- self.interface = nil
51
+ rescue IOError, SystemCallError
52
+ @interface.close
57
53
  rescue SignalException
58
54
  raise
59
- rescue Exception
55
+ rescue
60
56
  print "INTERNAL ERROR!!! #\{$!\}\n" rescue nil
61
57
  print $!.backtrace.map{|l| "\t#\{l\}"}.join("\n") rescue nil
62
58
  end
@@ -118,9 +114,6 @@ module Byebug
118
114
  def always_run(context, file, line, run_level)
119
115
  cmds = Command.commands
120
116
 
121
- # Remove some commands in post-mortem
122
- cmds = cmds.find_all { |cmd| cmd.allow_in_post_mortem } if context.dead?
123
-
124
117
  state = State.new(cmds, context, @display, file, @interface, line)
125
118
 
126
119
  # Change default when in irb or code included in command line
@@ -194,8 +187,8 @@ module Byebug
194
187
  #
195
188
  def one_cmd(commands, context, input)
196
189
  if cmd = commands.find { |c| c.match(input) }
197
- if context.dead? && cmd.class.need_context
198
- print "Command is unavailable\n"
190
+ if context.dead? && !cmd.class.allow_in_post_mortem
191
+ errmsg "Command unavailable in post mortem mode.\n"
199
192
  else
200
193
  cmd.execute
201
194
  end
@@ -204,7 +197,7 @@ module Byebug
204
197
  if unknown_cmd
205
198
  unknown_cmd.execute
206
199
  else
207
- errmsg "Unknown command: \"#{input}\". Try \"help\".\n"
200
+ errmsg "Unknown command: \"#{input}\". Try \"help\".\n"
208
201
  end
209
202
  end
210
203
  end
@@ -251,5 +244,5 @@ module Byebug
251
244
  end
252
245
 
253
246
  end # class CommandProcessor
254
-
247
+
255
248
  end
@@ -1,7 +1,3 @@
1
- require 'forwardable'
2
- require_relative 'interface'
3
- require_relative 'command'
4
-
5
1
  module Byebug
6
2
 
7
3
  class ControlCommandProcessor < Processor
@@ -32,8 +28,8 @@ module Byebug
32
28
  end
33
29
  end
34
30
  end
35
- rescue IOError, Errno::EPIPE
36
- rescue Exception
31
+ rescue IOError, SystemCallError
32
+ rescue
37
33
  print "INTERNAL ERROR!!! #{$!}\n" rescue nil
38
34
  print $!.backtrace.map{|l| "\t#{l}"}.join("\n") rescue nil
39
35
  ensure
@@ -75,5 +71,5 @@ module Byebug
75
71
  end
76
72
  end
77
73
  end
78
-
74
+
79
75
  end
@@ -1,3 +1,3 @@
1
1
  module Byebug
2
- VERSION = '2.7.0'
2
+ VERSION = '3.0.0'
3
3
  end
@@ -4,8 +4,8 @@ class TestEdit < TestDsl::TestCase
4
4
  temporary_change_hash ENV, 'EDITOR', 'editr'
5
5
 
6
6
  it 'must open current file in current line in configured editor' do
7
- Byebug::Edit.any_instance.expects(:system).
8
- with("editr +2 #{fullpath('edit')}")
7
+ Byebug::EditCommand.any_instance.expects(:system)
8
+ .with("editr +2 #{fullpath('edit')}")
9
9
  enter 'edit'
10
10
  debug_file 'edit'
11
11
  end
@@ -15,8 +15,8 @@ class TestEdit < TestDsl::TestCase
15
15
  temporary_change_hash ENV, 'EDITOR', nil
16
16
 
17
17
  it 'must call "vim" with current line and file if EDITOR env not set' do
18
- Byebug::Edit.any_instance.expects(:system).
19
- with("vim +2 #{fullpath('edit')}")
18
+ Byebug::EditCommand.any_instance.expects(:system)
19
+ .with("vim +2 #{fullpath('edit')}")
20
20
  enter 'edit'
21
21
  debug_file 'edit'
22
22
  end
@@ -26,8 +26,8 @@ class TestEdit < TestDsl::TestCase
26
26
  temporary_change_hash ENV, 'EDITOR', 'editr'
27
27
 
28
28
  it 'must open specified line in specified file with configured editor' do
29
- Byebug::Edit.any_instance.expects(:system).
30
- with("editr +3 #{fullpath('breakpoint')}")
29
+ Byebug::EditCommand.any_instance.expects(:system)
30
+ .with("editr +3 #{fullpath('breakpoint')}")
31
31
  enter "edit #{fullpath('breakpoint')}:3"
32
32
  debug_file 'edit'
33
33
  end
@@ -1,4 +1,4 @@
1
1
  ex = BreakpointDeepExample.new.a
2
2
  2.times do
3
- ex += 1
3
+ ex = ex ? ex : 1
4
4
  end
@@ -18,22 +18,22 @@ end
18
18
  class TestFinish < TestDsl::TestCase
19
19
  before { enter "break #{__FILE__}:14", 'cont' }
20
20
 
21
- it 'must stop at the next frame by default' do
21
+ it 'must stop after current frame is finished when without arguments' do
22
22
  enter 'finish'
23
23
  debug_file('finish') { state.line.must_equal 11 }
24
24
  end
25
25
 
26
- it 'must stop at the #0 frame by default' do
26
+ it 'must stop before current frame finishes if 0 specified as argument' do
27
27
  enter 'finish 0'
28
- debug_file('finish') { state.line.must_equal 11 }
28
+ debug_file('finish') { state.line.must_equal 15 }
29
29
  end
30
30
 
31
- it 'must stop at the specified frame' do
31
+ it 'must stop after current frame is finished if 1 specified as argument' do
32
32
  enter 'finish 1'
33
- debug_file('finish') { state.line.must_equal 7 }
33
+ debug_file('finish') { state.line.must_equal 11 }
34
34
  end
35
35
 
36
- it 'must stop at the next frame if the current frame was changed' do
36
+ it 'must behave consistenly even if current frame has been changed' do
37
37
  enter 'up', 'finish'
38
38
  debug_file('finish') { state.line.must_equal 7 }
39
39
  end
@@ -27,7 +27,7 @@ class TestHelp < TestDsl::TestCase
27
27
  it 'must show an error if an undefined command is specified' do
28
28
  enter 'help foobar'
29
29
  debug_file 'help'
30
- check_error_includes 'Undefined command: "foobar". Try "help".'
30
+ check_error_includes 'Undefined command: "foobar". Try "help".'
31
31
  end
32
32
 
33
33
  it "must show a command's help" do
@@ -25,7 +25,6 @@ class InfoExample
25
25
  raise "bang"
26
26
  rescue
27
27
  end
28
-
29
28
  end
30
29
 
31
30
  class TestInfo < TestDsl::TestCase
@@ -11,9 +11,9 @@ class TestKill < TestDsl::TestCase
11
11
  debug_file('kill')
12
12
  end
13
13
 
14
- it 'must finalize interface when sending KILL signal explicitly' do
14
+ it 'must close interface when sending KILL signal explicitly' do
15
15
  Process.stubs(:kill).with('KILL', Process.pid)
16
- interface.expects(:finalize)
16
+ interface.expects(:close)
17
17
  enter 'kill KILL'
18
18
  debug_file('kill')
19
19
  end
@@ -11,243 +11,59 @@ class TestPostMortem < TestDsl::TestCase
11
11
 
12
12
  describe 'Features' do
13
13
  before { enter 'set post_mortem', 'cont' }
14
+ after { Byebug.post_mortem = false }
14
15
 
15
- it 'must enter into post-mortem mode' do
16
- debug_file('post_mortem', rescue: true) do
17
- Byebug.post_mortem?.must_equal true
16
+ it 'is rising right before exiting' do
17
+ assert_raises(RuntimeError) do
18
+ debug_file('post_mortem')
18
19
  end
19
20
  end
20
21
 
21
- it 'must stop at the correct line' do
22
- debug_file('post_mortem', rescue: true) { assert_equal 4, state.line }
23
- end
24
- end
25
-
26
- describe 'Unavailable commands' do
27
- temporary_change_hash Byebug.settings, :autoeval, false
28
-
29
- describe 'step' do
30
- it 'must not work in post-mortem mode' do
31
- enter 'set post_mortem', 'cont', 'step'
32
- debug_file 'post_mortem', rescue: true
33
- check_error_includes 'Unknown command: "step". Try "help".'
34
- end
35
- end
36
-
37
- describe 'next' do
38
- it 'must not work in post-mortem mode' do
39
- enter 'set post_mortem', 'cont', 'next'
40
- debug_file 'post_mortem', rescue: true
41
- check_error_includes 'Unknown command: "next". Try "help".'
42
- end
43
- end
44
-
45
- describe 'finish' do
46
- it 'must not work in post-mortem mode' do
47
- enter 'set post_mortem', 'cont', 'finish'
48
- debug_file 'post_mortem', rescue: true
49
- check_error_includes 'Unknown command: "finish". Try "help".'
50
- end
51
- end
52
-
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".'
22
+ it 'sets post_mortem to true' do
23
+ begin
24
+ debug_file('post_mortem')
25
+ rescue
26
+ Byebug.post_mortem?.must_equal true
59
27
  end
60
28
  end
61
29
 
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\"."
30
+ it 'stops at the correct line' do
31
+ begin
32
+ debug_file('post_mortem')
33
+ rescue
34
+ Byebug.raised_exception.__bb_line.must_equal 4
70
35
  end
71
36
  end
37
+ end
72
38
 
73
- describe 'display' do
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".'
78
- end
79
- end
39
+ describe 'Unavailable commands' do
40
+ temporary_change_hash Byebug.settings, :autoeval, false
80
41
 
81
- describe 'reload' do
82
- it 'must work in post-mortem mode' do
83
- enter 'set post_mortem', 'cont', 'reload'
84
- debug_file 'post_mortem', rescue: true
85
- check_error_includes 'Unknown command: "reload". Try "help".'
42
+ %w(step next finish break condition display reload).each do |cmd|
43
+ define_method "test_#{cmd}_is_forbidden_in_post_mortem_mode" do
44
+ enter "#{cmd}"
45
+ state.context.stubs(:dead?).returns(:true)
46
+ begin
47
+ debug_file('post_mortem')
48
+ rescue RuntimeError
49
+ check_error_includes 'Command unavailable in post mortem mode.'
50
+ end
86
51
  end
87
52
  end
88
-
89
-
90
53
  end
91
54
 
92
55
  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
98
- end
99
- end
100
-
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/)
106
- end
107
- end
108
-
109
- describe 'exit' do
110
- it 'must work in post-mortem mode' do
111
- Byebug::QuitCommand.any_instance.expects(:exit!)
112
- enter 'cont', 'exit!'
113
- debug_file 'post_mortem', rescue: true
114
- end
115
- end
116
-
117
- describe 'edit' do
118
- temporary_change_hash ENV, 'EDITOR', 'editr'
119
-
120
- it 'must work in post-mortem mode' do
121
- Byebug::Edit.any_instance.
122
- expects(:system).with("editr +2 #{fullpath('edit')}")
123
- enter 'cont', "edit #{fullpath('edit')}:2", 'cont'
124
- debug_file 'post_mortem', rescue: true
125
- end
126
- end
56
+ ['restart', 'frame', 'quit', 'edit', 'info', 'irb', 'source', 'help',
57
+ 'var class', 'list', 'method', 'kill', 'eval', 'set', 'save', 'show',
58
+ 'trace', 'thread list'].each do |cmd|
59
+ define_method "test_#{cmd}_is_permitted_in_post_mortem_mode" do
60
+ enter "#{cmd}"
61
+ class_name = cmd.gsub(/(^| )\w/) { |b| b[-1,1].upcase } + 'Command'
127
62
 
128
- describe 'info' do
129
- it 'must work in post-mortem mode' do
130
- enter 'cont', 'info line'
131
- debug_file 'post_mortem', rescue: true
132
- check_output_includes "Line 4 of \"#{__FILE__}\""
133
- end
134
- end
135
-
136
- describe 'irb' do
137
- let(:irb) { stub(context: ->{}) }
138
-
139
- it 'must work in post-mortem mode' do
140
- skip "Don't know why this is failing now..."
141
- irb.stubs(:eval_input).throws(:IRB_EXIT, :cont)
142
- enter 'cont', 'break 11', 'irb'
143
- debug_file('post_mortem', rescue: true) { state.line.must_equal 11 }
144
- end
145
- end
146
-
147
- describe 'source' do
148
- let(:filename) { 'source_example.txt' }
149
-
150
- before { File.open(filename, 'w') { |f| f.puts 'frame' } }
151
-
152
- it 'must work in post-mortem mode' do
153
- enter 'cont', "so #{filename}"
154
- debug_file('post_mortem', rescue: true)
155
- check_output_includes(/--> #0 PostMortemExample\.a\s+at #{__FILE__}:4/)
156
- end
157
- end
158
-
159
- describe 'help' do
160
- it 'must work in post-mortem mode' do
161
- enter 'cont', 'help'
162
- debug_file 'post_mortem', rescue: true
163
- check_output_includes 'Available commands:'
164
- end
165
- end
166
-
167
- describe 'var' do
168
- it 'must work in post-mortem mode' do
169
- enter 'cont', 'var local'
170
- debug_file 'post_mortem', rescue: true
171
- check_output_includes 'x => nil', 'z => 4'
172
- end
173
- end
174
-
175
- describe 'list' do
176
- it 'must work in post-mortem mode' do
177
- enter 'cont'
178
- debug_file 'post_mortem', rescue: true
179
- check_output_includes "[1, 10] in #{__FILE__}"
180
- end
181
- end
182
-
183
- describe 'method' do
184
- it 'must work in post-mortem mode' do
185
- enter 'cont', 'm i self'
186
- debug_file 'post_mortem', rescue: true
187
- check_output_includes(/to_s/)
188
- end
189
- end
190
-
191
- describe 'kill' do
192
- it 'must work in post-mortem mode' do
193
- Process.expects(:kill).with('USR1', Process.pid)
194
- enter 'cont', 'kill USR1'
195
- debug_file 'post_mortem', rescue: true
196
- end
197
- end
198
-
199
- describe 'eval' do
200
- it 'must work in post-mortem mode' do
201
- enter 'cont', 'eval 2 + 2'
202
- debug_file 'post_mortem', rescue: true
203
- check_output_includes '4'
204
- end
205
- end
206
-
207
- describe 'set' do
208
- temporary_change_hash Byebug.settings, :autolist, 0
209
-
210
- it 'must work in post-mortem mode' do
211
- enter 'cont', 'set autolist on'
212
- debug_file 'post_mortem', rescue: true
213
- check_output_includes 'autolist is on.'
214
- end
215
- end
216
-
217
- describe 'save' do
218
- let(:file_name) { 'save_output.txt' }
219
- let(:file_contents) { File.read(file_name) }
220
- after { File.delete(file_name) }
221
-
222
- it 'must work in post-mortem mode' do
223
- enter 'cont', "save #{file_name}"
224
- debug_file 'post_mortem', rescue: true
225
- file_contents.must_include 'set autoirb off'
226
- end
227
- end
228
-
229
- describe 'show' do
230
- it 'must work in post-mortem mode' do
231
- enter 'cont', 'show autolist'
232
- debug_file 'post_mortem', rescue: true
233
- check_output_includes 'autolist is on.'
234
- end
235
- end
236
-
237
- describe 'trace' do
238
- it 'must work in post-mortem mode' do
239
- enter 'cont', 'trace on'
240
- debug_file 'post_mortem', rescue: true
241
- check_output_includes 'line tracing is on.'
242
- end
243
- end
244
-
245
- describe 'thread' do
246
- it "must work in post-mortem mode" do
247
- enter 'cont', 'thread list'
248
- debug_file 'post_mortem', rescue: true
249
- check_output_includes(/\+ \d+ #<Thread:(\S+) run/)
63
+ Byebug.const_get(class_name).any_instance.stubs(:execute)
64
+ assert_raises(RuntimeError) { debug_file('post_mortem') }
250
65
  end
251
66
  end
252
67
  end
68
+
253
69
  end