byebug 3.2.0 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +125 -99
- data/CONTRIBUTING.md +4 -6
- data/GUIDE.md +42 -20
- data/Gemfile +5 -3
- data/README.md +2 -3
- data/Rakefile +11 -7
- data/bin/byebug +2 -252
- data/byebug.gemspec +7 -4
- data/ext/byebug/byebug.c +17 -18
- data/ext/byebug/byebug.h +4 -5
- data/ext/byebug/context.c +37 -39
- data/ext/byebug/threads.c +39 -18
- data/lib/byebug.rb +2 -110
- data/lib/byebug/attacher.rb +23 -0
- data/lib/byebug/breakpoint.rb +60 -0
- data/lib/byebug/command.rb +62 -70
- data/lib/byebug/commands/break.rb +24 -24
- data/lib/byebug/commands/catchpoint.rb +18 -10
- data/lib/byebug/commands/condition.rb +18 -17
- data/lib/byebug/commands/continue.rb +17 -9
- data/lib/byebug/commands/delete.rb +19 -13
- data/lib/byebug/commands/display.rb +19 -53
- data/lib/byebug/commands/edit.rb +7 -4
- data/lib/byebug/commands/enable_disable.rb +130 -0
- data/lib/byebug/commands/eval.rb +40 -22
- data/lib/byebug/commands/finish.rb +13 -4
- data/lib/byebug/commands/frame.rb +65 -45
- data/lib/byebug/commands/help.rb +17 -18
- data/lib/byebug/commands/history.rb +14 -8
- data/lib/byebug/commands/info.rb +160 -182
- data/lib/byebug/commands/interrupt.rb +4 -1
- data/lib/byebug/commands/irb.rb +30 -0
- data/lib/byebug/commands/kill.rb +7 -8
- data/lib/byebug/commands/list.rb +71 -66
- data/lib/byebug/commands/method.rb +14 -6
- data/lib/byebug/commands/pry.rb +35 -0
- data/lib/byebug/commands/quit.rb +9 -6
- data/lib/byebug/commands/reload.rb +5 -2
- data/lib/byebug/commands/restart.rb +13 -9
- data/lib/byebug/commands/save.rb +17 -17
- data/lib/byebug/commands/set.rb +16 -15
- data/lib/byebug/commands/show.rb +10 -11
- data/lib/byebug/commands/source.rb +11 -5
- data/lib/byebug/commands/stepping.rb +38 -24
- data/lib/byebug/commands/threads.rb +45 -31
- data/lib/byebug/commands/trace.rb +22 -9
- data/lib/byebug/commands/undisplay.rb +45 -0
- data/lib/byebug/commands/variables.rb +83 -27
- data/lib/byebug/context.rb +25 -22
- data/lib/byebug/core.rb +82 -0
- data/lib/byebug/helper.rb +37 -28
- data/lib/byebug/history.rb +8 -4
- data/lib/byebug/interface.rb +12 -17
- data/lib/byebug/interfaces/local_interface.rb +11 -8
- data/lib/byebug/interfaces/remote_interface.rb +11 -8
- data/lib/byebug/interfaces/script_interface.rb +9 -6
- data/lib/byebug/options.rb +46 -0
- data/lib/byebug/processor.rb +7 -1
- data/lib/byebug/processors/command_processor.rb +135 -125
- data/lib/byebug/processors/control_command_processor.rb +23 -23
- data/lib/byebug/remote.rb +17 -26
- data/lib/byebug/runner.rb +100 -0
- data/lib/byebug/setting.rb +33 -8
- data/lib/byebug/settings/autoeval.rb +5 -15
- data/lib/byebug/settings/autoirb.rb +4 -1
- data/lib/byebug/settings/autolist.rb +5 -2
- data/lib/byebug/settings/autoreload.rb +5 -2
- data/lib/byebug/settings/autosave.rb +6 -2
- data/lib/byebug/settings/basename.rb +7 -2
- data/lib/byebug/settings/callstyle.rb +4 -1
- data/lib/byebug/settings/forcestep.rb +6 -3
- data/lib/byebug/settings/fullpath.rb +5 -2
- data/lib/byebug/settings/histfile.rb +5 -3
- data/lib/byebug/settings/histsize.rb +5 -3
- data/lib/byebug/settings/linetrace.rb +4 -1
- data/lib/byebug/settings/listsize.rb +5 -1
- data/lib/byebug/settings/post_mortem.rb +21 -13
- data/lib/byebug/settings/stack_on_error.rb +6 -2
- data/lib/byebug/settings/testing.rb +6 -1
- data/lib/byebug/settings/tracing_plus.rb +5 -1
- data/lib/byebug/settings/verbose.rb +13 -2
- data/lib/byebug/settings/width.rb +4 -1
- data/lib/byebug/version.rb +1 -1
- data/test/{break_test.rb → commands/break_test.rb} +41 -53
- data/test/{condition_test.rb → commands/condition_test.rb} +14 -14
- data/test/{continue_test.rb → commands/continue_test.rb} +0 -0
- data/test/{delete_test.rb → commands/delete_test.rb} +2 -2
- data/test/commands/display_test.rb +37 -0
- data/test/{edit_test.rb → commands/edit_test.rb} +0 -0
- data/test/{eval_test.rb → commands/eval_test.rb} +1 -0
- data/test/{finish_test.rb → commands/finish_test.rb} +11 -1
- data/test/{frame_test.rb → commands/frame_test.rb} +12 -16
- data/test/{help_test.rb → commands/help_test.rb} +21 -4
- data/test/{history_test.rb → commands/history_test.rb} +0 -0
- data/test/{info_test.rb → commands/info_test.rb} +5 -55
- data/test/{interrupt_test.rb → commands/interrupt_test.rb} +0 -0
- data/test/commands/irb_test.rb +28 -0
- data/test/{kill_test.rb → commands/kill_test.rb} +1 -1
- data/test/{list_test.rb → commands/list_test.rb} +1 -1
- data/test/{method_test.rb → commands/method_test.rb} +0 -0
- data/test/{post_mortem_test.rb → commands/post_mortem_test.rb} +6 -10
- data/test/{pry_test.rb → commands/pry_test.rb} +4 -13
- data/test/{quit_test.rb → commands/quit_test.rb} +4 -4
- data/test/{reload_test.rb → commands/reload_test.rb} +0 -0
- data/test/{restart_test.rb → commands/restart_test.rb} +6 -0
- data/test/{save_test.rb → commands/save_test.rb} +2 -2
- data/test/{set_test.rb → commands/set_test.rb} +9 -2
- data/test/{show_test.rb → commands/show_test.rb} +1 -1
- data/test/{source_test.rb → commands/source_test.rb} +3 -3
- data/test/{stepping_test.rb → commands/stepping_test.rb} +44 -35
- data/test/{thread_test.rb → commands/thread_test.rb} +0 -0
- data/test/{trace_test.rb → commands/trace_test.rb} +0 -0
- data/test/{display_test.rb → commands/undisplay_test.rb} +7 -45
- data/test/{variables_test.rb → commands/variables_test.rb} +10 -1
- data/test/debugger_alias_test.rb +2 -2
- data/test/runner_test.rb +127 -0
- data/test/support/matchers.rb +27 -25
- data/test/support/test_interface.rb +9 -5
- data/test/support/utils.rb +96 -101
- data/test/test_helper.rb +32 -20
- metadata +93 -68
- data/lib/byebug/commands/enable.rb +0 -154
- data/lib/byebug/commands/repl.rb +0 -126
- data/test/irb_test.rb +0 -47
- data/test/support/breakpoint.rb +0 -13
@@ -13,28 +13,28 @@ module Byebug
|
|
13
13
|
QuitCommand.any_instance.expects(:exit!)
|
14
14
|
enter 'quit', 'y'
|
15
15
|
debug_proc(@example)
|
16
|
-
|
16
|
+
check_confirm_includes 'Really quit? (y/n)'
|
17
17
|
end
|
18
18
|
|
19
19
|
def test_does_not_quit_if_user_did_not_confirm
|
20
20
|
QuitCommand.any_instance.expects(:exit!).never
|
21
21
|
enter 'quit', 'n'
|
22
22
|
debug_proc(@example)
|
23
|
-
|
23
|
+
check_confirm_includes 'Really quit? (y/n)'
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_quits_inmediately_if_used_with_bang
|
27
27
|
QuitCommand.any_instance.expects(:exit!)
|
28
28
|
enter 'quit!'
|
29
29
|
debug_proc(@example)
|
30
|
-
|
30
|
+
check_confirm_doesnt_include 'Really quit? (y/n)'
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_quits_inmediately_if_used_with_unconditionally
|
34
34
|
QuitCommand.any_instance.expects(:exit!)
|
35
35
|
enter 'quit unconditionally'
|
36
36
|
debug_proc(@example)
|
37
|
-
|
37
|
+
check_confirm_doesnt_include 'Really quit? (y/n)'
|
38
38
|
end
|
39
39
|
|
40
40
|
def test_closes_interface_before_quitting
|
File without changes
|
@@ -15,9 +15,15 @@ module Byebug
|
|
15
15
|
RestartExample.new.concat_args(a, b, c)
|
16
16
|
end
|
17
17
|
|
18
|
+
@old_prog_script = Byebug::PROG_SCRIPT if defined?(Byebug::PROG_SCRIPT)
|
19
|
+
|
18
20
|
super
|
19
21
|
end
|
20
22
|
|
23
|
+
def after
|
24
|
+
force_set_const(Byebug, 'PROG_SCRIPT', @old_prog_script)
|
25
|
+
end
|
26
|
+
|
21
27
|
def must_restart(cmd = nil)
|
22
28
|
expectation = RestartCommand.any_instance.expects(:exec)
|
23
29
|
expectation = expectation.with(cmd) if cmd
|
@@ -54,14 +54,14 @@ module Byebug
|
|
54
54
|
enter 'save'
|
55
55
|
debug_proc(@example)
|
56
56
|
assert_includes File.read(interface.restart_file), 'set autoirb false'
|
57
|
-
|
57
|
+
File.delete(interface.restart_file)
|
58
58
|
end
|
59
59
|
|
60
60
|
def test_save_without_a_filename_shows_a_message_with_the_file_used
|
61
61
|
enter 'save'
|
62
62
|
debug_proc(@example)
|
63
63
|
check_output_includes "Saved to '#{interface.restart_file}'"
|
64
|
-
|
64
|
+
File.delete(interface.restart_file)
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
@@ -96,7 +96,7 @@ module Byebug
|
|
96
96
|
def test_set_histsize_shows_an_error_message_if_no_size_is_provided
|
97
97
|
enter 'set histsize'
|
98
98
|
debug_proc(@example)
|
99
|
-
|
99
|
+
check_error_includes 'You must specify a value for setting :histsize'
|
100
100
|
end
|
101
101
|
|
102
102
|
def test_set_histfile_sets_command_history_file
|
@@ -110,7 +110,7 @@ module Byebug
|
|
110
110
|
def test_set_histfile_shows_an_error_message_if_no_filename_is_provided
|
111
111
|
enter 'set histfile'
|
112
112
|
debug_proc(@example)
|
113
|
-
|
113
|
+
check_error_includes 'You must specify a value for setting :histfile'
|
114
114
|
end
|
115
115
|
|
116
116
|
[:listsize, :width].each do |set|
|
@@ -122,6 +122,13 @@ module Byebug
|
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
125
|
+
def test_verbose_prints_tracepoint_api_event_information
|
126
|
+
enter 'set verbose'
|
127
|
+
debug_proc(@example)
|
128
|
+
assert_equal true, Byebug.verbose?
|
129
|
+
Byebug.verbose = false
|
130
|
+
end
|
131
|
+
|
125
132
|
def test_set_without_arguments_shows_help_for_set_command
|
126
133
|
enter 'set'
|
127
134
|
debug_proc(@example)
|
@@ -16,7 +16,7 @@ module Byebug
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def teardown
|
19
|
-
|
19
|
+
File.delete('source_example.txt')
|
20
20
|
end
|
21
21
|
|
22
22
|
%w(source so).each do |cmd_alias|
|
@@ -38,8 +38,8 @@ module Byebug
|
|
38
38
|
define_method(:"test_#{cmd_alias}_without_arguments_shows_help") do
|
39
39
|
enter 'source'
|
40
40
|
debug_proc(@example)
|
41
|
-
check_output_includes
|
42
|
-
|
41
|
+
check_output_includes(
|
42
|
+
/Executes file <file> containing byebug commands./)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -47,9 +47,14 @@ module Byebug
|
|
47
47
|
enter 's'
|
48
48
|
debug_proc(@example) { assert_equal 14, state.line }
|
49
49
|
end
|
50
|
+
|
51
|
+
def test_next_does_not_stop_at_byebug_internal_frames
|
52
|
+
enter 'set forcestep', 'next 2'
|
53
|
+
debug_proc(@example) { refute_match(/byebug.test.support/, state.file) }
|
54
|
+
end
|
50
55
|
end
|
51
56
|
|
52
|
-
class
|
57
|
+
class AdvancedSteppingTestCase < TestCase
|
53
58
|
def setup
|
54
59
|
@example = -> do
|
55
60
|
byebug
|
@@ -101,7 +106,7 @@ module Byebug
|
|
101
106
|
|
102
107
|
def test_next_goes_the_specified_number_of_lines_forward_by_default
|
103
108
|
enter 'set forcestep', 'next 2'
|
104
|
-
debug_proc(@example) { assert_equal
|
109
|
+
debug_proc(@example) { assert_equal 63, state.line }
|
105
110
|
end
|
106
111
|
|
107
112
|
def test_next_informs_when_not_staying_in_the_same_frame
|
@@ -113,35 +118,37 @@ module Byebug
|
|
113
118
|
|
114
119
|
def step_goes_the_specified_number_of_statements_forward_by_default
|
115
120
|
enter 'set forcestep', 'step 2'
|
116
|
-
debug_proc(@example) { assert_equal
|
121
|
+
debug_proc(@example) { assert_equal 63, state.line }
|
117
122
|
end
|
118
123
|
|
119
124
|
def test_next_steps_OVER_blocks
|
120
|
-
enter 'break
|
121
|
-
debug_proc(@example) { assert_equal
|
125
|
+
enter 'break 63', 'cont', 'next'
|
126
|
+
debug_proc(@example) { assert_equal 67, state.line }
|
122
127
|
end
|
123
128
|
|
124
129
|
def test_step_steps_INTO_blocks
|
125
|
-
enter 'break
|
126
|
-
debug_proc(@example) { assert_equal
|
130
|
+
enter 'break 63', 'cont', 'step'
|
131
|
+
debug_proc(@example) { assert_equal 64, state.line }
|
127
132
|
end
|
133
|
+
end
|
128
134
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
+
class RaiseFromCMethodExample
|
136
|
+
def a
|
137
|
+
b
|
138
|
+
rescue NameError
|
139
|
+
1
|
140
|
+
end
|
135
141
|
|
136
|
-
|
137
|
-
|
138
|
-
|
142
|
+
def b
|
143
|
+
c
|
144
|
+
end
|
139
145
|
|
140
|
-
|
141
|
-
|
142
|
-
end
|
146
|
+
def c
|
147
|
+
d
|
143
148
|
end
|
149
|
+
end
|
144
150
|
|
151
|
+
class RaiseFromCMethodTestCase < TestCase
|
145
152
|
def test_next_steps_over_rescue_when_raising_from_c_method
|
146
153
|
example_raise = -> do
|
147
154
|
byebug
|
@@ -149,26 +156,28 @@ module Byebug
|
|
149
156
|
RaiseFromCMethodExample.new.a
|
150
157
|
end
|
151
158
|
|
152
|
-
enter 'break
|
153
|
-
debug_proc(example_raise) { assert_equal
|
159
|
+
enter 'break 137', 'cont', 'next'
|
160
|
+
debug_proc(example_raise) { assert_equal 139, state.line }
|
154
161
|
end
|
162
|
+
end
|
155
163
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
164
|
+
class RaiseFromRubyMethodExample
|
165
|
+
def a
|
166
|
+
b
|
167
|
+
rescue
|
168
|
+
1
|
169
|
+
end
|
162
170
|
|
163
|
-
|
164
|
-
|
165
|
-
|
171
|
+
def b
|
172
|
+
c
|
173
|
+
end
|
166
174
|
|
167
|
-
|
168
|
-
|
169
|
-
end
|
175
|
+
def c
|
176
|
+
raise 'bang'
|
170
177
|
end
|
178
|
+
end
|
171
179
|
|
180
|
+
class RaiseFromRubyMethodTestCase < TestCase
|
172
181
|
def test_next_steps_over_rescue_when_raising_from_ruby_method
|
173
182
|
example_raise = -> do
|
174
183
|
byebug
|
@@ -176,8 +185,8 @@ module Byebug
|
|
176
185
|
RaiseFromRubyMethodExample.new.a
|
177
186
|
end
|
178
187
|
|
179
|
-
enter 'break
|
180
|
-
debug_proc(example_raise) { assert_equal
|
188
|
+
enter 'break 166', 'cont', 'next'
|
189
|
+
debug_proc(example_raise) { assert_equal 168, state.line }
|
181
190
|
end
|
182
191
|
end
|
183
192
|
end
|
File without changes
|
File without changes
|
@@ -1,40 +1,4 @@
|
|
1
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
|
-
|
38
2
|
class UndisplayTestCase < TestCase
|
39
3
|
def setup
|
40
4
|
@example = -> do
|
@@ -50,8 +14,7 @@ module Byebug
|
|
50
14
|
def test_asks_for_confirmation
|
51
15
|
enter 'display d', 'display d + 1', 'undisplay'
|
52
16
|
debug_proc(@example)
|
53
|
-
|
54
|
-
'Clear all expressions? (y/n)', interface.confirm_queue
|
17
|
+
check_confirm_includes 'Clear all expressions? (y/n)'
|
55
18
|
end
|
56
19
|
|
57
20
|
def test_removes_all_expressions_from_list_if_confirmed
|
@@ -59,7 +22,7 @@ module Byebug
|
|
59
22
|
debug_proc(@example) do
|
60
23
|
assert_equal [[false, 'd'], [false, 'd + 1']], state.display
|
61
24
|
end
|
62
|
-
check_output_doesnt_include '1:
|
25
|
+
check_output_doesnt_include '1: d = 3', '2: d + 1 = 4'
|
63
26
|
end
|
64
27
|
|
65
28
|
def test_does_not_remove_all_expressions_from_list_unless_confirmed
|
@@ -68,7 +31,7 @@ module Byebug
|
|
68
31
|
assert_equal [[true, 'd'], [true, 'd + 1']], state.display
|
69
32
|
end
|
70
33
|
|
71
|
-
check_output_includes '1:
|
34
|
+
check_output_includes '1: d = 0', '2: d + 1 = 1'
|
72
35
|
end
|
73
36
|
|
74
37
|
def test_marks_specific_expression_from_list_as_inactive
|
@@ -82,8 +45,8 @@ module Byebug
|
|
82
45
|
def test_displays_only_the_active_position
|
83
46
|
enter 'display d', 'display d + 1', 'undisplay 1', 'next'
|
84
47
|
debug_proc(@example)
|
85
|
-
check_output_includes '2:
|
86
|
-
check_output_doesnt_include '1:
|
48
|
+
check_output_includes '2: d + 1 = 4'
|
49
|
+
check_output_doesnt_include '1: d = 3'
|
87
50
|
end
|
88
51
|
|
89
52
|
def test_disable_display_removes_the_expression_from_display_list
|
@@ -94,14 +57,13 @@ module Byebug
|
|
94
57
|
def test_disable_display_shows_an_error_if_no_displays_are_set
|
95
58
|
enter 'disable display 1'
|
96
59
|
debug_proc(@example)
|
97
|
-
|
98
|
-
'No display expressions have been set', interface.error_queue
|
60
|
+
check_error_includes 'No display expressions have been set'
|
99
61
|
end
|
100
62
|
|
101
63
|
def test_disable_display_shows_an_error_if_theres_no_such_display_position
|
102
64
|
enter 'display d', 'disable display 4'
|
103
65
|
debug_proc(@example)
|
104
|
-
|
66
|
+
check_error_includes \
|
105
67
|
'"disable display" argument "4" needs to be at most 1'
|
106
68
|
end
|
107
69
|
|
@@ -30,7 +30,7 @@ module Byebug
|
|
30
30
|
super
|
31
31
|
end
|
32
32
|
|
33
|
-
# we check a class minitest variable... brittle
|
33
|
+
# TODO: we check a class minitest variable... brittle...
|
34
34
|
['var class', 'v cl'].each do |cmd_alias|
|
35
35
|
define_method(:"test_#{cmd_alias}_shows_class_variables") do
|
36
36
|
enter cmd_alias
|
@@ -92,5 +92,14 @@ module Byebug
|
|
92
92
|
debug_proc(@example)
|
93
93
|
check_output_includes 'a => 4', 'b => nil', 'i => 1'
|
94
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
|
95
104
|
end
|
96
105
|
end
|
data/test/debugger_alias_test.rb
CHANGED
data/test/runner_test.rb
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
require 'byebug/runner'
|
2
|
+
|
3
|
+
module Byebug
|
4
|
+
|
5
|
+
class RunnerTest < TestCase
|
6
|
+
def setup
|
7
|
+
super
|
8
|
+
@old_argv = ARGV
|
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
|
+
Byebug::Runner.new.run
|
18
|
+
|
19
|
+
check_output_includes(/#{Byebug::VERSION}/)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_run_with_help_flag
|
23
|
+
ARGV.replace(%w(--help))
|
24
|
+
Byebug::Runner.new.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
|
+
Byebug::Runner.new.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
|
+
Byebug::Runner.new.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) { Byebug::Runner.new.run }
|
49
|
+
|
50
|
+
check_output_includes(/You must specify a program to debug.../)
|
51
|
+
end
|
52
|
+
|
53
|
+
def expect_it_debugs_script
|
54
|
+
Byebug.expects(:start)
|
55
|
+
Byebug::Runner.any_instance.expects(:debug_program)
|
56
|
+
Byebug.expects(:run_init_script)
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_run_with_a_script_to_debug
|
60
|
+
ARGV.replace(%w(my_script))
|
61
|
+
expect_it_debugs_script
|
62
|
+
|
63
|
+
Byebug::Runner.new.run
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_run_with_no_rc_option
|
67
|
+
ARGV.replace(%w(--no-rc my_script))
|
68
|
+
Byebug.expects(:start)
|
69
|
+
Byebug::Runner.any_instance.expects(:debug_program)
|
70
|
+
Byebug.expects(:run_init_script).never
|
71
|
+
|
72
|
+
Byebug::Runner.new.run
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_run_with_post_mortem_mode_flag
|
76
|
+
ARGV.replace(%w(-m my_script))
|
77
|
+
expect_it_debugs_script
|
78
|
+
|
79
|
+
Byebug::Runner.new.run
|
80
|
+
assert_equal true, Byebug.post_mortem?
|
81
|
+
Byebug::Setting[:post_mortem] = false
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_run_with_linetracing_flag
|
85
|
+
ARGV.replace(%w(-t my_script))
|
86
|
+
expect_it_debugs_script
|
87
|
+
|
88
|
+
Byebug::Runner.new.run
|
89
|
+
assert_equal true, Byebug.tracing?
|
90
|
+
Byebug::Setting[:linetrace] = false
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_run_with_no_quit_flag
|
94
|
+
skip 'for now'
|
95
|
+
ARGV.replace(%w(--no-quit my_script))
|
96
|
+
|
97
|
+
Byebug::Runner.new.run
|
98
|
+
check_output_includes('(byebug:ctrl)')
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_run_with_require_flag
|
102
|
+
ARGV.replace(%w(-r abbrev my_script))
|
103
|
+
expect_it_debugs_script
|
104
|
+
|
105
|
+
Byebug::Runner.new.run
|
106
|
+
hsh = { 'can' => 'can', 'cat' => 'cat' }
|
107
|
+
assert_equal hsh, %w(can cat).abbrev
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_run_with_include_flag
|
111
|
+
ARGV.replace(%w(-I custom_dir my_script))
|
112
|
+
expect_it_debugs_script
|
113
|
+
|
114
|
+
Byebug::Runner.new.run
|
115
|
+
assert_includes $LOAD_PATH, 'custom_dir'
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_run_with_debug_flag
|
119
|
+
ARGV.replace(%w(-d my_script))
|
120
|
+
expect_it_debugs_script
|
121
|
+
|
122
|
+
Byebug::Runner.new.run
|
123
|
+
assert_equal $DEBUG, true
|
124
|
+
$DEBUG = false
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|