byebug 3.1.2 → 3.2.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 (97) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +4 -2
  3. data/CHANGELOG.md +15 -0
  4. data/GUIDE.md +17 -35
  5. data/Gemfile +8 -5
  6. data/LICENSE +1 -1
  7. data/README.md +10 -22
  8. data/Rakefile +1 -1
  9. data/ext/byebug/byebug.c +3 -2
  10. data/lib/byebug.rb +3 -38
  11. data/lib/byebug/commands/break.rb +83 -0
  12. data/lib/byebug/commands/catchpoint.rb +0 -1
  13. data/lib/byebug/commands/condition.rb +10 -6
  14. data/lib/byebug/commands/continue.rb +3 -6
  15. data/lib/byebug/commands/delete.rb +38 -0
  16. data/lib/byebug/commands/edit.rb +0 -2
  17. data/lib/byebug/commands/enable.rb +7 -8
  18. data/lib/byebug/commands/finish.rb +0 -2
  19. data/lib/byebug/commands/frame.rb +13 -15
  20. data/lib/byebug/commands/help.rb +1 -3
  21. data/lib/byebug/commands/history.rb +3 -3
  22. data/lib/byebug/commands/info.rb +4 -13
  23. data/lib/byebug/commands/interrupt.rb +25 -0
  24. data/lib/byebug/commands/kill.rb +0 -2
  25. data/lib/byebug/commands/list.rb +2 -4
  26. data/lib/byebug/commands/method.rb +2 -8
  27. data/lib/byebug/commands/quit.rb +0 -2
  28. data/lib/byebug/commands/reload.rb +2 -15
  29. data/lib/byebug/commands/repl.rb +0 -3
  30. data/lib/byebug/commands/{control.rb → restart.rb} +2 -26
  31. data/lib/byebug/commands/save.rb +0 -1
  32. data/lib/byebug/commands/set.rb +4 -7
  33. data/lib/byebug/commands/show.rb +0 -3
  34. data/lib/byebug/commands/source.rb +0 -3
  35. data/lib/byebug/commands/stepping.rb +3 -4
  36. data/lib/byebug/commands/trace.rb +0 -1
  37. data/lib/byebug/commands/variables.rb +3 -4
  38. data/lib/byebug/context.rb +0 -1
  39. data/lib/byebug/helper.rb +23 -0
  40. data/lib/byebug/interfaces/script_interface.rb +1 -1
  41. data/lib/byebug/processors/command_processor.rb +9 -9
  42. data/lib/byebug/remote.rb +2 -2
  43. data/lib/byebug/setting.rb +3 -1
  44. data/lib/byebug/settings/autoeval.rb +3 -1
  45. data/lib/byebug/settings/autoirb.rb +3 -1
  46. data/lib/byebug/settings/autolist.rb +3 -1
  47. data/lib/byebug/settings/autoreload.rb +1 -3
  48. data/lib/byebug/settings/autosave.rb +1 -3
  49. data/lib/byebug/settings/callstyle.rb +2 -4
  50. data/lib/byebug/settings/fullpath.rb +1 -3
  51. data/lib/byebug/settings/histfile.rb +1 -3
  52. data/lib/byebug/settings/histsize.rb +0 -4
  53. data/lib/byebug/settings/listsize.rb +1 -3
  54. data/lib/byebug/settings/post_mortem.rb +14 -1
  55. data/lib/byebug/settings/width.rb +1 -17
  56. data/lib/byebug/version.rb +1 -1
  57. data/test/break_test.rb +376 -0
  58. data/test/condition_test.rb +82 -0
  59. data/test/continue_test.rb +27 -30
  60. data/test/debugger_alias_test.rb +4 -4
  61. data/test/delete_test.rb +26 -0
  62. data/test/display_test.rb +80 -102
  63. data/test/edit_test.rb +28 -31
  64. data/test/eval_test.rb +50 -80
  65. data/test/finish_test.rb +23 -23
  66. data/test/frame_test.rb +172 -186
  67. data/test/help_test.rb +27 -37
  68. data/test/history_test.rb +32 -41
  69. data/test/info_test.rb +198 -230
  70. data/test/interrupt_test.rb +17 -36
  71. data/test/irb_test.rb +47 -0
  72. data/test/kill_test.rb +19 -19
  73. data/test/list_test.rb +126 -133
  74. data/test/method_test.rb +21 -54
  75. data/test/post_mortem_test.rb +44 -46
  76. data/test/pry_test.rb +42 -0
  77. data/test/quit_test.rb +17 -15
  78. data/test/reload_test.rb +23 -28
  79. data/test/restart_test.rb +35 -63
  80. data/test/save_test.rb +46 -62
  81. data/test/set_test.rb +93 -144
  82. data/test/show_test.rb +50 -71
  83. data/test/source_test.rb +23 -26
  84. data/test/stepping_test.rb +125 -153
  85. data/test/support/matchers.rb +1 -6
  86. data/test/support/test_interface.rb +1 -1
  87. data/test/support/{test_dsl.rb → utils.rb} +17 -64
  88. data/test/test_helper.rb +25 -7
  89. data/test/thread_test.rb +101 -89
  90. data/test/trace_test.rb +48 -85
  91. data/test/variables_test.rb +43 -80
  92. metadata +18 -13
  93. data/lib/byebug/commands/breakpoints.rb +0 -137
  94. data/lib/byebug/commands/skip.rb +0 -30
  95. data/test/breakpoints_test.rb +0 -474
  96. data/test/conditions_test.rb +0 -82
  97. data/test/repl_test.rb +0 -75
