needy_debugger 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. data/.gitignore +14 -0
  2. data/.travis.yml +8 -0
  3. data/AUTHORS +10 -0
  4. data/CHANGELOG.md +68 -0
  5. data/CONTRIBUTING.md +1 -0
  6. data/Gemfile +3 -0
  7. data/LICENSE +23 -0
  8. data/OLDER_CHANGELOG +334 -0
  9. data/OLD_CHANGELOG +5655 -0
  10. data/OLD_README +122 -0
  11. data/README.md +141 -0
  12. data/Rakefile +78 -0
  13. data/bin/rdebug +397 -0
  14. data/doc/.cvsignore +42 -0
  15. data/doc/Makefile.am +63 -0
  16. data/doc/emacs-notes.txt +38 -0
  17. data/doc/hanoi.rb +35 -0
  18. data/doc/primes.rb +28 -0
  19. data/doc/rdebug-emacs.texi +1030 -0
  20. data/doc/ruby-debug.texi +3791 -0
  21. data/doc/test-tri2.rb +18 -0
  22. data/doc/tri3.rb +8 -0
  23. data/doc/triangle.rb +12 -0
  24. data/emacs/Makefile.am +130 -0
  25. data/emacs/rdebug-annotate.el +385 -0
  26. data/emacs/rdebug-breaks.el +407 -0
  27. data/emacs/rdebug-cmd.el +92 -0
  28. data/emacs/rdebug-core.el +502 -0
  29. data/emacs/rdebug-dbg.el +62 -0
  30. data/emacs/rdebug-error.el +79 -0
  31. data/emacs/rdebug-fns.el +111 -0
  32. data/emacs/rdebug-frames.el +230 -0
  33. data/emacs/rdebug-gud.el +242 -0
  34. data/emacs/rdebug-help.el +104 -0
  35. data/emacs/rdebug-info.el +83 -0
  36. data/emacs/rdebug-layouts.el +180 -0
  37. data/emacs/rdebug-locring.el +118 -0
  38. data/emacs/rdebug-output.el +106 -0
  39. data/emacs/rdebug-regexp.el +118 -0
  40. data/emacs/rdebug-secondary.el +260 -0
  41. data/emacs/rdebug-shortkey.el +175 -0
  42. data/emacs/rdebug-source.el +568 -0
  43. data/emacs/rdebug-track.el +392 -0
  44. data/emacs/rdebug-varbuf.el +150 -0
  45. data/emacs/rdebug-vars.el +125 -0
  46. data/emacs/rdebug-watch.el +132 -0
  47. data/emacs/rdebug.el +326 -0
  48. data/emacs/test/elk-test.el +242 -0
  49. data/emacs/test/test-annotate.el +103 -0
  50. data/emacs/test/test-cmd.el +116 -0
  51. data/emacs/test/test-core.el +104 -0
  52. data/emacs/test/test-fns.el +65 -0
  53. data/emacs/test/test-frames.el +62 -0
  54. data/emacs/test/test-gud.el +35 -0
  55. data/emacs/test/test-indent.el +58 -0
  56. data/emacs/test/test-regexp.el +144 -0
  57. data/emacs/test/test-shortkey.el +61 -0
  58. data/ext/ruby_debug/192/breakpoint.c +586 -0
  59. data/ext/ruby_debug/192/ruby_debug.c +2645 -0
  60. data/ext/ruby_debug/192/ruby_debug.h +148 -0
  61. data/ext/ruby_debug/193/breakpoint.c +586 -0
  62. data/ext/ruby_debug/193/ruby_debug.c +2626 -0
  63. data/ext/ruby_debug/193/ruby_debug.h +148 -0
  64. data/ext/ruby_debug/200/breakpoint.c +586 -0
  65. data/ext/ruby_debug/200/ruby_debug.c +2692 -0
  66. data/ext/ruby_debug/200/ruby_debug.h +148 -0
  67. data/ext/ruby_debug/extconf.rb +94 -0
  68. data/lib/debugger.rb +5 -0
  69. data/lib/debugger/version.rb +5 -0
  70. data/lib/ruby-debug-base.rb +305 -0
  71. data/lib/ruby-debug.rb +177 -0
  72. data/lib/ruby-debug/command.rb +227 -0
  73. data/lib/ruby-debug/commands/breakpoints.rb +153 -0
  74. data/lib/ruby-debug/commands/catchpoint.rb +55 -0
  75. data/lib/ruby-debug/commands/condition.rb +49 -0
  76. data/lib/ruby-debug/commands/continue.rb +38 -0
  77. data/lib/ruby-debug/commands/control.rb +107 -0
  78. data/lib/ruby-debug/commands/display.rb +120 -0
  79. data/lib/ruby-debug/commands/edit.rb +48 -0
  80. data/lib/ruby-debug/commands/enable.rb +202 -0
  81. data/lib/ruby-debug/commands/eval.rb +176 -0
  82. data/lib/ruby-debug/commands/finish.rb +42 -0
  83. data/lib/ruby-debug/commands/frame.rb +301 -0
  84. data/lib/ruby-debug/commands/help.rb +56 -0
  85. data/lib/ruby-debug/commands/info.rb +467 -0
  86. data/lib/ruby-debug/commands/irb.rb +123 -0
  87. data/lib/ruby-debug/commands/jump.rb +66 -0
  88. data/lib/ruby-debug/commands/kill.rb +51 -0
  89. data/lib/ruby-debug/commands/list.rb +94 -0
  90. data/lib/ruby-debug/commands/method.rb +84 -0
  91. data/lib/ruby-debug/commands/quit.rb +50 -0
  92. data/lib/ruby-debug/commands/reload.rb +40 -0
  93. data/lib/ruby-debug/commands/save.rb +90 -0
  94. data/lib/ruby-debug/commands/set.rb +223 -0
  95. data/lib/ruby-debug/commands/show.rb +247 -0
  96. data/lib/ruby-debug/commands/skip.rb +35 -0
  97. data/lib/ruby-debug/commands/source.rb +36 -0
  98. data/lib/ruby-debug/commands/stepping.rb +81 -0
  99. data/lib/ruby-debug/commands/threads.rb +189 -0
  100. data/lib/ruby-debug/commands/tmate.rb +36 -0
  101. data/lib/ruby-debug/commands/trace.rb +57 -0
  102. data/lib/ruby-debug/commands/variables.rb +199 -0
  103. data/lib/ruby-debug/debugger.rb +5 -0
  104. data/lib/ruby-debug/helper.rb +69 -0
  105. data/lib/ruby-debug/interface.rb +232 -0
  106. data/lib/ruby-debug/processor.rb +474 -0
  107. data/man/rdebug.1 +241 -0
  108. data/needy_debugger.gemspec +31 -0
  109. data/old_scripts/Makefile.am +14 -0
  110. data/old_scripts/README.md +2 -0
  111. data/old_scripts/autogen.sh +4 -0
  112. data/old_scripts/configure.ac +12 -0
  113. data/old_scripts/rdbg.rb +33 -0
  114. data/old_scripts/runner.sh +7 -0
  115. data/old_scripts/svn2cl_usermap +3 -0
  116. data/test/.cvsignore +1 -0
  117. data/test/breakpoints_test.rb +365 -0
  118. data/test/conditions_test.rb +76 -0
  119. data/test/continue_test.rb +28 -0
  120. data/test/display_test.rb +141 -0
  121. data/test/edit_test.rb +55 -0
  122. data/test/eval_test.rb +92 -0
  123. data/test/examples/breakpoint1.rb +15 -0
  124. data/test/examples/breakpoint2.rb +7 -0
  125. data/test/examples/conditions.rb +4 -0
  126. data/test/examples/continue.rb +4 -0
  127. data/test/examples/display.rb +5 -0
  128. data/test/examples/edit.rb +3 -0
  129. data/test/examples/edit2.rb +3 -0
  130. data/test/examples/eval.rb +4 -0
  131. data/test/examples/finish.rb +20 -0
  132. data/test/examples/frame.rb +31 -0
  133. data/test/examples/help.rb +2 -0
  134. data/test/examples/info.rb +48 -0
  135. data/test/examples/info2.rb +3 -0
  136. data/test/examples/irb.rb +6 -0
  137. data/test/examples/jump.rb +14 -0
  138. data/test/examples/kill.rb +2 -0
  139. data/test/examples/list.rb +12 -0
  140. data/test/examples/method.rb +15 -0
  141. data/test/examples/post_mortem.rb +19 -0
  142. data/test/examples/quit.rb +2 -0
  143. data/test/examples/reload.rb +6 -0
  144. data/test/examples/restart.rb +6 -0
  145. data/test/examples/save.rb +3 -0
  146. data/test/examples/set.rb +3 -0
  147. data/test/examples/set_annotate.rb +12 -0
  148. data/test/examples/settings.rb +1 -0
  149. data/test/examples/show.rb +2 -0
  150. data/test/examples/source.rb +3 -0
  151. data/test/examples/stepping.rb +21 -0
  152. data/test/examples/thread.rb +32 -0
  153. data/test/examples/tmate.rb +10 -0
  154. data/test/examples/trace.rb +7 -0
  155. data/test/examples/trace_threads.rb +20 -0
  156. data/test/examples/variables.rb +26 -0
  157. data/test/finish_test.rb +48 -0
  158. data/test/frame_test.rb +140 -0
  159. data/test/help_test.rb +50 -0
  160. data/test/info_test.rb +325 -0
  161. data/test/irb_test.rb +81 -0
  162. data/test/jump_test.rb +70 -0
  163. data/test/kill_test.rb +47 -0
  164. data/test/list_test.rb +145 -0
  165. data/test/method_test.rb +70 -0
  166. data/test/post_mortem_test.rb +25 -0
  167. data/test/quit_test.rb +55 -0
  168. data/test/reload_test.rb +43 -0
  169. data/test/restart_test.rb +143 -0
  170. data/test/save_test.rb +92 -0
  171. data/test/set_test.rb +177 -0
  172. data/test/show_test.rb +292 -0
  173. data/test/source_test.rb +44 -0
  174. data/test/stepping_test.rb +118 -0
  175. data/test/support/breakpoint.rb +12 -0
  176. data/test/support/context.rb +14 -0
  177. data/test/support/matchers.rb +67 -0
  178. data/test/support/mocha_extensions.rb +71 -0
  179. data/test/support/processor.rb +7 -0
  180. data/test/support/test_dsl.rb +205 -0
  181. data/test/support/test_interface.rb +66 -0
  182. data/test/test_helper.rb +8 -0
  183. data/test/thread_test.rb +122 -0
  184. data/test/tmate_test.rb +43 -0
  185. data/test/trace_test.rb +154 -0
  186. data/test/variables_test.rb +114 -0
  187. metadata +352 -0
@@ -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
@@ -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
@@ -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