byebug 3.5.1 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -1
- data/.rubocop.yml +18 -1
- data/.travis.yml +21 -1
- data/CHANGELOG.md +356 -308
- data/CONTRIBUTING.md +31 -15
- data/GUIDE.md +859 -475
- data/Gemfile +8 -10
- data/LICENSE +1 -1
- data/README.md +41 -45
- data/Rakefile +30 -28
- data/byebug.gemspec +18 -18
- data/ext/byebug/breakpoint.c +88 -75
- data/ext/byebug/byebug.c +253 -252
- data/ext/byebug/byebug.h +53 -53
- data/ext/byebug/context.c +188 -159
- data/ext/byebug/extconf.rb +9 -6
- data/ext/byebug/locker.c +53 -11
- data/ext/byebug/threads.c +137 -39
- data/lib/byebug/attacher.rb +7 -2
- data/lib/byebug/breakpoint.rb +30 -0
- data/lib/byebug/command.rb +36 -32
- data/lib/byebug/commands/break.rb +49 -48
- data/lib/byebug/commands/catch.rb +64 -0
- data/lib/byebug/commands/condition.rb +13 -9
- data/lib/byebug/commands/continue.rb +8 -4
- data/lib/byebug/commands/delete.rb +10 -4
- data/lib/byebug/commands/display.rb +33 -25
- data/lib/byebug/commands/edit.rb +18 -13
- data/lib/byebug/commands/enable_disable.rb +26 -24
- data/lib/byebug/commands/eval.rb +77 -35
- data/lib/byebug/commands/finish.rb +9 -5
- data/lib/byebug/commands/frame.rb +66 -125
- data/lib/byebug/commands/help.rb +14 -21
- data/lib/byebug/commands/history.rb +5 -1
- data/lib/byebug/commands/info.rb +41 -106
- data/lib/byebug/commands/interrupt.rb +6 -2
- data/lib/byebug/commands/irb.rb +5 -2
- data/lib/byebug/commands/kill.rb +6 -2
- data/lib/byebug/commands/list.rb +21 -14
- data/lib/byebug/commands/method.rb +17 -9
- data/lib/byebug/commands/pry.rb +13 -3
- data/lib/byebug/commands/quit.rb +10 -5
- data/lib/byebug/commands/restart.rb +12 -19
- data/lib/byebug/commands/save.rb +10 -6
- data/lib/byebug/commands/set.rb +15 -14
- data/lib/byebug/commands/show.rb +8 -8
- data/lib/byebug/commands/source.rb +14 -8
- data/lib/byebug/commands/stepping.rb +15 -29
- data/lib/byebug/commands/threads.rb +73 -49
- data/lib/byebug/commands/tracevar.rb +56 -0
- data/lib/byebug/commands/undisplay.rb +8 -4
- data/lib/byebug/commands/untracevar.rb +38 -0
- data/lib/byebug/commands/var.rb +107 -0
- data/lib/byebug/context.rb +78 -42
- data/lib/byebug/core.rb +78 -40
- data/lib/byebug/helper.rb +58 -42
- data/lib/byebug/history.rb +12 -1
- data/lib/byebug/interface.rb +91 -11
- data/lib/byebug/interfaces/local_interface.rb +12 -19
- data/lib/byebug/interfaces/remote_interface.rb +12 -15
- data/lib/byebug/interfaces/script_interface.rb +14 -18
- data/lib/byebug/interfaces/test_interface.rb +54 -0
- data/lib/byebug/printers/base.rb +64 -0
- data/lib/byebug/printers/plain.rb +53 -0
- data/lib/byebug/processor.rb +20 -1
- data/lib/byebug/processors/command_processor.rb +57 -172
- data/lib/byebug/processors/control_command_processor.rb +16 -43
- data/lib/byebug/remote.rb +13 -7
- data/lib/byebug/runner.rb +102 -54
- data/lib/byebug/setting.rb +45 -68
- data/lib/byebug/settings/autoeval.rb +2 -0
- data/lib/byebug/settings/autoirb.rb +3 -0
- data/lib/byebug/settings/autolist.rb +3 -0
- data/lib/byebug/settings/autosave.rb +2 -0
- data/lib/byebug/settings/basename.rb +2 -0
- data/lib/byebug/settings/callstyle.rb +2 -0
- data/lib/byebug/settings/fullpath.rb +2 -0
- data/lib/byebug/settings/histfile.rb +2 -0
- data/lib/byebug/settings/histsize.rb +2 -0
- data/lib/byebug/settings/linetrace.rb +2 -0
- data/lib/byebug/settings/listsize.rb +2 -0
- data/lib/byebug/settings/post_mortem.rb +7 -2
- data/lib/byebug/settings/stack_on_error.rb +2 -0
- data/lib/byebug/settings/verbose.rb +2 -0
- data/lib/byebug/settings/width.rb +2 -0
- data/lib/byebug/state.rb +12 -0
- data/lib/byebug/states/control_state.rb +26 -0
- data/lib/byebug/states/regular_state.rb +178 -0
- data/lib/byebug/version.rb +1 -1
- metadata +24 -109
- data/lib/byebug/commands/catchpoint.rb +0 -53
- data/lib/byebug/commands/reload.rb +0 -29
- data/lib/byebug/commands/trace.rb +0 -50
- data/lib/byebug/commands/variables.rb +0 -206
- data/lib/byebug/options.rb +0 -46
- data/lib/byebug/settings/autoreload.rb +0 -12
- data/lib/byebug/settings/forcestep.rb +0 -14
- data/lib/byebug/settings/testing.rb +0 -12
- data/lib/byebug/settings/tracing_plus.rb +0 -11
- data/test/commands/break_test.rb +0 -364
- data/test/commands/condition_test.rb +0 -85
- data/test/commands/continue_test.rb +0 -47
- data/test/commands/delete_test.rb +0 -26
- data/test/commands/display_test.rb +0 -37
- data/test/commands/edit_test.rb +0 -52
- data/test/commands/eval_test.rb +0 -89
- data/test/commands/finish_test.rb +0 -74
- data/test/commands/frame_test.rb +0 -223
- data/test/commands/help_test.rb +0 -66
- data/test/commands/history_test.rb +0 -61
- data/test/commands/info_test.rb +0 -238
- data/test/commands/interrupt_test.rb +0 -45
- data/test/commands/irb_test.rb +0 -28
- data/test/commands/kill_test.rb +0 -50
- data/test/commands/list_test.rb +0 -174
- data/test/commands/method_test.rb +0 -52
- data/test/commands/post_mortem_test.rb +0 -71
- data/test/commands/pry_test.rb +0 -26
- data/test/commands/quit_test.rb +0 -53
- data/test/commands/reload_test.rb +0 -39
- data/test/commands/restart_test.rb +0 -46
- data/test/commands/save_test.rb +0 -67
- data/test/commands/set_test.rb +0 -140
- data/test/commands/show_test.rb +0 -76
- data/test/commands/source_test.rb +0 -46
- data/test/commands/stepping_test.rb +0 -192
- data/test/commands/thread_test.rb +0 -164
- data/test/commands/trace_test.rb +0 -71
- data/test/commands/undisplay_test.rb +0 -75
- data/test/commands/variables_test.rb +0 -105
- data/test/debugger_alias_test.rb +0 -7
- data/test/runner_test.rb +0 -150
- data/test/support/matchers.rb +0 -65
- data/test/support/test_interface.rb +0 -59
- data/test/support/utils.rb +0 -122
- data/test/test_helper.rb +0 -58
@@ -1,164 +0,0 @@
|
|
1
|
-
module Byebug
|
2
|
-
class ThreadExample
|
3
|
-
def initialize
|
4
|
-
Thread.main[:should_break] = false
|
5
|
-
end
|
6
|
-
|
7
|
-
def launch
|
8
|
-
@t1 = Thread.new do
|
9
|
-
while true
|
10
|
-
break if Thread.main[:should_break]
|
11
|
-
sleep 0.02
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
@t2 = Thread.new do
|
16
|
-
while true
|
17
|
-
sleep 0.02
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
@t1.join
|
22
|
-
Thread.main[:should_break]
|
23
|
-
end
|
24
|
-
|
25
|
-
def kill
|
26
|
-
@t2.kill
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
class ThreadTestCase < TestCase
|
31
|
-
def setup
|
32
|
-
@example = -> do
|
33
|
-
byebug
|
34
|
-
|
35
|
-
t = ThreadExample.new
|
36
|
-
t.launch
|
37
|
-
t.kill
|
38
|
-
end
|
39
|
-
|
40
|
-
super
|
41
|
-
end
|
42
|
-
|
43
|
-
def release
|
44
|
-
@release ||= 'eval Thread.main[:should_break] = true'
|
45
|
-
end
|
46
|
-
|
47
|
-
def first_thnum
|
48
|
-
Byebug.contexts.first.thnum
|
49
|
-
end
|
50
|
-
|
51
|
-
def last_thnum
|
52
|
-
Byebug.contexts.last.thnum
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_thread_list_marks_current_thread_with_a_plus_sign
|
56
|
-
skip 'for now'
|
57
|
-
thnum = nil
|
58
|
-
enter 'break 8', 'cont', 'thread list', release
|
59
|
-
debug_proc(@example) { thnum = first_thnum }
|
60
|
-
check_output_includes(/\+ #{thnum} #<Thread:\S+ run>\t#{__FILE__}:8/)
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_thread_list_works_with_shortcut
|
64
|
-
skip 'for now'
|
65
|
-
thnum = nil
|
66
|
-
enter 'break 8', 'cont', 'th list', release
|
67
|
-
debug_proc(@example) { thnum = first_thnum }
|
68
|
-
check_output_includes(/\+ #{thnum} #<Thread:\S+ run>\t#{__FILE__}:8/)
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_thread_list_show_all_available_threads
|
72
|
-
skip 'for now'
|
73
|
-
enter 'break 21', 'cont', 'thread list', release
|
74
|
-
debug_proc(@example)
|
75
|
-
check_output_includes(/(\+)?\d+ #<Thread:\S+ (sleep|run)>/,
|
76
|
-
/(\+)?\d+ #<Thread:\S+ (sleep|run)>/,
|
77
|
-
/(\+)?\d+ #<Thread:\S+ (sleep|run)>/)
|
78
|
-
end
|
79
|
-
|
80
|
-
def test_thread_stop_marks_thread_as_suspended
|
81
|
-
skip 'for now'
|
82
|
-
thnum = nil
|
83
|
-
enter 'break 21', 'cont', -> { "thread stop #{last_thnum}" }, release
|
84
|
-
debug_proc(@example) { thnum = last_thnum }
|
85
|
-
check_output_includes(/\$ #{thnum} #<Thread:/)
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_thread_stop_actually_suspends_thread_execution
|
89
|
-
skip 'for now'
|
90
|
-
enter 'break 21', 'cont', 'trace on',
|
91
|
-
-> { "thread stop #{last_thnum}" }, release
|
92
|
-
debug_proc(@example)
|
93
|
-
check_output_doesnt_include(/Tracing: #{__FILE__}:16/,
|
94
|
-
/Tracing: #{__FILE__}:17/)
|
95
|
-
end
|
96
|
-
|
97
|
-
def test_thread_stop_shows_error_when_thread_number_not_specified
|
98
|
-
skip 'for now'
|
99
|
-
enter 'break 8', 'cont', 'thread stop', release
|
100
|
-
debug_proc(@example)
|
101
|
-
check_error_includes '"thread stop" needs a thread number'
|
102
|
-
end
|
103
|
-
|
104
|
-
def test_thread_stop_shows_error_when_trying_to_stop_current_thread
|
105
|
-
skip 'for now'
|
106
|
-
enter 'break 8', 'cont', -> { "thread stop #{first_thnum}" }, release
|
107
|
-
debug_proc(@example)
|
108
|
-
check_error_includes "It's the current thread"
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_thread_resume_removes_threads_from_the_suspended_state
|
112
|
-
skip 'for now'
|
113
|
-
thnum = nil
|
114
|
-
enter 'break 21', 'cont',
|
115
|
-
-> { thnum = last_thnum ; "thread stop #{thnum}" },
|
116
|
-
-> { "thread resume #{thnum}" }, release
|
117
|
-
debug_proc(@example) do
|
118
|
-
assert_equal false, Byebug.contexts.last.suspended?
|
119
|
-
end
|
120
|
-
check_output_includes(/\$ #{thnum} #<Thread:/, /#{thnum} #<Thread:/)
|
121
|
-
end
|
122
|
-
|
123
|
-
def test_thread_resume_shows_error_if_thread_number_not_specified
|
124
|
-
skip 'for now'
|
125
|
-
enter 'break 8', 'cont', 'thread resume', release
|
126
|
-
debug_proc(@example)
|
127
|
-
check_error_includes '"thread resume" needs a thread number'
|
128
|
-
end
|
129
|
-
|
130
|
-
def test_thread_resume_shows_error_when_trying_to_resume_current_thread
|
131
|
-
skip 'for now'
|
132
|
-
enter 'break 8', 'cont', -> { "thread resume #{first_thnum}" }, release
|
133
|
-
debug_proc(@example)
|
134
|
-
check_error_includes "It's the current thread"
|
135
|
-
end
|
136
|
-
|
137
|
-
def test_thread_resume_shows_error_if_thread_is_already_running
|
138
|
-
skip 'for now'
|
139
|
-
enter 'break 21', 'cont', -> { "thread resume #{last_thnum}" }, release
|
140
|
-
debug_proc(@example)
|
141
|
-
check_error_includes 'Already running'
|
142
|
-
end
|
143
|
-
|
144
|
-
def test_thread_switch_changes_execution_to_another_thread
|
145
|
-
skip 'for now'
|
146
|
-
enter 'break 21', 'cont', -> { "thread switch #{last_thnum}" }, release
|
147
|
-
debug_proc(@example) { assert_equal state.line, 16 }
|
148
|
-
end
|
149
|
-
|
150
|
-
def test_thread_switch_shows_error_if_thread_number_not_specified
|
151
|
-
skip 'for now'
|
152
|
-
enter 'break 8', 'cont', 'thread switch', release
|
153
|
-
debug_proc(@example)
|
154
|
-
check_error_includes '"thread switch" needs a thread number'
|
155
|
-
end
|
156
|
-
|
157
|
-
def test_thread_switch_shows_error_when_trying_to_switch_current_thread
|
158
|
-
skip 'for now'
|
159
|
-
enter 'break 8', 'cont', -> { "thread switch #{first_thnum}" }, release
|
160
|
-
debug_proc(@example)
|
161
|
-
check_error_includes "It's the current thread"
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|
data/test/commands/trace_test.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
module Byebug
|
2
|
-
class TraceTestCase < TestCase
|
3
|
-
def setup
|
4
|
-
@example = -> do
|
5
|
-
$bla = 5
|
6
|
-
byebug
|
7
|
-
$bla = 7
|
8
|
-
$bla = 8
|
9
|
-
$bla = 9
|
10
|
-
$bla = 10
|
11
|
-
$bla = (0 == (10 % $bla))
|
12
|
-
end
|
13
|
-
untrace_var(:$bla) if defined?($bla)
|
14
|
-
|
15
|
-
super
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_linetrace_setting_enables_tracing_program_execution
|
19
|
-
enter 'set linetrace', 'cont 11', 'set nolinetrace'
|
20
|
-
debug_proc(@example)
|
21
|
-
check_output_includes 'linetrace is on',
|
22
|
-
"Tracing: #{__FILE__}:8 $bla = 8",
|
23
|
-
"Tracing: #{__FILE__}:9 $bla = 9",
|
24
|
-
"Tracing: #{__FILE__}:10 $bla = 10",
|
25
|
-
"Tracing: #{__FILE__}:11 $bla = (0 == (10 % $bla))"
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_basename_setting_affects_tracing_output
|
29
|
-
enter 'set basename', 'set linetrace on', 'cont 10', 'set nolinetrace'
|
30
|
-
debug_proc(@example)
|
31
|
-
check_output_includes \
|
32
|
-
"Tracing: #{File.basename(__FILE__)}:10 $bla = 10"
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_disabling_linetrace_setting_stops_tracing
|
36
|
-
enter 'set linetrace', 'next', 'set nolinetrace'
|
37
|
-
debug_proc(@example)
|
38
|
-
check_output_includes "Tracing: #{__FILE__}:8 $bla = 8"
|
39
|
-
check_output_doesnt_include "Tracing: #{__FILE__}:9 $bla = 9"
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_tracevar_tracks_global_variables
|
43
|
-
enter 'tracevar bla'
|
44
|
-
debug_proc(@example)
|
45
|
-
check_output_includes "traced global variable 'bla' has value '7'",
|
46
|
-
"traced global variable 'bla' has value '10'"
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_tracevar_stop_makes_program_stop_when_global_var_changes
|
50
|
-
enter 'tracevar bla stop', 'break 10', 'cont'
|
51
|
-
debug_proc(@example) { assert_equal 8, state.line }
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_tracevar_nostop_does_not_stop_when_global_var_changes
|
55
|
-
enter 'tracevar bla nostop', 'break 10', 'cont'
|
56
|
-
debug_proc(@example) { assert_equal 10, state.line }
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_tracevar_shows_an_error_message_if_there_is_no_such_global_var
|
60
|
-
enter 'tracevar foo'
|
61
|
-
debug_proc(@example)
|
62
|
-
check_error_includes "'foo' is not a global variable."
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_tracevar_shows_an_error_message_if_subcommand_is_invalid
|
66
|
-
enter 'tracevar bla foo'
|
67
|
-
debug_proc(@example)
|
68
|
-
check_error_includes 'expecting "stop" or "nostop"; got "foo"'
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
@@ -1,75 +0,0 @@
|
|
1
|
-
module Byebug
|
2
|
-
class UndisplayTestCase < 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_asks_for_confirmation
|
15
|
-
enter 'display d', 'display d + 1', 'undisplay'
|
16
|
-
debug_proc(@example)
|
17
|
-
check_confirm_includes 'Clear all expressions? (y/n)'
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_removes_all_expressions_from_list_if_confirmed
|
21
|
-
enter 'display d', 'display d + 1', 'undisplay', 'y', 'next'
|
22
|
-
debug_proc(@example) do
|
23
|
-
assert_equal [[false, 'd'], [false, 'd + 1']], state.display
|
24
|
-
end
|
25
|
-
check_output_doesnt_include '1: d = 3', '2: d + 1 = 4'
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_does_not_remove_all_expressions_from_list_unless_confirmed
|
29
|
-
enter 'display d', 'display d + 1', 'undisplay', 'n', 'display'
|
30
|
-
debug_proc(@example) do
|
31
|
-
assert_equal [[true, 'd'], [true, 'd + 1']], state.display
|
32
|
-
end
|
33
|
-
|
34
|
-
check_output_includes '1: d = 0', '2: d + 1 = 1'
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_marks_specific_expression_from_list_as_inactive
|
38
|
-
enter 'display d', 'display d + 1', 'undisplay 1'
|
39
|
-
|
40
|
-
debug_proc(@example) do
|
41
|
-
assert_equal [[nil, 'd'], [true, 'd + 1']], state.display
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_displays_only_the_active_position
|
46
|
-
enter 'display d', 'display d + 1', 'undisplay 1', 'next'
|
47
|
-
debug_proc(@example)
|
48
|
-
check_output_includes '2: d + 1 = 4'
|
49
|
-
check_output_doesnt_include '1: d = 3'
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_disable_display_removes_the_expression_from_display_list
|
53
|
-
enter 'display d', 'disable display 1'
|
54
|
-
debug_proc(@example) { assert_equal [[false, 'd']], state.display }
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_disable_display_shows_an_error_if_no_displays_are_set
|
58
|
-
enter 'disable display 1'
|
59
|
-
debug_proc(@example)
|
60
|
-
check_error_includes 'No display expressions have been set'
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_disable_display_shows_an_error_if_theres_no_such_display_position
|
64
|
-
enter 'display d', 'disable display 4'
|
65
|
-
debug_proc(@example)
|
66
|
-
check_error_includes \
|
67
|
-
'"disable display" argument "4" needs to be at most 1'
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_enable_display_set_display_flag_to_true_in_display_list
|
71
|
-
enter 'display d', 'disable display 1', 'enable display 1'
|
72
|
-
debug_proc(@example) { assert_equal [[true, 'd']], state.display }
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
@@ -1,105 +0,0 @@
|
|
1
|
-
module Byebug
|
2
|
-
class VariablesExample
|
3
|
-
SOMECONST = 'foo' unless defined?(SOMECONST)
|
4
|
-
|
5
|
-
def initialize
|
6
|
-
@inst_a = 1
|
7
|
-
@inst_b = 2
|
8
|
-
@inst_c = '1' * 40
|
9
|
-
@inst_d = BasicObject.new
|
10
|
-
end
|
11
|
-
|
12
|
-
def run
|
13
|
-
a = 4
|
14
|
-
b = [1, 2, 3].map do |i|
|
15
|
-
a * i
|
16
|
-
end
|
17
|
-
b
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
class VariablesTestCase < TestCase
|
22
|
-
def setup
|
23
|
-
@example = -> do
|
24
|
-
byebug
|
25
|
-
|
26
|
-
v = VariablesExample.new
|
27
|
-
v.run
|
28
|
-
end
|
29
|
-
|
30
|
-
super
|
31
|
-
end
|
32
|
-
|
33
|
-
# TODO: we check a class minitest variable... brittle...
|
34
|
-
['var class', 'v cl'].each do |cmd_alias|
|
35
|
-
define_method(:"test_#{cmd_alias}_shows_class_variables") do
|
36
|
-
enter cmd_alias
|
37
|
-
debug_proc(@example)
|
38
|
-
check_output_includes(/@@runnables/)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
['var const', 'v co'].each do |cmd_alias|
|
43
|
-
define_method(:"test_#{cmd_alias}_shows_constants_in_class_or_module") do
|
44
|
-
enter "#{cmd_alias} VariablesExample"
|
45
|
-
debug_proc(@example)
|
46
|
-
check_output_includes 'SOMECONST => "foo"'
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_var_const_shows_error_if_given_object_is_not_a_class_or_module
|
51
|
-
enter 'var const v'
|
52
|
-
debug_proc(@example)
|
53
|
-
check_output_includes 'Should be Class/Module: v'
|
54
|
-
end
|
55
|
-
|
56
|
-
['var global', 'v g'].each do |cmd_alias|
|
57
|
-
define_method(:"test_#{cmd_alias}_shows_global_variables") do
|
58
|
-
enter cmd_alias
|
59
|
-
debug_proc(@example)
|
60
|
-
check_output_includes '$VERBOSE = true'
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
['var instance', 'v ins'].each do |cmd_alias|
|
65
|
-
define_method(:"test_#{cmd_alias}_shows_instance_vars_of_an_object") do
|
66
|
-
enter 'break 27', 'cont', "#{cmd_alias} v"
|
67
|
-
debug_proc(@example)
|
68
|
-
check_output_includes '@inst_a = 1', '@inst_b = 2'
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_var_instance_shows_instance_variables_of_self_if_no_object_given
|
73
|
-
enter 'break 9', 'cont', 'var instance'
|
74
|
-
debug_proc(@example)
|
75
|
-
check_output_includes '@inst_a = 1', '@inst_b = 2'
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_var_instance_cuts_long_variable_values_according_to_width_setting
|
79
|
-
enter 'break 27', 'cont', 'set width 45', 'var instance v'
|
80
|
-
debug_proc(@example)
|
81
|
-
check_output_includes '@inst_c = "1111111111111111111111111111111...'
|
82
|
-
end
|
83
|
-
|
84
|
-
def test_v_ins_shows_error_if_value_does_not_have_to_s_or_inspect_methods
|
85
|
-
enter 'break 27', 'cont', 'v ins v'
|
86
|
-
debug_proc(@example)
|
87
|
-
check_output_includes '@inst_d = *Error in evaluation*'
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_var_local_shows_local_variables
|
91
|
-
enter 'break 15', 'cont', 'var local'
|
92
|
-
debug_proc(@example)
|
93
|
-
check_output_includes 'a => 4', 'b => nil', 'i => 1'
|
94
|
-
end
|
95
|
-
|
96
|
-
# TODO: class variables not currently checked
|
97
|
-
['var all', 'v a'].each do |cmd_alias|
|
98
|
-
define_method(:"test_#{cmd_alias}_shows_all_variables") do
|
99
|
-
enter 'break 15', 'cont', cmd_alias
|
100
|
-
debug_proc(@example)
|
101
|
-
check_output_includes '$VERBOSE = true', '@inst_a = 1', 'a => 4'
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
data/test/debugger_alias_test.rb
DELETED
data/test/runner_test.rb
DELETED
@@ -1,150 +0,0 @@
|
|
1
|
-
require 'byebug/runner'
|
2
|
-
|
3
|
-
module Byebug
|
4
|
-
class RunnerTest < TestCase
|
5
|
-
def setup
|
6
|
-
super
|
7
|
-
@old_argv = ARGV
|
8
|
-
@runner = Byebug::Runner.new
|
9
|
-
end
|
10
|
-
|
11
|
-
def after
|
12
|
-
ARGV.replace(@old_argv)
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_run_with_version_flag
|
16
|
-
ARGV.replace(%w(--version))
|
17
|
-
@runner.run
|
18
|
-
|
19
|
-
check_output_includes(/#{Byebug::VERSION}/)
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_run_with_help_flag
|
23
|
-
ARGV.replace(%w(--help))
|
24
|
-
@runner.run
|
25
|
-
|
26
|
-
check_output_includes(/-d.*-I.*-q.*-s.*-x.*-m.*-r.*-R.*-t.*-v.*-h/m)
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_run_with_remote_option_only_with_a_port_number
|
30
|
-
ARGV.replace(%w(--remote 9999))
|
31
|
-
Byebug.expects(:start_client)
|
32
|
-
@runner.run
|
33
|
-
|
34
|
-
check_output_includes(/Connecting to byebug server localhost:9999/)
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_run_with_remote_option_with_host_and_port_specification
|
38
|
-
ARGV.replace(%w(--remote myhost:9999))
|
39
|
-
Byebug.expects(:start_client)
|
40
|
-
@runner.run
|
41
|
-
|
42
|
-
check_output_includes(/Connecting to byebug server myhost:9999/)
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_run_without_a_script_to_debug
|
46
|
-
ARGV.replace([])
|
47
|
-
|
48
|
-
assert_raises(SystemExit) { @runner.run }
|
49
|
-
|
50
|
-
check_error_includes(/You must specify a program to debug.../)
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_run_with_an_nonexistent_script
|
54
|
-
ARGV.replace(%w(non_existent_script.rb))
|
55
|
-
|
56
|
-
assert_raises(SystemExit) { @runner.run }
|
57
|
-
|
58
|
-
check_error_includes("The script doesn't exist")
|
59
|
-
end
|
60
|
-
|
61
|
-
def expect_it_debugs_script(rc = true)
|
62
|
-
Byebug.expects(:start)
|
63
|
-
rc_expectation = Byebug.expects(:run_init_script)
|
64
|
-
rc_expectation.never unless rc
|
65
|
-
@runner.expects(:debug_program)
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_run_with_a_script_to_debug
|
69
|
-
ARGV.replace(%w(lib/byebug.rb))
|
70
|
-
expect_it_debugs_script
|
71
|
-
|
72
|
-
@runner.run
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_run_with_a_script_and_params_does_not_consume_script_params
|
76
|
-
ARGV.replace(%w(-- lib/byebug.rb -opt value))
|
77
|
-
expect_it_debugs_script
|
78
|
-
|
79
|
-
@runner.run
|
80
|
-
assert_equal %w(lib/byebug.rb -opt value), ARGV
|
81
|
-
end
|
82
|
-
|
83
|
-
def test_run_with_ruby_script_ruby_is_ignored_and_script_passed_instead
|
84
|
-
ARGV.replace(%w(-- ruby lib/byebug.rb))
|
85
|
-
expect_it_debugs_script
|
86
|
-
|
87
|
-
@runner.run
|
88
|
-
assert_equal %w(lib/byebug.rb), ARGV
|
89
|
-
end
|
90
|
-
|
91
|
-
def test_run_with_no_rc_option
|
92
|
-
ARGV.replace(%w(--no-rc lib/byebug.rb))
|
93
|
-
expect_it_debugs_script(false)
|
94
|
-
|
95
|
-
@runner.run
|
96
|
-
end
|
97
|
-
|
98
|
-
def test_run_with_post_mortem_mode_flag
|
99
|
-
ARGV.replace(%w(-m lib/byebug.rb))
|
100
|
-
expect_it_debugs_script
|
101
|
-
@runner.run
|
102
|
-
|
103
|
-
assert_equal true, Byebug.post_mortem?
|
104
|
-
Byebug::Setting[:post_mortem] = false
|
105
|
-
end
|
106
|
-
|
107
|
-
def test_run_with_linetracing_flag
|
108
|
-
ARGV.replace(%w(-t lib/byebug.rb))
|
109
|
-
expect_it_debugs_script
|
110
|
-
@runner.run
|
111
|
-
|
112
|
-
assert_equal true, Byebug.tracing?
|
113
|
-
Byebug::Setting[:linetrace] = false
|
114
|
-
end
|
115
|
-
|
116
|
-
def test_run_with_no_quit_flag
|
117
|
-
skip 'for now'
|
118
|
-
ARGV.replace(%w(--no-quit lib/byebug.rb))
|
119
|
-
@runner.run
|
120
|
-
|
121
|
-
check_output_includes('(byebug:ctrl)')
|
122
|
-
end
|
123
|
-
|
124
|
-
def test_run_with_require_flag
|
125
|
-
ARGV.replace(%w(-r abbrev lib/byebug.rb))
|
126
|
-
expect_it_debugs_script
|
127
|
-
@runner.run
|
128
|
-
|
129
|
-
hsh = { 'can' => 'can', 'cat' => 'cat' }
|
130
|
-
assert_equal hsh, %w(can cat).abbrev
|
131
|
-
end
|
132
|
-
|
133
|
-
def test_run_with_include_flag
|
134
|
-
ARGV.replace(%w(-I custom_dir lib/byebug.rb))
|
135
|
-
expect_it_debugs_script
|
136
|
-
@runner.run
|
137
|
-
|
138
|
-
assert_includes $LOAD_PATH, 'custom_dir'
|
139
|
-
end
|
140
|
-
|
141
|
-
def test_run_with_debug_flag
|
142
|
-
ARGV.replace(%w(-d lib/byebug.rb))
|
143
|
-
expect_it_debugs_script
|
144
|
-
@runner.run
|
145
|
-
|
146
|
-
assert_equal $DEBUG, true
|
147
|
-
$DEBUG = false
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|