@@ -1,85 +1,52 @@
1
- module MethodTest
2
- class Example
1
+ module Byebug
2
+ class MethodExample
3
3
  def initialize
4
4
  @a = 'b'
5
5
  @c = 'd'
6
6
  end
7
+
7
8
  def self.foo
8
- "asdf"
9
+ 'asdf'
9
10
  end
11
+
10
12
  def bla
11
- "asdf"
13
+ 'asdf'
12
14
  end
13
15
  end
14
16
 
15
- class MethodTestCase < TestDsl::TestCase
16
- before do
17
- Byebug::Setting[:autolist] = false
17
+ class MethodTestCase < TestCase
18
+ def setup
18
19
  @example = -> do
19
20
  byebug
20
- a = Example.new
21
+ a = MethodExample.new
21
22
  a.bla
22
23
  end
23
- end
24
24
 
25
- after do
26
- Byebug::Setting[:autolist] = true
25
+ super
27
26
  end
28
27
 
29
- describe 'show instance method of a class' do
30
- before { enter 'break 4', 'cont' }
31
-
32
- it 'must show using full command name' do
33
- enter 'method Example'
28
+ %w(method m).each do |cmd_alias|
29
+ define_method(:"test_#{cmd_alias}_shows_instance_methods_of_a_class") do
30
+ enter 'break 4', 'cont', "#{cmd_alias} MethodExample"
34
31
  debug_proc(@example)
35
32
  check_output_includes(/bla/)
36
33
  check_output_doesnt_include(/foo/)
37
34
  end
38
-
39
- it 'must show using shortcut' do
40
- enter 'm Example'
41
- debug_proc(@example)
42
- check_output_includes(/bla/)
43
- end
44
-
45
- it 'must show an error if specified object is not a class or module' do
46
- enter 'm a'
47
- debug_proc(@example)
48
- check_output_includes 'Should be Class/Module: a'
49
- end
50
35
  end
51
36
 
52
- describe 'show methods of an object' do
53
- before { enter 'break 21', 'cont' }
37
+ def test_m_shows_an_error_if_specified_object_is_not_a_class_or_module
38
+ enter 'm a'
39
+ debug_proc(@example)
40
+ check_output_includes 'Should be Class/Module: a'
41
+ end
54
42
 
55
- it 'must show using full command name' do
56
- enter 'method instance a'
43
+ ['method instance', 'm i'].each do |cmd_alias|
44
+ define_method(:"test_#{cmd_alias}_shows_methods_of_object") do
45
+ enter 'break 22', 'cont', "#{cmd_alias} a"
57
46
  debug_proc(@example)
58
47
  check_output_includes(/bla/)
59
48
  check_output_doesnt_include(/foo/)
60
49
  end
