byebug 3.5.1 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -1
  3. data/.rubocop.yml +18 -1
  4. data/.travis.yml +21 -1
  5. data/CHANGELOG.md +356 -308
  6. data/CONTRIBUTING.md +31 -15
  7. data/GUIDE.md +859 -475
  8. data/Gemfile +8 -10
  9. data/LICENSE +1 -1
  10. data/README.md +41 -45
  11. data/Rakefile +30 -28
  12. data/byebug.gemspec +18 -18
  13. data/ext/byebug/breakpoint.c +88 -75
  14. data/ext/byebug/byebug.c +253 -252
  15. data/ext/byebug/byebug.h +53 -53
  16. data/ext/byebug/context.c +188 -159
  17. data/ext/byebug/extconf.rb +9 -6
  18. data/ext/byebug/locker.c +53 -11
  19. data/ext/byebug/threads.c +137 -39
  20. data/lib/byebug/attacher.rb +7 -2
  21. data/lib/byebug/breakpoint.rb +30 -0
  22. data/lib/byebug/command.rb +36 -32
  23. data/lib/byebug/commands/break.rb +49 -48
  24. data/lib/byebug/commands/catch.rb +64 -0
  25. data/lib/byebug/commands/condition.rb +13 -9
  26. data/lib/byebug/commands/continue.rb +8 -4
  27. data/lib/byebug/commands/delete.rb +10 -4
  28. data/lib/byebug/commands/display.rb +33 -25
  29. data/lib/byebug/commands/edit.rb +18 -13
  30. data/lib/byebug/commands/enable_disable.rb +26 -24
  31. data/lib/byebug/commands/eval.rb +77 -35
  32. data/lib/byebug/commands/finish.rb +9 -5
  33. data/lib/byebug/commands/frame.rb +66 -125
  34. data/lib/byebug/commands/help.rb +14 -21
  35. data/lib/byebug/commands/history.rb +5 -1
  36. data/lib/byebug/commands/info.rb +41 -106
  37. data/lib/byebug/commands/interrupt.rb +6 -2
  38. data/lib/byebug/commands/irb.rb +5 -2
  39. data/lib/byebug/commands/kill.rb +6 -2
  40. data/lib/byebug/commands/list.rb +21 -14
  41. data/lib/byebug/commands/method.rb +17 -9
  42. data/lib/byebug/commands/pry.rb +13 -3
  43. data/lib/byebug/commands/quit.rb +10 -5
  44. data/lib/byebug/commands/restart.rb +12 -19
  45. data/lib/byebug/commands/save.rb +10 -6
  46. data/lib/byebug/commands/set.rb +15 -14
  47. data/lib/byebug/commands/show.rb +8 -8
  48. data/lib/byebug/commands/source.rb +14 -8
  49. data/lib/byebug/commands/stepping.rb +15 -29
  50. data/lib/byebug/commands/threads.rb +73 -49
  51. data/lib/byebug/commands/tracevar.rb +56 -0
  52. data/lib/byebug/commands/undisplay.rb +8 -4
  53. data/lib/byebug/commands/untracevar.rb +38 -0
  54. data/lib/byebug/commands/var.rb +107 -0
  55. data/lib/byebug/context.rb +78 -42
  56. data/lib/byebug/core.rb +78 -40
  57. data/lib/byebug/helper.rb +58 -42
  58. data/lib/byebug/history.rb +12 -1
  59. data/lib/byebug/interface.rb +91 -11
  60. data/lib/byebug/interfaces/local_interface.rb +12 -19
  61. data/lib/byebug/interfaces/remote_interface.rb +12 -15
  62. data/lib/byebug/interfaces/script_interface.rb +14 -18
  63. data/lib/byebug/interfaces/test_interface.rb +54 -0
  64. data/lib/byebug/printers/base.rb +64 -0
  65. data/lib/byebug/printers/plain.rb +53 -0
  66. data/lib/byebug/processor.rb +20 -1
  67. data/lib/byebug/processors/command_processor.rb +57 -172
  68. data/lib/byebug/processors/control_command_processor.rb +16 -43
  69. data/lib/byebug/remote.rb +13 -7
  70. data/lib/byebug/runner.rb +102 -54
  71. data/lib/byebug/setting.rb +45 -68
  72. data/lib/byebug/settings/autoeval.rb +2 -0
  73. data/lib/byebug/settings/autoirb.rb +3 -0
  74. data/lib/byebug/settings/autolist.rb +3 -0
  75. data/lib/byebug/settings/autosave.rb +2 -0
  76. data/lib/byebug/settings/basename.rb +2 -0
  77. data/lib/byebug/settings/callstyle.rb +2 -0
  78. data/lib/byebug/settings/fullpath.rb +2 -0
  79. data/lib/byebug/settings/histfile.rb +2 -0
  80. data/lib/byebug/settings/histsize.rb +2 -0
  81. data/lib/byebug/settings/linetrace.rb +2 -0
  82. data/lib/byebug/settings/listsize.rb +2 -0
  83. data/lib/byebug/settings/post_mortem.rb +7 -2
  84. data/lib/byebug/settings/stack_on_error.rb +2 -0
  85. data/lib/byebug/settings/verbose.rb +2 -0
  86. data/lib/byebug/settings/width.rb +2 -0
  87. data/lib/byebug/state.rb +12 -0
  88. data/lib/byebug/states/control_state.rb +26 -0
  89. data/lib/byebug/states/regular_state.rb +178 -0
  90. data/lib/byebug/version.rb +1 -1
  91. metadata +24 -109
  92. data/lib/byebug/commands/catchpoint.rb +0 -53
  93. data/lib/byebug/commands/reload.rb +0 -29
  94. data/lib/byebug/commands/trace.rb +0 -50
  95. data/lib/byebug/commands/variables.rb +0 -206
  96. data/lib/byebug/options.rb +0 -46
  97. data/lib/byebug/settings/autoreload.rb +0 -12
  98. data/lib/byebug/settings/forcestep.rb +0 -14
  99. data/lib/byebug/settings/testing.rb +0 -12
  100. data/lib/byebug/settings/tracing_plus.rb +0 -11
  101. data/test/commands/break_test.rb +0 -364
  102. data/test/commands/condition_test.rb +0 -85
  103. data/test/commands/continue_test.rb +0 -47
  104. data/test/commands/delete_test.rb +0 -26
  105. data/test/commands/display_test.rb +0 -37
  106. data/test/commands/edit_test.rb +0 -52
  107. data/test/commands/eval_test.rb +0 -89
  108. data/test/commands/finish_test.rb +0 -74
  109. data/test/commands/frame_test.rb +0 -223
  110. data/test/commands/help_test.rb +0 -66
  111. data/test/commands/history_test.rb +0 -61
  112. data/test/commands/info_test.rb +0 -238
  113. data/test/commands/interrupt_test.rb +0 -45
  114. data/test/commands/irb_test.rb +0 -28
  115. data/test/commands/kill_test.rb +0 -50
  116. data/test/commands/list_test.rb +0 -174
  117. data/test/commands/method_test.rb +0 -52
  118. data/test/commands/post_mortem_test.rb +0 -71
  119. data/test/commands/pry_test.rb +0 -26
  120. data/test/commands/quit_test.rb +0 -53
  121. data/test/commands/reload_test.rb +0 -39
  122. data/test/commands/restart_test.rb +0 -46
  123. data/test/commands/save_test.rb +0 -67
  124. data/test/commands/set_test.rb +0 -140
  125. data/test/commands/show_test.rb +0 -76
  126. data/test/commands/source_test.rb +0 -46
  127. data/test/commands/stepping_test.rb +0 -192
  128. data/test/commands/thread_test.rb +0 -164
  129. data/test/commands/trace_test.rb +0 -71
  130. data/test/commands/undisplay_test.rb +0 -75
  131. data/test/commands/variables_test.rb +0 -105
  132. data/test/debugger_alias_test.rb +0 -7
  133. data/test/runner_test.rb +0 -150
  134. data/test/support/matchers.rb +0 -65
  135. data/test/support/test_interface.rb +0 -59
  136. data/test/support/utils.rb +0 -122
  137. data/test/test_helper.rb +0 -58
