debugger 1.2.4 → 1.3.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.
- data/.gitignore +14 -0
- data/.travis.yml +0 -1
- data/CHANGELOG.md +9 -0
- data/Gemfile +3 -0
- data/README.md +2 -0
- data/Rakefile +3 -55
- data/debugger.gemspec +2 -0
- data/lib/debugger/version.rb +1 -1
- data/lib/ruby-debug-base.rb +3 -1
- data/lib/ruby-debug/commands/irb.rb +1 -1
- data/lib/ruby-debug/commands/jump.rb +1 -1
- data/lib/ruby-debug/commands/method.rb +1 -1
- data/lib/ruby-debug/commands/show.rb +1 -1
- data/lib/ruby-debug/commands/trace.rb +2 -2
- data/lib/ruby-debug/commands/variables.rb +3 -3
- data/test/breakpoints_test.rb +365 -0
- data/test/conditions_test.rb +76 -0
- data/test/continue_test.rb +28 -0
- data/test/display_test.rb +141 -0
- data/test/edit_test.rb +55 -0
- data/test/eval_test.rb +92 -0
- data/test/examples/breakpoint1.rb +15 -0
- data/test/examples/breakpoint2.rb +7 -0
- data/test/examples/conditions.rb +4 -0
- data/test/examples/continue.rb +4 -0
- data/test/examples/display.rb +5 -0
- data/test/examples/edit.rb +3 -0
- data/test/examples/edit2.rb +3 -0
- data/test/examples/eval.rb +4 -0
- data/test/examples/finish.rb +20 -0
- data/test/examples/frame.rb +31 -0
- data/test/examples/help.rb +2 -0
- data/test/examples/info.rb +48 -0
- data/test/examples/info2.rb +3 -0
- data/test/examples/irb.rb +6 -0
- data/test/examples/jump.rb +14 -0
- data/test/examples/kill.rb +2 -0
- data/test/examples/list.rb +12 -0
- data/test/examples/method.rb +15 -0
- data/test/examples/post_mortem.rb +19 -0
- data/test/examples/quit.rb +2 -0
- data/test/examples/reload.rb +6 -0
- data/test/examples/restart.rb +6 -0
- data/test/examples/save.rb +3 -0
- data/test/examples/set.rb +3 -0
- data/test/examples/set_annotate.rb +12 -0
- data/test/examples/settings.rb +1 -0
- data/test/examples/show.rb +2 -0
- data/test/examples/source.rb +3 -0
- data/test/examples/stepping.rb +21 -0
- data/test/examples/thread.rb +32 -0
- data/test/examples/tmate.rb +10 -0
- data/test/examples/trace.rb +7 -0
- data/test/examples/trace_threads.rb +20 -0
- data/test/examples/variables.rb +26 -0
- data/test/finish_test.rb +48 -0
- data/test/frame_test.rb +140 -0
- data/test/help_test.rb +50 -0
- data/test/info_test.rb +325 -0
- data/test/irb_test.rb +81 -0
- data/test/jump_test.rb +70 -0
- data/test/kill_test.rb +47 -0
- data/test/list_test.rb +145 -0
- data/test/method_test.rb +70 -0
- data/test/post_mortem_test.rb +25 -0
- data/test/quit_test.rb +55 -0
- data/test/reload_test.rb +43 -0
- data/test/restart_test.rb +143 -0
- data/test/save_test.rb +92 -0
- data/test/set_test.rb +163 -0
- data/test/show_test.rb +292 -0
- data/test/source_test.rb +44 -0
- data/test/stepping_test.rb +118 -0
- data/test/support/breakpoint.rb +12 -0
- data/test/support/context.rb +14 -0
- data/test/support/matchers.rb +67 -0
- data/test/support/mocha_extensions.rb +71 -0
- data/test/support/processor.rb +7 -0
- data/test/support/test_dsl.rb +205 -0
- data/test/support/test_interface.rb +66 -0
- data/test/test_helper.rb +8 -0
- data/test/thread_test.rb +122 -0
- data/test/tmate_test.rb +43 -0
- data/test/trace_test.rb +154 -0
- data/test/variables_test.rb +114 -0
- metadata +107 -158
- data/test/base/base.rb +0 -71
- data/test/base/binding.rb +0 -24
- data/test/base/catchpoint.rb +0 -22
- data/test/base/load.rb +0 -36
- data/test/bp_loop_issue.rb +0 -3
- data/test/classes.rb +0 -11
- data/test/config.yaml +0 -8
- data/test/data/annotate.cmd +0 -29
- data/test/data/annotate.right +0 -139
- data/test/data/break_bad.cmd +0 -18
- data/test/data/break_bad.right +0 -28
- data/test/data/break_loop_bug.cmd +0 -5
- data/test/data/break_loop_bug.right +0 -15
- data/test/data/breakpoints.cmd +0 -38
- data/test/data/breakpoints.right +0 -98
- data/test/data/catch.cmd +0 -20
- data/test/data/catch.right +0 -49
- data/test/data/catch2.cmd +0 -19
- data/test/data/catch2.right +0 -65
- data/test/data/catch3.cmd +0 -11
- data/test/data/catch3.right +0 -37
- data/test/data/condition.cmd +0 -28
- data/test/data/condition.right +0 -65
- data/test/data/ctrl.cmd +0 -23
- data/test/data/ctrl.right +0 -70
- data/test/data/display.cmd +0 -24
- data/test/data/display.right +0 -44
- data/test/data/dollar-0.right +0 -2
- data/test/data/dollar-0a.right +0 -2
- data/test/data/dollar-0b.right +0 -2
- data/test/data/edit.cmd +0 -12
- data/test/data/edit.right +0 -19
- data/test/data/emacs_basic.cmd +0 -43
- data/test/data/emacs_basic.right +0 -106
- data/test/data/enable.cmd +0 -20
- data/test/data/enable.right +0 -36
- data/test/data/finish.cmd +0 -16
- data/test/data/finish.right +0 -31
- data/test/data/frame.cmd +0 -26
- data/test/data/frame.right +0 -55
- data/test/data/help.cmd +0 -20
- data/test/data/help.right +0 -21
- data/test/data/history.right +0 -7
- data/test/data/info-thread.cmd +0 -13
- data/test/data/info-thread.right +0 -37
- data/test/data/info-var-bug2.cmd +0 -5
- data/test/data/info-var-bug2.right +0 -10
- data/test/data/info-var.cmd +0 -23
- data/test/data/info-var.right +0 -52
- data/test/data/info.cmd +0 -21
- data/test/data/info.right +0 -65
- data/test/data/jump.cmd +0 -16
- data/test/data/jump.right +0 -56
- data/test/data/jump2.cmd +0 -16
- data/test/data/jump2.right +0 -44
- data/test/data/linetrace.cmd +0 -6
- data/test/data/linetrace.right +0 -23
- data/test/data/list.cmd +0 -19
- data/test/data/list.right +0 -127
- data/test/data/method.cmd +0 -10
- data/test/data/method.right +0 -21
- data/test/data/methodsig.cmd +0 -10
- data/test/data/methodsig.right +0 -20
- data/test/data/next.cmd +0 -22
- data/test/data/next.right +0 -61
- data/test/data/noquit.right +0 -1
- data/test/data/output.cmd +0 -6
- data/test/data/output.right +0 -31
- data/test/data/pm-bug.cmd +0 -7
- data/test/data/pm-bug.right +0 -12
- data/test/data/post-mortem-next.cmd +0 -8
- data/test/data/post-mortem-next.right +0 -14
- data/test/data/post-mortem-osx.right +0 -31
- data/test/data/post-mortem.cmd +0 -13
- data/test/data/post-mortem.right +0 -32
- data/test/data/quit.cmd +0 -6
- data/test/data/quit.right +0 -0
- data/test/data/raise.cmd +0 -11
- data/test/data/raise.right +0 -23
- data/test/data/save.cmd +0 -34
- data/test/data/save.right +0 -59
- data/test/data/scope-var.cmd +0 -42
- data/test/data/scope-var.right +0 -587
- data/test/data/setshow.cmd +0 -56
- data/test/data/setshow.right +0 -98
- data/test/data/source.cmd +0 -5
- data/test/data/source.right +0 -15
- data/test/data/stepping.cmd +0 -21
- data/test/data/stepping.right +0 -50
- data/test/data/test-init-cygwin.right +0 -7
- data/test/data/test-init-osx.right +0 -4
- data/test/data/test-init.right +0 -5
- data/test/data/trace.right +0 -14
- data/test/dollar-0.rb +0 -5
- data/test/gcd-dbg-nox.rb +0 -30
- data/test/gcd-dbg.rb +0 -29
- data/test/gcd.rb +0 -18
- data/test/helper.rb +0 -142
- data/test/info-var-bug.rb +0 -47
- data/test/info-var-bug2.rb +0 -2
- data/test/jump.rb +0 -14
- data/test/jump2.rb +0 -27
- data/test/lib/commands/catchpoint_test.rb +0 -28
- data/test/lib/commands/unit/regexp.rb +0 -38
- data/test/next.rb +0 -18
- data/test/null.rb +0 -1
- data/test/output.rb +0 -2
- data/test/pm-base.rb +0 -17
- data/test/pm-bug.rb +0 -3
- data/test/pm-catch.rb +0 -12
- data/test/pm-catch2.rb +0 -27
- data/test/pm-catch3.rb +0 -47
- data/test/pm.rb +0 -11
- data/test/raise.rb +0 -3
- data/test/rdebug-save.1 +0 -7
- data/test/runall +0 -12
- data/test/scope-var.rb +0 -29
- data/test/tdebug.rb +0 -246
- data/test/test-annotate.rb +0 -24
- data/test/test-break-bad.rb +0 -36
- data/test/test-breakpoints.rb +0 -24
- data/test/test-catch.rb +0 -24
- data/test/test-catch2.rb +0 -24
- data/test/test-catch3.rb +0 -24
- data/test/test-condition.rb +0 -24
- data/test/test-ctrl.rb +0 -51
- data/test/test-display.rb +0 -25
- data/test/test-dollar-0.rb +0 -39
- data/test/test-edit.rb +0 -25
- data/test/test-emacs-basic.rb +0 -25
- data/test/test-enable.rb +0 -24
- data/test/test-finish.rb +0 -33
- data/test/test-frame.rb +0 -33
- data/test/test-help.rb +0 -54
- data/test/test-hist.rb +0 -65
- data/test/test-info-thread.rb +0 -31
- data/test/test-info-var.rb +0 -46
- data/test/test-info.rb +0 -25
- data/test/test-init.rb +0 -43
- data/test/test-jump.rb +0 -34
- data/test/test-list.rb +0 -24
- data/test/test-method.rb +0 -33
- data/test/test-next.rb +0 -24
- data/test/test-output.rb +0 -25
- data/test/test-quit.rb +0 -29
- data/test/test-raise.rb +0 -24
- data/test/test-remote.rb +0 -14
- data/test/test-save.rb +0 -30
- data/test/test-scope-var.rb +0 -24
- data/test/test-setshow.rb +0 -24
- data/test/test-source.rb +0 -24
- data/test/test-stepping.rb +0 -25
- data/test/test-trace.rb +0 -46
- data/test/thread1.rb +0 -25
- data/test/trunc-call.rb +0 -30
data/test/help_test.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe "Help Command" do
|
4
|
+
include TestDsl
|
5
|
+
include Columnize
|
6
|
+
|
7
|
+
let(:available_commands) do
|
8
|
+
Debugger::Command.commands.select(&:event).map(&:help_command).flatten.uniq.sort
|
9
|
+
end
|
10
|
+
|
11
|
+
it "must show help how to use 'help'" do
|
12
|
+
temporary_change_hash_value(Debugger::HelpCommand.settings, :width, 50) do
|
13
|
+
enter 'help'
|
14
|
+
debug_file('help')
|
15
|
+
check_output_includes(
|
16
|
+
"Type 'help <command-name>' for help on a specific command",
|
17
|
+
"Available commands:",
|
18
|
+
columnize(available_commands, 50)
|
19
|
+
)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
it "must show help when use shortcut" do
|
24
|
+
enter 'h'
|
25
|
+
debug_file('help')
|
26
|
+
check_output_includes "Type 'help <command-name>' for help on a specific command"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "must show an error if undefined command is specified" do
|
30
|
+
enter 'help foobar'
|
31
|
+
debug_file('help')
|
32
|
+
check_output_includes 'Undefined command: "foobar". Try "help".', interface.error_queue
|
33
|
+
end
|
34
|
+
|
35
|
+
it "must show a command's help" do
|
36
|
+
enter 'help break'
|
37
|
+
debug_file('help')
|
38
|
+
check_output_includes Debugger::AddBreakpoint.help(nil).split("\n").map { |l| l.gsub(/^ +/, '') }.join("\n")
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
describe "Post Mortem" do
|
43
|
+
it "must work in post-mortem mode" do
|
44
|
+
enter 'cont', 'help'
|
45
|
+
debug_file "post_mortem"
|
46
|
+
check_output_includes "Available commands:"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
data/test/info_test.rb
ADDED
@@ -0,0 +1,325 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe "Info Command" do
|
4
|
+
include TestDsl
|
5
|
+
include Columnize
|
6
|
+
|
7
|
+
describe "Args info" do
|
8
|
+
temporary_change_hash_value(Debugger::InfoCommand.settings, :width, 15)
|
9
|
+
|
10
|
+
it "must show info about all args" do
|
11
|
+
enter 'break 3', 'cont', 'info args'
|
12
|
+
debug_file 'info'
|
13
|
+
check_output_includes 'a = "aaaaaaa...', 'b = "b"'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "Breakpoints info" do
|
18
|
+
it "must show info about all breakpoints" do
|
19
|
+
enter 'break 7', 'break 9 if a == b', 'info breakpoints'
|
20
|
+
debug_file 'info'
|
21
|
+
check_output_includes(
|
22
|
+
"Num Enb What",
|
23
|
+
/\d+ y at #{fullpath('info')}:7/,
|
24
|
+
/\d+ y at #{fullpath('info')}:9 if a == b/
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "must show info about specific breakpoint" do
|
29
|
+
enter 'break 7', 'break 9', ->{"info breakpoints #{breakpoint.id}"}
|
30
|
+
debug_file 'info'
|
31
|
+
check_output_includes "Num Enb What", /\d+ y at #{fullpath('info')}:7/
|
32
|
+
check_output_doesnt_include /\d+ y at #{fullpath('info')}:9/
|
33
|
+
end
|
34
|
+
|
35
|
+
it "must show an error if no breakpoints are found" do
|
36
|
+
enter 'info breakpoints'
|
37
|
+
debug_file 'info'
|
38
|
+
check_output_includes "No breakpoints."
|
39
|
+
end
|
40
|
+
|
41
|
+
it "must show an error if no breakpoints are found" do
|
42
|
+
enter 'break 7', 'info breakpoints 123'
|
43
|
+
debug_file 'info'
|
44
|
+
check_output_includes "No breakpoints found among list given.", interface.error_queue
|
45
|
+
end
|
46
|
+
|
47
|
+
it "must show hit count" do
|
48
|
+
enter 'break 9', 'cont', 'info breakpoints'
|
49
|
+
debug_file 'info'
|
50
|
+
check_output_includes /\d+ y at #{fullpath('info')}:9/, "breakpoint already hit 1 time"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "Display info" do
|
55
|
+
it "must show all display expressions" do
|
56
|
+
enter 'display 3 + 3', 'display a + b', 'info display'
|
57
|
+
debug_file 'info'
|
58
|
+
check_output_includes(
|
59
|
+
"Auto-display expressions now in effect:",
|
60
|
+
"Num Enb Expression",
|
61
|
+
"1: y 3 + 3",
|
62
|
+
"2: y a + b"
|
63
|
+
)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "must show a message if there are no display expressions created" do
|
67
|
+
enter 'info display'
|
68
|
+
debug_file 'info'
|
69
|
+
check_output_includes "There are no auto-display expressions now."
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "Files info" do
|
74
|
+
let(:files) { (LineCache.cached_files + SCRIPT_LINES__.keys).uniq.sort }
|
75
|
+
it "must show all files read in" do
|
76
|
+
enter 'info files'
|
77
|
+
debug_file 'info'
|
78
|
+
check_output_includes files.map { |f| "File #{f}" }
|
79
|
+
end
|
80
|
+
|
81
|
+
it "must show all files read in using 'info file' too" do
|
82
|
+
enter 'info file'
|
83
|
+
debug_file 'info'
|
84
|
+
check_output_includes files.map { |f| "File #{f}" }
|
85
|
+
end
|
86
|
+
|
87
|
+
it "must show explicitly loaded files" do
|
88
|
+
enter 'info files stat'
|
89
|
+
debug_file 'info'
|
90
|
+
check_output_includes "File #{fullpath('info')}", LineCache.stat(fullpath('info')).mtime.to_s
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe "File info" do
|
95
|
+
let(:file) { fullpath('info') }
|
96
|
+
let(:filename) { "File #{file}" }
|
97
|
+
let(:lines) { "#{LineCache.size(file)} lines" }
|
98
|
+
let(:mtime) { LineCache.stat(file).mtime.to_s }
|
99
|
+
let(:sha1) { LineCache.sha1(file) }
|
100
|
+
let(:breakpoint_line_numbers) do
|
101
|
+
columnize(LineCache.trace_line_numbers(file).to_a.sort, Debugger::InfoCommand.settings[:width])
|
102
|
+
end
|
103
|
+
|
104
|
+
it "must show basic about the file" do
|
105
|
+
enter "info file #{file} basic"
|
106
|
+
debug_file 'info'
|
107
|
+
check_output_includes filename, lines
|
108
|
+
check_output_doesnt_include breakpoint_line_numbers, mtime, sha1
|
109
|
+
end
|
110
|
+
|
111
|
+
it "must show number of lines" do
|
112
|
+
enter "info file #{file} lines"
|
113
|
+
debug_file 'info'
|
114
|
+
check_output_includes filename, lines
|
115
|
+
check_output_doesnt_include breakpoint_line_numbers, mtime, sha1
|
116
|
+
end
|
117
|
+
|
118
|
+
it "must show mtime of the file" do
|
119
|
+
enter "info file #{file} mtime"
|
120
|
+
debug_file 'info'
|
121
|
+
check_output_includes filename, mtime
|
122
|
+
check_output_doesnt_include lines, breakpoint_line_numbers, sha1
|
123
|
+
end
|
124
|
+
|
125
|
+
it "must show sha1 of the file" do
|
126
|
+
enter "info file #{file} sha1"
|
127
|
+
debug_file 'info'
|
128
|
+
check_output_includes filename, sha1
|
129
|
+
check_output_doesnt_include lines, breakpoint_line_numbers, mtime
|
130
|
+
end
|
131
|
+
|
132
|
+
it "must show breakpoints in the file" do
|
133
|
+
enter 'break 5', 'break 7', "info file #{file} breakpoints"
|
134
|
+
debug_file 'info'
|
135
|
+
check_output_includes(
|
136
|
+
filename, "breakpoint line numbers:", breakpoint_line_numbers,
|
137
|
+
/Breakpoint \d+ at #{file}:5/, /Breakpoint \d+ at #{file}:7/
|
138
|
+
)
|
139
|
+
check_output_doesnt_include lines, mtime, sha1
|
140
|
+
end
|
141
|
+
|
142
|
+
it "must show all info about the file" do
|
143
|
+
enter "info file #{file} all"
|
144
|
+
debug_file 'info'
|
145
|
+
check_output_includes filename, lines, breakpoint_line_numbers, mtime, sha1
|
146
|
+
end
|
147
|
+
|
148
|
+
it "must not show info about the file if the file is not loaded" do
|
149
|
+
enter "info file #{fullpath('info2')} basic"
|
150
|
+
debug_file 'info'
|
151
|
+
check_output_includes "File #{fullpath('info2')} is not cached"
|
152
|
+
end
|
153
|
+
|
154
|
+
it "must not show any info if the parameter is invalid" do
|
155
|
+
enter "info file #{file} blabla"
|
156
|
+
debug_file 'info'
|
157
|
+
check_output_includes "Invalid parameter blabla", interface.error_queue
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
describe "Instance variables info" do
|
162
|
+
it "must show instance variables" do
|
163
|
+
enter 'break 21', 'cont', 'info instance_variables'
|
164
|
+
debug_file 'info'
|
165
|
+
check_output_includes '@bla = "blabla"', '@foo = "bar"'
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
describe "Line info" do
|
170
|
+
it "must show the current line" do
|
171
|
+
enter 'break 21', 'cont', 'info line'
|
172
|
+
debug_file 'info'
|
173
|
+
check_output_includes "Line 21 of \"#{fullpath('info')}\""
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
describe "Locals info" do
|
178
|
+
it "must show the current local variables" do
|
179
|
+
temporary_change_hash_value(Debugger::InfoCommand.settings, :width, 12) do
|
180
|
+
enter 'break 21', 'cont', 'info locals'
|
181
|
+
debug_file 'info'
|
182
|
+
check_output_includes 'a = "1111...', 'b = 2'
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
it "must fail if the local variable doesn't respond to #to_s or to #inspect" do
|
187
|
+
enter 'break 26', 'cont', 'info locals'
|
188
|
+
debug_file 'info'
|
189
|
+
check_output_includes "*Error in evaluation*"
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
describe "Program info" do
|
194
|
+
it "must show the initial stop reason" do
|
195
|
+
enter 'info program'
|
196
|
+
debug_file 'info'
|
197
|
+
check_output_includes "It stopped after stepping, next'ing or initial start."
|
198
|
+
end
|
199
|
+
|
200
|
+
it "must show the step stop reason" do
|
201
|
+
enter 'step', 'info program'
|
202
|
+
debug_file 'info'
|
203
|
+
check_output_includes "Program stopped.", "It stopped after stepping, next'ing or initial start."
|
204
|
+
end
|
205
|
+
|
206
|
+
it "must show the breakpoint stop reason" do
|
207
|
+
enter 'break 7', 'cont', 'info program'
|
208
|
+
debug_file 'info'
|
209
|
+
check_output_includes "Program stopped.", "It stopped at a breakpoint."
|
210
|
+
end
|
211
|
+
|
212
|
+
it "must show the catchpoint stop reason"
|
213
|
+
|
214
|
+
it "must show the unknown stop reason" do
|
215
|
+
enter 'break 7', 'cont', ->{context.stubs(:stop_reason).returns("blabla"); 'info program'}
|
216
|
+
debug_file 'info'
|
217
|
+
check_output_includes "Program stopped.", "unknown reason: blabla"
|
218
|
+
end
|
219
|
+
|
220
|
+
it "must show an error if the program is crashed"
|
221
|
+
end
|
222
|
+
|
223
|
+
describe "Stack info" do
|
224
|
+
it "must show stack info" do
|
225
|
+
enter 'break 20', 'cont', 'info stack'
|
226
|
+
debug_file 'info'
|
227
|
+
check_output_includes(
|
228
|
+
"-->", "#0", "A.a", "at line #{fullpath('info')}:20",
|
229
|
+
"#1", "at line #{fullpath('info')}:30"
|
230
|
+
)
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
describe "Threads info" do
|
235
|
+
it "must show threads info" do
|
236
|
+
enter 'break 36', 'cont', 'info threads'
|
237
|
+
debug_file 'info'
|
238
|
+
check_output_includes /#<Thread:\S+ run>/
|
239
|
+
end
|
240
|
+
|
241
|
+
it "must show verbose threads info" # TODO: Unreliable due to race conditions, need to fix to be reliable
|
242
|
+
# enter 'break 20', 'cont', ->{sleep 0.01; "info threads verbose"}
|
243
|
+
# debug_file 'info'
|
244
|
+
# check_output_includes /#<Thread:\S+ run>/, "#0", "A.a", "at line #{fullpath('info')}:20"
|
245
|
+
#end
|
246
|
+
end
|
247
|
+
|
248
|
+
describe "Thread info" do
|
249
|
+
it "must show threads info when without args" # TODO: Unreliable due to race conditions, need to fix to be reliable
|
250
|
+
# enter 'break 48', 'cont', 'info threads'
|
251
|
+
# debug_file 'info'
|
252
|
+
# check_output_includes /#<Thread:\S+ run>/, /#<Thread:\S+ run>/
|
253
|
+
# end
|
254
|
+
|
255
|
+
it "must show thread info" do
|
256
|
+
thread_number = nil
|
257
|
+
enter ->{thread_number = context.thnum; "info thread #{context.thnum}"}
|
258
|
+
debug_file 'info'
|
259
|
+
check_output_includes "+", thread_number.to_s, /#<Thread:\S+ run>/
|
260
|
+
end
|
261
|
+
|
262
|
+
it "must show verbose thread info" do
|
263
|
+
enter 'break 20', 'cont', ->{"info thread #{context.thnum} verbose"}
|
264
|
+
debug_file 'info'
|
265
|
+
check_output_includes /#<Thread:\S+ run>/, "#0", "A.a", "at line #{fullpath('info')}:20"
|
266
|
+
end
|
267
|
+
|
268
|
+
it "must show error when unknown parameter is used" do
|
269
|
+
enter ->{"info thread #{context.thnum} blabla"}
|
270
|
+
debug_file 'info'
|
271
|
+
check_output_includes "'terse' or 'verbose' expected. Got 'blabla'", interface.error_queue
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
describe "Global Variables info" do
|
276
|
+
it "must show global variables" do
|
277
|
+
enter 'info global_variables'
|
278
|
+
debug_file 'info'
|
279
|
+
check_output_includes "$$ = #{Process.pid}"
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
describe "Variables info" do
|
284
|
+
it "must show all variables" do
|
285
|
+
temporary_change_hash_value(Debugger::InfoCommand.settings, :width, 30) do
|
286
|
+
enter 'break 21', 'cont', 'info variables'
|
287
|
+
debug_file 'info'
|
288
|
+
check_output_includes(
|
289
|
+
'a = "1111111111111111111111...',
|
290
|
+
"b = 2",
|
291
|
+
/self = #<A:\S+.../,
|
292
|
+
'@bla = "blabla"',
|
293
|
+
'@foo = "bar"'
|
294
|
+
)
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
it "must fail if the variable doesn't respond to #to_s or to #inspect" do
|
299
|
+
enter 'break 26', 'cont', 'info variables'
|
300
|
+
debug_file 'info'
|
301
|
+
check_output_includes(
|
302
|
+
'a = *Error in evaluation*',
|
303
|
+
/self = #<A:\S+.../,
|
304
|
+
'@bla = "blabla"',
|
305
|
+
'@foo = "bar"'
|
306
|
+
)
|
307
|
+
end
|
308
|
+
|
309
|
+
it "must handle printf strings correctly" do
|
310
|
+
enter 'break 32', 'cont', 'info variables'
|
311
|
+
debug_file 'info'
|
312
|
+
check_output_includes 'e = "%%.2f"'
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
|
317
|
+
describe "Post Mortem" do
|
318
|
+
it "must work in post-mortem mode" do
|
319
|
+
enter 'cont', 'info line'
|
320
|
+
debug_file "post_mortem"
|
321
|
+
check_output_includes "Line 8 of \"#{fullpath('post_mortem')}\""
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
325
|
+
end
|
data/test/irb_test.rb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe "Irb Command" do
|
4
|
+
include TestDsl
|
5
|
+
before do
|
6
|
+
interface.stubs(:kind_of?).with(Debugger::LocalInterface).returns(true)
|
7
|
+
IRB::Irb.stubs(:new).returns(irb)
|
8
|
+
Signal.trap("SIGINT", "IGNORE")
|
9
|
+
end
|
10
|
+
after do
|
11
|
+
Signal.trap("SIGINT", "DEFAULT")
|
12
|
+
end
|
13
|
+
let(:irb) { stub(context: ->{}) }
|
14
|
+
|
15
|
+
it "must support next command" do
|
16
|
+
irb.stubs(:eval_input).throws(:IRB_EXIT, :next)
|
17
|
+
enter 'irb'
|
18
|
+
debug_file('irb') { state.line.must_equal 3 }
|
19
|
+
end
|
20
|
+
|
21
|
+
it "must support step command" do
|
22
|
+
irb.stubs(:eval_input).throws(:IRB_EXIT, :step)
|
23
|
+
enter 'irb'
|
24
|
+
debug_file('irb') { state.line.must_equal 3 }
|
25
|
+
end
|
26
|
+
|
27
|
+
it "must support cont command" do
|
28
|
+
irb.stubs(:eval_input).throws(:IRB_EXIT, :cont)
|
29
|
+
enter 'break 4', 'irb'
|
30
|
+
debug_file('irb') { state.line.must_equal 4 }
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "autoirb" do
|
34
|
+
temporary_change_hash_value(Debugger::Command.settings, :autoirb, 0)
|
35
|
+
|
36
|
+
it "must call irb automatically after breakpoint" do
|
37
|
+
irb.expects(:eval_input)
|
38
|
+
enter 'set autoirb', 'break 4', 'cont'
|
39
|
+
debug_file 'irb'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# TODO: Can't reliably test the signal, from time to time Signal.trap, which is defined in IRBCommand, misses
|
44
|
+
# the SIGINT signal, which makes the test suite exit. Not sure how to fix that...
|
45
|
+
it "must translate SIGINT into 'cont' command" # do
|
46
|
+
# irb.stubs(:eval_input).calls { Process.kill("SIGINT", Process.pid) }
|
47
|
+
# enter 'break 4', 'irb'
|
48
|
+
# debug_file('irb') { state.line.must_equal 4 }
|
49
|
+
#end
|
50
|
+
|
51
|
+
describe "setting context to $rdebug_state" do
|
52
|
+
before { $rdebug_state = nil }
|
53
|
+
temporary_change_hash_value(Debugger::Command.settings, :debuggertesting, false)
|
54
|
+
|
55
|
+
it "must set $rdebug_state if irb is in the debug mode" do
|
56
|
+
rdebug_state = nil
|
57
|
+
irb.stubs(:eval_input).calls { rdebug_state = $rdebug_state }
|
58
|
+
enter 'irb -d'
|
59
|
+
debug_file('irb')
|
60
|
+
rdebug_state.must_be_kind_of Debugger::CommandProcessor::State
|
61
|
+
end
|
62
|
+
|
63
|
+
it "must not set $rdebug_state if irb is not in the debug mode" do
|
64
|
+
rdebug_state = nil
|
65
|
+
irb.stubs(:eval_input).calls { rdebug_state = $rdebug_state }
|
66
|
+
enter 'irb'
|
67
|
+
debug_file('irb')
|
68
|
+
rdebug_state.must_be_nil
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
describe "Post Mortem" do
|
74
|
+
it "must work in post-mortem mode" do
|
75
|
+
irb.stubs(:eval_input).throws(:IRB_EXIT, :cont)
|
76
|
+
enter 'cont', 'break 12', 'irb'
|
77
|
+
debug_file("post_mortem") { state.line.must_equal 12 }
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|