61
-
62
- it 'must show using shortcut' do
63
- enter 'm i a'
64
- debug_proc(@example)
65
- check_output_includes(/bla/)
66
- end
67
- end
68
-
69
- describe 'show instance variables of an object' do
70
- before { enter 'break 21', 'cont' }
71
-
72
- it 'must show using full name command' do
73
- enter 'method iv a'
74
- debug_proc(@example)
75
- check_output_includes '@a = "b"', '@c = "d"'
76
- end
77
-
78
- it 'must show using shortcut' do
79
- enter 'm iv a'
80
- debug_proc(@example)
81
- check_output_includes '@a = "b"', '@c = "d"'
82
- end
83
50
  end
84
51
  end
85
52
  end
@@ -1,5 +1,5 @@
1
- module PostMortemTest
2
- class Example
1
+ module Byebug
2
+ class PostMortemExample
3
3
  def a
4
4
  z = 4
5
5
  raise 'blabla'
@@ -8,69 +8,67 @@ module PostMortemTest
8
8
  end
9
9
  end
10
10
 
11
- class PostMortemTestCase < TestDsl::TestCase
12
- before do
11
+ class PostMortemTestCase < TestCase
12
+ def setup
13
13
  @example = -> do
14
14
  byebug
15
- c = Example.new
15
+ c = PostMortemExample.new
16
16
  c.a
17
17
  end
18
+
19
+ super
18
20
  end
19
21
 
20
- describe 'Features' do
21
- before { enter 'set post_mortem', 'cont' }
22
- after { Byebug.post_mortem = false }
22
+ def teardown
23
+ Byebug.post_mortem = false
24
+ end
23
25
 
24
- it 'is rising right before exiting' do
25
- assert_raises(RuntimeError) do
26
- debug_proc(@example)
27
- end
26
+ def test_rises_before_exit_in_post_mortem_mode
27
+ enter 'set post_mortem', 'cont'
28
+ assert_raises(RuntimeError) do
29
+ debug_proc(@example)
28
30
  end
31
+ end
29
32
 
30
- it 'sets post_mortem to true' do
31
- begin
32
- debug_proc(@example)
33
- rescue
34
- Byebug.post_mortem?.must_equal true
35
- end
33
+ def test_post_mortem_mode_sets_post_mortem_flag_to_true
34
+ enter 'set post_mortem', 'cont'
35
+ begin
36
+ debug_proc(@example)
37
+ rescue
38
+ assert_equal true, Byebug.post_mortem?
36
39
  end
40
+ end
37
41
 
38
- it 'stops at the correct line' do
39
- begin
40
- debug_proc(@example)
41
- rescue
42
- Byebug.raised_exception.__bb_line.must_equal 5
43
- end
42
+ def test_execution_is_stop_at_the_correct_line_after_exception
43
+ enter 'set post_mortem', 'cont'
44
+ begin
45
+ debug_proc(@example)
46
+ rescue
47
+ assert_equal 5, Byebug.raised_exception.__bb_line
44
48
  end
45
49
  end
46
50
 
47
- describe 'Unavailable commands' do
48
- temporary_change_hash Byebug::Setting, :autoeval, false
49
-
50
- %w(step next finish break condition display reload).each do |cmd|
51
- define_method "test_#{cmd}_is_forbidden_in_post_mortem_mode" do
52
- enter "#{cmd}"
53
- state.context.stubs(:dead?).returns(:true)
54
- begin
55
- debug_proc(@example)
56
- rescue RuntimeError
57
- check_error_includes 'Command unavailable in post mortem mode.'
58
- end
51
+ %w(step next finish break condition display reload).each do |cmd|
52
+ define_method "test_#{cmd}_is_forbidden_in_post_mortem_mode" do
53
+ enter 'set noautoeval', cmd
54
+ state.context.stubs(:dead?).returns(:true)
55
+ begin
56
+ debug_proc(@example)
57
+ rescue RuntimeError
58
+ check_error_includes 'Command unavailable in post mortem mode.'
59
59
  end
60
60
  end
61
61
  end
62
62
 