@@ -1,85 +0,0 @@
1
- module Byebug
2
- class ConditionTestCase < TestCase
3
- def setup
4
- @example = -> do
5
- byebug
6
- b = 5
7
- c = b + 5
8
- c = Object.new
9
- end
10
-
11
- super
12
- end
13
-
14
- def test_setting_condition_w_short_syntax_assigns_expression_to_breakpoint
15
- enter 'break 7', -> { "cond #{Breakpoint.first.id} b == 5" }
16
-
17
- debug_proc(@example) { assert_equal 'b == 5', Breakpoint.first.expr }
18
- end
19
-
20
- def test_setting_condition_w_full_syntax_assigns_expression_to_breakpoint
21
- enter 'break 7', -> { "condition #{Breakpoint.first.id} b == 5" }
22
-
23
- debug_proc(@example) { assert_equal 'b == 5', Breakpoint.first.expr }
24
- end
25
-
26
- def test_setting_condition_w_wrong_syntax_does_not_enable_breakpoint
27
- enter 'break 7', -> { "disable #{Breakpoint.first.id}" },
28
- -> { "cond #{Breakpoint.first.id} b ==" }
29
-
30
- debug_proc(@example) { assert_equal false, Breakpoint.first.enabled? }
31
- end
32
-
33
- def test_setting_condition_w_wrong_syntax_shows_error
34
- enter 'break 7', -> { "disable #{Breakpoint.first.id}" },
35
- -> { "cond #{Breakpoint.first.id} b ==" }
36
-
37
- debug_proc(@example)
38
- check_error_includes \
39
- 'Incorrect expression "b ==", breakpoint not changed'
40
- end
41
-
42
- def test_execution_stops_when_condition_is_true
43
- enter 'break 7', -> { "cond #{Breakpoint.first.id} b == 5" }, 'cont'
44
-
45
- debug_proc(@example) { assert_equal 7, state.line }
46
- end
47
-
48
- def test_execution_does_not_stop_when_condition_is_false
49
- enter 'b 7', 'b 8', -> { "cond #{Breakpoint.first.id} b == 3" }, 'cont'
50
-
51
- debug_proc(@example) { assert_equal 8, state.line }
52
- end
53
-
54
- def test_conditions_with_wrong_syntax_are_ignored
55
- enter 'b 7', 'b 8', -> { "cond #{Breakpoint.first.id} b ==" }, 'cont'
56
-
57
- debug_proc(@example) { assert_equal 7, state.line }
58
- end
59
-
60
- def test_empty_condition_means_removing_any_conditions
61
- enter 'b 7 if b == 3', 'b 8', -> { "cond #{Breakpoint.first.id}" }, 'c'
62
-
63
- debug_proc(@example) do
64
- assert_nil Breakpoint.first.expr
65
- assert_equal 7, state.line
66
- end
67
- end
68
-
69
- def test_shows_error_if_there_are_no_breakpoints
70
- enter 'cond 1 true'
71
-
72
- debug_proc(@example)
73
- check_error_includes 'No breakpoints have been set'
74
- end
75
-
76
- def test_shows_error_if_breakpoint_id_is_incorrect
77
- enter 'break 7', 'cond 2 b == 3'
78
-
79
- debug_proc(@example)
80
- check_error_includes \
81
- 'Invalid breakpoint id. ' \
82
- 'Use "info breakpoint" to find out the correct id'
83
- end
84
- end
85
- end
@@ -1,47 +0,0 @@
1
- module Byebug
2
- class ContinueExample
3
- def self.a(num)
4
- num + 4
5
- end
6
- end
7
-
8
- class ContinueTestCase < TestCase
9
- def setup
10
- @example = -> do
11
- byebug
12
-
13
- b = 5
14
- c = b + 5
15
- ContinueExample.a(c)
16
- end
17
-
18
- super
19
- end
20
-
21
- def test_continues_up_to_breakpoint_if_no_line_specified
22
- enter 'break 14', 'continue'
23
- debug_proc(@example) { assert_equal 14, state.line }
24
- end
25
-
26
- def test_works_in_abbreviated_mode_too
27
- enter 'break 14', 'cont'
28
- debug_proc(@example) { assert_equal 14, state.line }
29
- end
30
-
31
- def test_continues_up_to_the_specified_line
32
- enter 'cont 14'
33
- debug_proc(@example) { assert_equal 14, state.line }
34
- end
35
-
36
- def test_ignores_the_command_if_specified_line_is_not_valid
37
- enter 'cont 100'
38
- debug_proc(@example) { assert_equal 13, state.line }
39
- end
40
-
41
- def test_shows_error_if_specified_line_is_not_valid
42
- enter 'cont 100'
43
- debug_proc(@example)
44
- check_error_includes 'Line 100 is not a valid stopping point in file'
45
- end
46
- end
47
- end
@@ -1,26 +0,0 @@
1
- module Byebug
2
- class DeleteTestCase < TestCase
3
- def setup
4
- @example = -> do
5
- byebug
6
- x = 1
7
- x += 1
8
- return x
9
- end
10
-
11
- super
12
- end
13
-
14
- def test_deleting_a_breakpoint_removes_it_from_breakpoints_list
15
- enter 'break 7', -> { "delete #{Breakpoint.first.id}" }
16
-
17
- debug_proc(@example) { assert_empty Byebug.breakpoints }
18
- end
19
-
20
- def test_does_not_stop_at_the_deleted_breakpoint
21
- enter 'b 7', 'b 8', -> { "delete #{Breakpoint.first.id}" }, 'cont'
22
-
23
- debug_proc(@example) { assert_equal 8, state.line }
24
- end
25
- end
26
- end
@@ -1,37 +0,0 @@
1
- module Byebug
2
- class DisplayTestCase < TestCase
3
- def setup
4
- @example = -> do
5
- d = 0
6
- byebug
7
- d = d + 3
8
- d = d + 6
9
- end
10
-
11
- super
12
- end
13
-
14
- def test_shows_expressions
15
- enter 'display d + 1'
16
- debug_proc(@example)
17
- check_output_includes '1: d + 1 = 1'
18
- end
19
-
20
- def test_works_when_using_a_shortcut
21
- enter 'disp d + 1'
22
- debug_proc(@example)
23
- check_output_includes '1: d + 1 = 1'
24
- end
25
-
26
- def test_saves_displayed_expressions
27
- enter 'display d + 1'
28
- debug_proc(@example) { assert_equal [[true, 'd + 1']], state.display }
29
- end
30
-
31
- def test_displays_all_expressions_available
32
- enter 'display d', 'display d + 1', 'display'
33
- debug_proc(@example)
34
- check_output_includes '1: d = 0', '2: d + 1 = 1'
35
- end
36
- end
37
- end
@@ -1,52 +0,0 @@
1
- module Byebug
2
- class EditTestCase < TestCase
3
- def setup
4
- @example = -> do
5
- byebug
6
- Object.new
7
- end
8
-
9
- super
10
- end
11
-
12
- def after
13
- ENV['EDITOR'] = @previous_editor
14
- end
15
-
16
- def test_edit_opens_current_file_in_current_line_in_configured_editor
17
- ENV['EDITOR'] = 'edi'
18
- file = __FILE__
19
- EditCommand.any_instance.expects(:system).with("edi +6 #{file}")
20
- enter 'edit'
21
- debug_proc(@example)
22
- end
23
-
24
- def test_edit_calls_vim_if_no_EDITOR_environment_variable_is_set
25
- ENV['EDITOR'] = nil
26
- file = __FILE__
27
- EditCommand.any_instance.expects(:system).with("vim +6 #{file}")
28
- enter 'edit'
29
- debug_proc(@example)
30
- end
31
-
32
- def test_edit_opens_configured_editor_at_specific_line_and_file
33
- ENV['EDITOR'] = 'edi'
34
- file = File.expand_path('test/test_helper.rb')
35
- EditCommand.any_instance.expects(:system).with("edi +3 #{file}")
36
- enter "edit #{file}:3"
37
- debug_proc(@example)
38
- end
39
-
40
- def test_edit_shows_an_error_if_file_specified_does_not_exists
41
- enter "edit no_such_file:6"
42
- debug_proc(@example)
43
- check_error_includes 'File "no_such_file" is not readable.'
44
- end
45
-
46
- def test_edit_shows_an_error_if_incorrect_syntax_is_used
47
- enter 'edit blabla'
48
- debug_proc(@example)
49
- check_error_includes 'Invalid file[:line] number specification: blabla'
50
- end
51
- end
52
- end
@@ -1,89 +0,0 @@
1
- module Byebug
2
- class EvalExample
3
- def sum(a,b)
4
- a + b
5
- end
6
-
7
- def inspect
8
- raise 'Broken'
9
- end
10
- end
11
-
12
- class EvalTestCase < TestCase
13
- def setup
14
- @example = -> do
15
- byebug
16
- @foo = EvalExample.new
17
- @foo.sum(1, 2)
18
- end
19
-
20
- super
21
- end
22
-
23
- %w(eval e p).each do |cmd_alias|
24
- define_method(:"test_#{cmd_alias}_properly_evaluates_expressions") do
25
- enter 'eval 3 + 2'
26
- debug_proc(@example)
27
- check_output_includes '5'
28
- end
29
- end
30
-
31
- def test_eval_properly_evaluates_an_expression_using_timeout
32
- enter 'eval Timeout::timeout(60) { 1 }'
33
- debug_proc(@example)
34
- check_output_includes '1'
35
- end
36
-
37
- def test_eval_works_when_inspect_raises_an_exception
38
- enter 'c 17', 'p @foo'
39
- debug_proc(@example) { assert_equal 17, state.line }
40
- check_output_includes 'RuntimeError Exception: Broken'
41
- end
42
-
43
- def test_autoeval_works_by_default
44
- enter '[5, 6 , 7].inject(&:+)'
45
- debug_proc(@example)
46
- check_output_includes '18'
47
- end
48
-
49
- def test_auto_eval_can_be_turned_off_and_back_on
50
- enter 'set noautoeval', '[5, 6, 7].inject(&:+)',
51
- 'set autoeval', '[1, 2, 3].inject(&:+)'
52
- debug_proc(@example)
53
- check_output_doesnt_include '18'
54
- check_output_includes '6'
55
- end
56
-
57
- def test_eval_shows_backtrace_on_error_if_stack_on_error_enabled
58
- enter 'set stack_on_error', 'eval 2 / 0'
59
- debug_proc(@example)
60
- check_output_includes(/\s*from \S+:in \`eval\'/)
61
- check_output_doesnt_include 'ZeroDivisionError Exception: divided by 0'
62
- end
63
-
64
- def test_eval_shows_only_exception_if_stack_on_error_disabled
65
- enter 'set stack_on_error off', 'eval 2 / 0'
66
- debug_proc(@example)
67
- check_output_includes 'ZeroDivisionError Exception: divided by 0'
68
- check_output_doesnt_include(/\S+:\d+:in `eval':divided by 0/)
69
- end
70
-
71
- def test_pp_pretty_print_the_expressions_result
72
- enter "pp { a: '3' * 40, b: '4' * 30 }"
73
- debug_proc(@example)
74
- check_output_includes "{:a=>\"#{'3' * 40}\",\n :b=>\"#{'4' * 30}\"}"
75
- end
76
-
77
- def test_putl_prints_expression_and_columnize_the_result
78
- enter 'set width 20', 'putl [1, 2, 3, 4, 5, 9, 8, 7, 6]'
79
- debug_proc(@example)
80
- check_output_includes "1 3 5 8 6\n2 4 9 7"
81
- end
82
-
83
- def test_putl_prints_expression_and_sorts_and_columnize_the_result
84
- enter 'set width 20', 'ps [1, 2, 3, 4, 5, 9, 8, 7, 6]'
85
- debug_proc(@example)
86
- check_output_includes "1 3 5 7 9\n2 4 6 8"
87
- end
88
- end
89
- end
@@ -1,74 +0,0 @@
1
- module Byebug
2
- class FinishExample
3
- def a
4
- b
5
- end
6
-
7
- def b
8
- c
9
- 2
10
- end
11
-
12
- def c
13
- d
14
- 3
15
- end
16
-
17
- def d
18
- 5
19
- end
20
- end
21
-
22
- class FinishTestCase < TestCase
23
- def setup
24
- @example = -> do
25
- byebug
26
- FinishExample.new.a
27
- end
28
-
29
- super
30
- enter 'break 18', 'cont'
31
- end
32
-
33
- def test_finish_stops_after_current_frame_is_finished
34
- enter 'finish'
35
- debug_proc(@example) { assert_equal 14, state.line }
36
- end
37
-
38
- def test_finish_0_stops_before_current_frame_finishes
39
- enter 'finish 0'
40
- debug_proc(@example) { assert_equal 19, state.line }
41
- end
42
-
43
- def test_finish_1_stops_after_current_frame_is_finished
44
- enter 'finish 1'
45
- debug_proc(@example) { assert_equal 14, state.line }
46
- end
47
-
48
- def test_finish_works_for_frame_numbers_higher_than_one
49
- enter 'finish 2'
50
- debug_proc(@example) { assert_equal 9, state.line }
51
- end
52
-
53
- def test_finish_behaves_consistenly_even_if_current_frame_has_been_changed
54
- enter 'up', 'finish'
55
- debug_proc(@example) { assert_equal 9, state.line }
56
- end
57
-
58
- def test_finish_shows_an_error_if_incorrect_frame_number_specified
59
- enter 'finish foo'
60
- debug_proc(@example)
61
- check_error_includes '"finish" argument "foo" needs to be a number'
62
- end
63
-
64
- def test_finish_stays_at_the_same_line_if_incorrect_frame_number_specified
65
- enter 'finish foo'
66
- debug_proc(@example) { assert_equal 18, state.line }
67
- end
68
-
69
- def test_finish_does_not_stop_in_byebug_internal_frames
70
- enter 'finish 4'
71
- debug_proc(@example) { refute_match(/byebug.test.support/, state.file) }
72
- end
73
- end
74
- end
@@ -1,223 +0,0 @@
1
- module Byebug
2
- class FrameExample
3
- def initialize(f)
4
- @f = f
5
- end
6
-
7
- def a
8
- b
9
- end
10
-
11
- def b
12
- c
13
- 2
14
- end
15
-
16
- def c
17
- d('a')
18
- 3
19
- end
20
-
21
- def d(e)
22
- 4
23
- end
24
- end
25
-
26
- class FrameTestCase < TestCase
27
- def setup
28
- @example = -> do
29
- byebug
30
- fr_ex = FrameExample.new('f')
31
- fr_ex.a()
32
- end
33
-
34
- super
35
- end
36
-
37
- def test_up_moves_up_in_the_callstack
38
- enter 'break 22', 'cont', 'up'
39
- debug_proc(@example) { assert_equal 17, state.line }
40
- end
41
-
42
- def test_up_moves_up_in_the_callstack_a_specific_number_of_frames
43
- enter 'break 22', 'cont', 'up 2'
44
- debug_proc(@example) { assert_equal 12, state.line }
45
- end
46
-
47
- def test_down_moves_down_in_the_callstack
48
- enter 'break 22', 'cont', 'up', 'down'
49
- debug_proc(@example) { assert_equal 22, state.line }
50
- end
51
-
52
- def test_down_moves_down_in_the_callstack_a_specific_number_of_frames
53
- enter 'break 22', 'cont', 'up 3', 'down 2'
54
- debug_proc(@example) { assert_equal 17, state.line }
55
- end
56
-
57
- def test_frame_moves_to_a_specific_frame
58
- enter 'break 22', 'cont', 'frame 2'
59
- debug_proc(@example) { assert_equal 12, state.line }
60
- end
61
-
62
- def test_frame_prints_the_callstack_when_called_without_arguments
63
- enter 'break 22', 'cont', 'up', 'frame'
64
- debug_proc(@example)
65
- check_output_includes(/#1 Byebug::FrameExample\.c\s+at #{__FILE__}:17/)
66
- end
67
-
68
- def test_frame_0_sets_frame_to_the_first_one
69
- enter 'break 22', 'cont', 'up', 'frame 0'
70
- debug_proc(@example) { assert_equal 22, state.line }
71
- end
72
-
73
- def test_frame_minus_one_sets_frame_to_the_last_one
74
- enter 'break 22', 'cont', 'frame -1'
75
- debug_proc(@example) { assert_match 'frame_test.rb', state.file }
76
- end
77
-
78
- def test_down_does_not_move_if_frame_number_to_too_low
79
- enter 'break 22', 'cont', 'down'
80
- debug_proc(@example) { assert_equal 22, state.line }
81
- check_error_includes "Can't navigate beyond the newest frame"
82
- end
83
-
84
- def test_up_does_not_move_if_frame_number_to_too_high
85
- enter 'break 22', 'cont', 'up 100'
86
- debug_proc(@example) { assert_equal 22, state.line }
87
- check_error_includes "Can't navigate beyond the oldest frame"
88
- end
89
-
90
- def test_where_displays_current_backtrace_with_fullpaths
91
- enter 'break 22', 'cont', 'where'
92
- debug_proc(@example)
93
- check_output_includes(
94
- /--> #0 Byebug::FrameExample\.d\(e#String\)\s+at #{__FILE__}:22/,
95
- /#1 Byebug::FrameExample\.c\s+at #{__FILE__}:17/,
96
- /#2 Byebug::FrameExample\.b\s+at #{__FILE__}:12/,
97
- /#3 Byebug::FrameExample\.a\s+at #{__FILE__}:8/)
98
- end
99
-
100
- def test_where_displays_current_backtrace_w_shorpaths_if_fullpath_disabled
101
- enter 'break 22', 'cont', 'set nofullpath', 'where'
102
- debug_proc(@example)
103
- path = File.basename(__FILE__)
104
- check_output_includes(
105
- /--> #0 Byebug::FrameExample\.d\(e#String\)\s+at \.\.\..*#{path}:22/,
106
- /#1 Byebug::FrameExample\.c\s+at \.\.\..*#{path}:17/,
107
- /#2 Byebug::FrameExample\.b\s+at \.\.\..*#{path}:12/,
108
- /#3 Byebug::FrameExample\.a\s+at \.\.\..*#{path}:8/)
109
- end
110
-
111
- def test_where_displays_backtraces_using_long_callstyle
112
- enter 'break 22', 'cont', 'set callstyle long', 'where'
113
- debug_proc(@example)
114
- check_output_includes(
115
- /--> #0 Byebug::FrameExample\.d\(e#String\)\s+at #{__FILE__}:22/,
116
- /#1 Byebug::FrameExample\.c\s+at #{__FILE__}:17/,
117
- /#2 Byebug::FrameExample\.b\s+at #{__FILE__}:12/,
118
- /#3 Byebug::FrameExample\.a\s+at #{__FILE__}:8/)
119
- end
120
-
121
- def test_where_displays_backtraces_using_short_callstyle
122
- enter 'break 22', 'cont', 'set callstyle short', 'where'
123
- debug_proc(@example)
124
- check_output_includes(/--> #0 d\(e\)\s+at #{__FILE__}:22/,
125
- /#1 c\s+at #{__FILE__}:17/,
126
- /#2 b\s+at #{__FILE__}:12/,
127
- /#3 a\s+at #{__FILE__}:8/)
128
- end
129
-
130
- def test_where_marks_c_frames_when_printing_the_callstack
131
- enter 'break 4', 'cont', 'where'
132
- debug_proc(@example)
133
- path = __FILE__
134
- check_output_includes(
135
- /--> #0 Byebug::FrameExample.initialize\(f#String\)\s+at #{path}:4/,
136
- /ͱ-- #1 Class.new\(\*args\)\s+at #{__FILE__}:30/,
137
- /#2 block in Byebug::FrameTestCase.setup\s+at #{path}:30/)
138
- end
139
-
140
- def test_up_skips_c_frames
141
- enter 'break 4', 'cont', 'where', 'up', 'where'
142
- debug_proc(@example)
143
- check_output_includes(
144
- /--> #2 block in Byebug::FrameTestCase.setup\s+at #{__FILE__}:30/)
145
- end
146
-
147
- def test_down_skips_c_frames
148
- enter 'break 4', 'cont', 'up', 'down', 'eval f'
149
- debug_proc(@example)
150
- check_output_includes '"f"'
151
- end
152
-
153
- def test_frame_cannot_navigate_to_c_frames
154
- enter 'break 4', 'cont', 'frame 1'
155
- debug_proc(@example)
156
- check_error_includes "Can't navigate to c-frame"
157
- end
158
- end
159
-
160
- class DeepFrameExample
161
- def a
162
- z = 1
163
- z += b
164
- end
165
-
166
- def b
167
- z = 2
168
- z += c
169
- end
170
-
171
- def c
172
- z = 3
173
- byebug
174
- z += d('a')
175
- end
176
-
177
- def d(e)
178
- 4
179
- end
180
- end
181
-
182
- class DeepFrameTestCase < TestCase
183
- def setup
184
- @deep_example = -> do
185
- DeepFrameExample.new.a
186
- end
187
-
188
- super
189
- enter 'break 178', 'cont'
190
- end
191
-
192
- def test_where_correctly_prints_the_backtrace
193
- enter 'where'
194
- debug_proc(@deep_example)
195
- check_output_includes(
196
- /--> #0 Byebug::DeepFrameExample\.d\(e#String\)\s+at #{__FILE__}:178/,
197
- /#1 Byebug::DeepFrameExample\.c\s+at #{__FILE__}:174/,
198
- /#2 Byebug::DeepFrameExample\.b\s+at #{__FILE__}:168/,
199
- /#3 Byebug::DeepFrameExample\.a\s+at #{__FILE__}:163/)
200
- end
201
-
202
- def test_up_moves_up_in_the_callstack
203
- enter 'up'
204
- debug_proc(@deep_example) { assert_equal 174, state.line }
205
- end
206
-
207
- def test_down_moves_down_in_the_callstack
208
- enter 'up', 'down'
209
- debug_proc(@deep_example) { assert_equal 178, state.line }
210
- end
211
-
212
- def test_frame_moves_to_a_specific_frame
213
- enter 'frame 2'
214
- debug_proc(@deep_example) { assert_equal 168, state.line }
215
- end
216
-
217
- def test_eval_works_properly_when_moving_through_the_stack
218
- enter 'p z', 'up', 'p z', 'up', 'p z'
219
- debug_proc(@deep_example)
220
- check_output_includes 'nil', '3', '2'
221
- end
222
- end
223
- end