63
- describe 'Available commands' do
64
- ['restart', 'frame', 'quit', 'edit', 'info', 'irb', 'source', 'help',
65
- 'var class', 'list', 'method', 'kill', 'eval', 'set', 'save', 'show',
66
- 'trace', 'thread list'].each do |cmd|
67
- define_method "test_#{cmd}_is_permitted_in_post_mortem_mode" do
68
- enter "#{cmd}"
69
- class_name = cmd.gsub(/(^| )\w/) { |b| b[-1,1].upcase } + 'Command'
63
+ ['restart', 'frame', 'quit', 'edit', 'info', 'irb', 'source', 'help',
64
+ 'var class', 'list', 'method', 'kill', 'eval', 'set', 'save', 'show',
65
+ 'trace', 'thread list'].each do |cmd|
66
+ define_method "test_#{cmd}_is_permitted_in_post_mortem_mode" do
67
+ enter "#{cmd}"
68
+ class_name = cmd.gsub(/(^| )\w/) { |b| b[-1,1].upcase } + 'Command'
70
69
 
71
- Byebug.const_get(class_name).any_instance.stubs(:execute)
72
- assert_raises(RuntimeError) { debug_proc(@example) }
73
- end
70
+ Byebug.const_get(class_name).any_instance.stubs(:execute)
71
+ assert_raises(RuntimeError) { debug_proc(@example) }
74
72
  end
75
73
  end
76
74
  end
@@ -0,0 +1,42 @@
1
+ begin
2
+ require 'pry'
3
+ has_pry = true
4
+ rescue LoadError
5
+ has_pry = false
6
+ end
7
+
8
+ module Byebug
9
+ class PryTestCase < TestCase
10
+ def setup
11
+ @example = -> do
12
+ byebug
13
+ a = 2
14
+ a = 3
15
+ a = 4
16
+ a = 5
17
+ a = 6
18
+ end
19
+
20
+ super
21
+
22
+ interface.stubs(:kind_of?).with(LocalInterface).returns(true)
23
+ PryCommand.any_instance.expects(:pry)
24
+ end
25
+
26
+ def test_pry_supports_next_command
27
+ skip 'TODO'
28
+ end
29
+
30
+ def test_pry_supports_step_command
31
+ skip 'TODO'
32
+ end
33
+
34
+ def test_pry_supports_cont_command
35
+ skip 'TODO'
36
+ end
37
+
38
+ def test_autopry_calls_pry_automatically_after_every_stop
39
+ skip 'TODO'
40
+ end
41
+ end
42
+ end if has_pry
@@ -1,49 +1,51 @@
1
- module QuitTest
2
- class QuitTestCase < TestDsl::TestCase
3
- before do
1
+ module Byebug
2
+ class QuitTestCase < TestCase
3
+ def setup
4
4
  @example = -> do
5
5
  byebug
6
6
  Object.new
7
7
  end
8
+
9
+ super
8
10
  end
9
11
 
10
- it 'must quit if user confirmed' do
11
- Byebug::QuitCommand.any_instance.expects(:exit!)
12
+ def test_finishes_byebug_if_user_confirms
13
+ QuitCommand.any_instance.expects(:exit!)
12
14
  enter 'quit', 'y'
13
15
  debug_proc(@example)
14
16
  check_output_includes 'Really quit? (y/n)', interface.confirm_queue
15
17
  end
16
18
 
17
- it 'must not quit if user didn\'t confirm' do
18
- Byebug::QuitCommand.any_instance.expects(:exit!).never
19
+ def test_does_not_quit_if_user_did_not_confirm
20
+ QuitCommand.any_instance.expects(:exit!).never
19
21
  enter 'quit', 'n'
20
22
  debug_proc(@example)
21
23
  check_output_includes 'Really quit? (y/n)', interface.confirm_queue
22
24
  end
23
25
 
24
- it 'must quit immediatly if used with !' do
25
- Byebug::QuitCommand.any_instance.expects(:exit!)
26
+ def test_quits_inmediately_if_used_with_bang
27
+ QuitCommand.any_instance.expects(:exit!)
26
28
  enter 'quit!'
27
29
  debug_proc(@example)
28
30
  check_output_doesnt_include 'Really quit? (y/n)', interface.confirm_queue
29
31
  end
30
32
 
31
- it 'must quit immediatly if used with "unconditionally"' do
32
- Byebug::QuitCommand.any_instance.expects(:exit!)
33
+ def test_quits_inmediately_if_used_with_unconditionally
34
+ QuitCommand.any_instance.expects(:exit!)
33
35
  enter 'quit unconditionally'
34
36
  debug_proc(@example)
35
37
  check_output_doesnt_include 'Really quit? (y/n)', interface.confirm_queue
36
38
  end
37
39
 
38
- it 'must close interface before quitting' do
39
- Byebug::QuitCommand.any_instance.stubs(:exit!)
40
+ def test_closes_interface_before_quitting
41
+ QuitCommand.any_instance.stubs(:exit!)
40
42
  interface.expects(:close)
41
43
  enter 'quit!'
42
44
  debug_proc(@example)
43
45
  end
44
46
 
45
- it 'must quit if used "exit" alias' do
46
- Byebug::QuitCommand.any_instance.expects(:exit!)
47
+ def test_quits_if_used_with_exit_alias
48
+ QuitCommand.any_instance.expects(:exit!)
47
49
  enter 'exit!'
48
50
  debug_proc(@example)
49
51
  end
@@ -1,6 +1,6 @@
1
- module ReloadTest
2
- class ReloadTestCase < TestDsl::TestCase
3
- before do
1
+ module Byebug
2
+ class ReloadTestCase < TestCase
3
+ def setup
4
4
  @example = -> do
5
5
  byebug
6
6
  a = 6
@@ -9,36 +9,31 @@ module ReloadTest
9
9
  a = 9
10
10
  a = 10
11
11
  end
12
- end
13
-
14
- describe 'autoreloading' do
15
- after { Byebug::Setting[:autoreload] = true }
16
12
 
17
- it 'must notify that automatic reloading is on by default' do
18
- enter 'reload'
19
- debug_proc(@example)
20
- check_output_includes \
21
- 'Source code is reloaded. Automatic reloading is on.'
22
- end
13
+ super
14
+ end
23
15
 
24
- it 'must notify that automatic reloading is off if setting changed' do
25
- enter 'set noautoreload', 'reload'
26
- debug_proc(@example)
27
- check_output_includes \
28
- 'Source code is reloaded. Automatic reloading is off.'
29
- end
16
+ def test_reload_notifies_about_default_setting
17
+ enter 'reload'
18
+ debug_proc(@example)
19
+ check_output_includes \
20
+ 'Source code was reloaded. Automatic reloading is on'
30
21
  end
31
22
 
32
- describe 'reloading' do
33
- after { change_line_in_file(__FILE__, 8, ' a = 8') }
23
+ def test_reload_notifies_that_automatic_reloading_is_off_is_setting_changed
24
+ enter 'set noautoreload', 'reload'
25
+ debug_proc(@example)
26
+ check_output_includes \
27
+ 'Source code was reloaded. Automatic reloading is off'
28
+ end
34
29
 
35
- it 'must reload the code' do
36
- enter 'break 7', 'cont', 'l 8-8',
37
- -> { change_line_in_file(__FILE__, 8, ' a = 100'); 'reload' },
38
- 'l 8-8'
39
- debug_proc(@example)
40
- check_output_includes '8: a = 100'
41
- end
30
+ def test_reload_properly_reloads_source_code
31
+ enter 'break 7', 'cont', 'l 8-8',
32
+ -> { change_line_in_file(__FILE__, 8, ' a = 100'); 'reload' },
33
+ 'l 8-8'
34
+ debug_proc(@example)
35
+ check_output_includes '8: a = 100'
36
+ change_line_in_file(__FILE__, 8, ' a = 8')
42
37
  end
43
38
  end
44
39
  end
@@ -1,90 +1,62 @@
1
- module RestartTest
2
- class Example
1
+ module Byebug
2
+ class RestartExample
3
3
  def concat_args(a, b, c)
4
4
  a.to_s + b.to_s + c.to_s
5
5
  end
6
6
  end
7
7
 
8
- class RestartTestCase < TestDsl::TestCase
9
- before do
8
+ class RestartTestCase < TestCase
9
+ def setup
10
10
  @example = -> do
11
11
  byebug
12
12
  a = ARGV[0]
13
13
  b = ARGV[1]
14
14
  c = ARGV[2]
15
- Example.new.concat_args(a, b, c)
15
+ RestartExample.new.concat_args(a, b, c)
16
16
  end
17
+
18
+ super
17
19
  end
18
20
 
19
21
  def must_restart(cmd = nil)
20
- expectation = Byebug::RestartCommand.any_instance.expects(:exec)
22
+ expectation = RestartCommand.any_instance.expects(:exec)
21
23
  expectation = expectation.with(cmd) if cmd
22
24
  expectation
23
25
  end
24
26
 
25
- describe 'usual restarting' do
26
- temporary_change_const Byebug, 'BYEBUG_SCRIPT', 'byebug_script'
27
-
28
- it 'must be restarted with arguments' do
29
- cmd = "#{Byebug::BYEBUG_SCRIPT} #{Byebug::PROG_SCRIPT} 1 2 3"
30
- must_restart(cmd)
31
- enter 'restart 1 2 3'
32
- debug_proc(@example)
33
- check_output_includes "Re exec'ing:\n\t#{cmd}"
34
- end
27
+ def test_restarts_with_manual_arguments
28
+ force_set_const(Byebug, 'BYEBUG_SCRIPT', 'byebug_script')
29
+ cmd = "#{BYEBUG_SCRIPT} #{PROG_SCRIPT} 1 2 3"
30
+ must_restart(cmd)
31
+ enter 'restart 1 2 3'
32
+ debug_proc(@example)
33
+ check_output_includes "Re exec'ing:\n\t#{cmd}"
35
34
  end
36
35
 
37
- describe 'no script specified' do
38
- temporary_change_const Byebug, 'PROG_SCRIPT', :__undefined__
39
-
40
- it 'must not restart and show error messages instead' do
41
- must_restart.never
42
- enter 'restart'
43
- debug_proc(@example)
44
- check_error_includes 'Don\'t know name of debugged program'
45
- end
36
+ def test_does_not_restart_when_no_script_specified
37
+ force_unset_const(Byebug, 'PROG_SCRIPT')
38
+ must_restart.never
39
+ enter 'restart'
40
+ debug_proc(@example)
41
+ check_error_includes "Don't know name of debugged program"
46
42
  end
47
43
 
48
- describe 'no script at the specified path' do
49
- temporary_change_const Byebug, 'PROG_SCRIPT', 'blabla'
50
-
51
- it 'must not restart' do
52
- must_restart.never
53
- enter 'restart'
54
- debug_proc(@example)
55
- end
56
-
57
- it 'must show an error message' do
58
- enter 'restart'
59
- debug_proc(@example)
60
- check_error_includes 'Ruby program blabla doesn\'t exist'
61
- end
44
+ def test_does_not_restart_when_script_specified_does_not_exist
45
+ force_set_const(Byebug, 'PROG_SCRIPT', 'blabla')
46
+ must_restart.never
47
+ enter 'restart'
48
+ debug_proc(@example)
49
+ check_error_includes 'Ruby program blabla doesn\'t exist'
62
50
  end
63
51
 
64
- describe 'when no runner script specified' do
65
- temporary_change_const Byebug, 'BYEBUG_SCRIPT', :__undefined__
66
-
67
- describe 'restarting' do
68
- before do
69
- must_restart
70
- enter 'restart'
71
- end
72
-
73
- it 'must restart anyways' do
74
- debug_proc(@example)
75
- end
76
-
77
- it 'must show a warning message' do
78
- debug_proc(@example)
79
- check_output_includes 'Byebug was not called from the outset...'
80
- end
81
-
82
- it 'must show a warning message when prog script is not executable' do
83
- debug_proc(@example)
84
- check_output_includes "Ruby program #{Byebug::PROG_SCRIPT} not " \
85
- "executable... We'll wrap it in a ruby call"
86
- end
87
- end
52
+ def test_still_restarts_when_byebug_attached_to_running_program
53
+ force_unset_const(Byebug, 'BYEBUG_SCRIPT')
54
+ must_restart
55
+ enter 'restart'
56
+ debug_proc(@example)
57
+ check_output_includes 'Byebug was not called from the outset...'
58
+ check_output_includes "Ruby program #{PROG_SCRIPT} not executable... " \
59
+ "We'll wrap it in a ruby call"
88
60
  end
89
61
  end
90
62
  end