debugger2 1.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (183) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.travis.yml +3 -0
  4. data/AUTHORS +10 -0
  5. data/CHANGELOG.md +65 -0
  6. data/CONTRIBUTING.md +1 -0
  7. data/Gemfile +3 -0
  8. data/LICENSE +23 -0
  9. data/OLDER_CHANGELOG +334 -0
  10. data/OLD_CHANGELOG +5655 -0
  11. data/OLD_README +122 -0
  12. data/README.md +108 -0
  13. data/Rakefile +78 -0
  14. data/bin/rdebug +397 -0
  15. data/debugger2.gemspec +29 -0
  16. data/doc/.cvsignore +42 -0
  17. data/doc/Makefile.am +63 -0
  18. data/doc/emacs-notes.txt +38 -0
  19. data/doc/hanoi.rb +35 -0
  20. data/doc/primes.rb +28 -0
  21. data/doc/rdebug-emacs.texi +1030 -0
  22. data/doc/ruby-debug.texi +3791 -0
  23. data/doc/test-tri2.rb +18 -0
  24. data/doc/tri3.rb +8 -0
  25. data/doc/triangle.rb +12 -0
  26. data/emacs/Makefile.am +130 -0
  27. data/emacs/rdebug-annotate.el +385 -0
  28. data/emacs/rdebug-breaks.el +407 -0
  29. data/emacs/rdebug-cmd.el +92 -0
  30. data/emacs/rdebug-core.el +502 -0
  31. data/emacs/rdebug-dbg.el +62 -0
  32. data/emacs/rdebug-error.el +79 -0
  33. data/emacs/rdebug-fns.el +111 -0
  34. data/emacs/rdebug-frames.el +230 -0
  35. data/emacs/rdebug-gud.el +242 -0
  36. data/emacs/rdebug-help.el +104 -0
  37. data/emacs/rdebug-info.el +83 -0
  38. data/emacs/rdebug-layouts.el +180 -0
  39. data/emacs/rdebug-locring.el +118 -0
  40. data/emacs/rdebug-output.el +106 -0
  41. data/emacs/rdebug-regexp.el +118 -0
  42. data/emacs/rdebug-secondary.el +260 -0
  43. data/emacs/rdebug-shortkey.el +175 -0
  44. data/emacs/rdebug-source.el +568 -0
  45. data/emacs/rdebug-track.el +392 -0
  46. data/emacs/rdebug-varbuf.el +150 -0
  47. data/emacs/rdebug-vars.el +125 -0
  48. data/emacs/rdebug-watch.el +132 -0
  49. data/emacs/rdebug.el +326 -0
  50. data/emacs/test/elk-test.el +242 -0
  51. data/emacs/test/test-annotate.el +103 -0
  52. data/emacs/test/test-cmd.el +116 -0
  53. data/emacs/test/test-core.el +104 -0
  54. data/emacs/test/test-fns.el +65 -0
  55. data/emacs/test/test-frames.el +62 -0
  56. data/emacs/test/test-gud.el +35 -0
  57. data/emacs/test/test-indent.el +58 -0
  58. data/emacs/test/test-regexp.el +144 -0
  59. data/emacs/test/test-shortkey.el +61 -0
  60. data/ext/ruby_debug/breakpoint.c +630 -0
  61. data/ext/ruby_debug/extconf.rb +11 -0
  62. data/ext/ruby_debug/ruby_debug.c +2203 -0
  63. data/ext/ruby_debug/ruby_debug.h +151 -0
  64. data/lib/debugger.rb +5 -0
  65. data/lib/debugger/version.rb +5 -0
  66. data/lib/debugger2.rb +6 -0
  67. data/lib/ruby-debug-base.rb +307 -0
  68. data/lib/ruby-debug.rb +176 -0
  69. data/lib/ruby-debug/command.rb +227 -0
  70. data/lib/ruby-debug/commands/breakpoints.rb +153 -0
  71. data/lib/ruby-debug/commands/catchpoint.rb +55 -0
  72. data/lib/ruby-debug/commands/condition.rb +49 -0
  73. data/lib/ruby-debug/commands/continue.rb +38 -0
  74. data/lib/ruby-debug/commands/control.rb +107 -0
  75. data/lib/ruby-debug/commands/display.rb +120 -0
  76. data/lib/ruby-debug/commands/edit.rb +48 -0
  77. data/lib/ruby-debug/commands/enable.rb +202 -0
  78. data/lib/ruby-debug/commands/eval.rb +176 -0
  79. data/lib/ruby-debug/commands/finish.rb +42 -0
  80. data/lib/ruby-debug/commands/frame.rb +301 -0
  81. data/lib/ruby-debug/commands/help.rb +56 -0
  82. data/lib/ruby-debug/commands/info.rb +467 -0
  83. data/lib/ruby-debug/commands/irb.rb +123 -0
  84. data/lib/ruby-debug/commands/jump.rb +66 -0
  85. data/lib/ruby-debug/commands/kill.rb +51 -0
  86. data/lib/ruby-debug/commands/list.rb +94 -0
  87. data/lib/ruby-debug/commands/method.rb +84 -0
  88. data/lib/ruby-debug/commands/quit.rb +39 -0
  89. data/lib/ruby-debug/commands/reload.rb +40 -0
  90. data/lib/ruby-debug/commands/save.rb +90 -0
  91. data/lib/ruby-debug/commands/set.rb +223 -0
  92. data/lib/ruby-debug/commands/show.rb +247 -0
  93. data/lib/ruby-debug/commands/skip.rb +35 -0
  94. data/lib/ruby-debug/commands/source.rb +36 -0
  95. data/lib/ruby-debug/commands/stepping.rb +81 -0
  96. data/lib/ruby-debug/commands/threads.rb +189 -0
  97. data/lib/ruby-debug/commands/tmate.rb +36 -0
  98. data/lib/ruby-debug/commands/trace.rb +57 -0
  99. data/lib/ruby-debug/commands/variables.rb +199 -0
  100. data/lib/ruby-debug/debugger.rb +5 -0
  101. data/lib/ruby-debug/helper.rb +69 -0
  102. data/lib/ruby-debug/interface.rb +232 -0
  103. data/lib/ruby-debug/processor.rb +474 -0
  104. data/man/rdebug.1 +241 -0
  105. data/old_scripts/Makefile.am +14 -0
  106. data/old_scripts/README.md +2 -0
  107. data/old_scripts/autogen.sh +4 -0
  108. data/old_scripts/configure.ac +12 -0
  109. data/old_scripts/rdbg.rb +33 -0
  110. data/old_scripts/runner.sh +7 -0
  111. data/old_scripts/svn2cl_usermap +3 -0
  112. data/test/.cvsignore +1 -0
  113. data/test/breakpoints_test.rb +366 -0
  114. data/test/conditions_test.rb +77 -0
  115. data/test/continue_test.rb +28 -0
  116. data/test/display_test.rb +143 -0
  117. data/test/edit_test.rb +55 -0
  118. data/test/eval_test.rb +94 -0
  119. data/test/examples/breakpoint1.rb +15 -0
  120. data/test/examples/breakpoint2.rb +7 -0
  121. data/test/examples/conditions.rb +4 -0
  122. data/test/examples/continue.rb +4 -0
  123. data/test/examples/display.rb +5 -0
  124. data/test/examples/edit.rb +3 -0
  125. data/test/examples/edit2.rb +3 -0
  126. data/test/examples/eval.rb +4 -0
  127. data/test/examples/finish.rb +20 -0
  128. data/test/examples/frame.rb +31 -0
  129. data/test/examples/help.rb +2 -0
  130. data/test/examples/info.rb +48 -0
  131. data/test/examples/info2.rb +3 -0
  132. data/test/examples/irb.rb +6 -0
  133. data/test/examples/jump.rb +14 -0
  134. data/test/examples/kill.rb +2 -0
  135. data/test/examples/list.rb +12 -0
  136. data/test/examples/method.rb +15 -0
  137. data/test/examples/post_mortem.rb +19 -0
  138. data/test/examples/quit.rb +2 -0
  139. data/test/examples/reload.rb +6 -0
  140. data/test/examples/restart.rb +6 -0
  141. data/test/examples/save.rb +3 -0
  142. data/test/examples/set.rb +3 -0
  143. data/test/examples/set_annotate.rb +12 -0
  144. data/test/examples/settings.rb +1 -0
  145. data/test/examples/show.rb +2 -0
  146. data/test/examples/source.rb +3 -0
  147. data/test/examples/stepping.rb +21 -0
  148. data/test/examples/thread.rb +32 -0
  149. data/test/examples/tmate.rb +10 -0
  150. data/test/examples/trace.rb +7 -0
  151. data/test/examples/trace_threads.rb +20 -0
  152. data/test/examples/variables.rb +26 -0
  153. data/test/finish_test.rb +49 -0
  154. data/test/frame_test.rb +140 -0
  155. data/test/help_test.rb +51 -0
  156. data/test/info_test.rb +326 -0
  157. data/test/irb_test.rb +82 -0
  158. data/test/jump_test.rb +70 -0
  159. data/test/kill_test.rb +49 -0
  160. data/test/list_test.rb +147 -0
  161. data/test/method_test.rb +72 -0
  162. data/test/post_mortem_test.rb +25 -0
  163. data/test/quit_test.rb +56 -0
  164. data/test/reload_test.rb +47 -0
  165. data/test/restart_test.rb +145 -0
  166. data/test/save_test.rb +94 -0
  167. data/test/set_test.rb +183 -0
  168. data/test/show_test.rb +294 -0
  169. data/test/source_test.rb +46 -0
  170. data/test/stepping_test.rb +122 -0
  171. data/test/support/breakpoint.rb +12 -0
  172. data/test/support/context.rb +14 -0
  173. data/test/support/matchers.rb +67 -0
  174. data/test/support/mocha_extensions.rb +71 -0
  175. data/test/support/processor.rb +7 -0
  176. data/test/support/test_dsl.rb +206 -0
  177. data/test/support/test_interface.rb +66 -0
  178. data/test/test_helper.rb +9 -0
  179. data/test/thread_test.rb +124 -0
  180. data/test/tmate_test.rb +45 -0
  181. data/test/trace_test.rb +156 -0
  182. data/test/variables_test.rb +116 -0
  183. metadata +319 -0
@@ -0,0 +1,145 @@
1
+ require_relative 'test_helper'
2
+
3
+ describe "Restart Command" do
4
+ include TestDsl
5
+
6
+ let(:initial_dir) { Pathname.new(__FILE__ + "/../..").realpath.to_s }
7
+ let(:prog_script) do
8
+ Pathname.new(fullpath('restart')).relative_path_from(Pathname.new(Debugger::INITIAL_DIR)).cleanpath.to_s
9
+ end
10
+ let(:rdebug_script) { 'rdebug-script' }
11
+
12
+ def must_restart
13
+ Debugger::RestartCommand.any_instance.unstub(:exec)
14
+ Debugger::RestartCommand.any_instance.expects(:exec)
15
+ end
16
+
17
+ before do
18
+ force_set_const(Debugger, "INITIAL_DIR", initial_dir)
19
+ force_set_const(Debugger, "PROG_SCRIPT", prog_script)
20
+ force_set_const(Debugger, "RDEBUG_SCRIPT", rdebug_script)
21
+ Debugger::Command.settings[:argv] = ['argv']
22
+ Debugger::RestartCommand.any_instance.stubs(:exec).with("#{rdebug_script} argv")
23
+ end
24
+
25
+ it "must be restarted with arguments" do
26
+ Debugger::RestartCommand.any_instance.expects(:exec).with("#{rdebug_script} test/examples/restart.rb 1 2 3")
27
+ enter 'restart 1 2 3'
28
+ debug_file('restart')
29
+ end
30
+
31
+ it "must be restarted without arguments" do
32
+ Debugger::RestartCommand.any_instance.expects(:exec).with("#{rdebug_script} argv")
33
+ enter 'restart'
34
+ debug_file('restart')
35
+ end
36
+
37
+ it "must specify arguments by 'set' command" do
38
+ temporary_change_hash_value(Debugger::Command.settings, :argv, []) do
39
+ Debugger::RestartCommand.any_instance.expects(:exec).with("#{rdebug_script} 1 2 3")
40
+ enter 'set args 1 2 3', 'restart'
41
+ debug_file('restart')
42
+ end
43
+ end
44
+
45
+ describe "messaging" do
46
+ before { enter 'restart' }
47
+
48
+ describe "reexecing" do
49
+ it "must restart" do
50
+ must_restart
51
+ debug_file('restart')
52
+ end
53
+
54
+ it "must show a message about reexecing" do
55
+ debug_file('restart')
56
+ check_output_includes "Re exec'ing:\n\t#{rdebug_script} argv"
57
+ end
58
+ end
59
+
60
+ describe "no script is specified and don't use $0" do
61
+ before do
62
+ Debugger.send(:remove_const, "PROG_SCRIPT")
63
+ force_set_const(Debugger, "DEFAULT_START_SETTINGS", init: false, post_mortem: false, tracing: nil)
64
+ end
65
+
66
+ it "must not restart" do
67
+ must_restart.never
68
+ debug_file('restart')
69
+ end
70
+
71
+ it "must show an error message" do
72
+ debug_file('restart')
73
+ check_output_includes "Don't know name of debugged program", interface.error_queue
74
+ end
75
+ end
76
+
77
+ it "must use prog_script from $0 if PROG_SCRIPT is undefined" do
78
+ $0 = 'prog-0'
79
+ Debugger.send(:remove_const, "PROG_SCRIPT")
80
+ force_set_const(Debugger, "DEFAULT_START_SETTINGS", init: true, post_mortem: false, tracing: nil)
81
+ debug_file('restart')
82
+ check_output_includes "Ruby program prog-0 doesn't exist", interface.error_queue
83
+ end
84
+
85
+ describe "no script at the specified path" do
86
+ before { force_set_const(Debugger, "PROG_SCRIPT", 'blabla') }
87
+
88
+ it "must not restart" do
89
+ must_restart.never
90
+ debug_file('restart')
91
+ end
92
+
93
+ it "must show an error message" do
94
+ debug_file('restart')
95
+ check_output_includes "Ruby program blabla doesn't exist", interface.error_queue
96
+ end
97
+ end
98
+
99
+ describe "debugger runner script is not specified" do
100
+ before { Debugger.send(:remove_const, "RDEBUG_SCRIPT") }
101
+
102
+ it "must restart anyway" do
103
+ must_restart
104
+ debug_file('restart')
105
+ end
106
+
107
+ it "must show a warning message" do
108
+ debug_file('restart')
109
+ check_output_includes "Debugger was not called from the outset..."
110
+ end
111
+
112
+ it "must show a warning message when prog script is not executable" do
113
+ debug_file('restart')
114
+ check_output_includes "Ruby program #{prog_script} doesn't seem to be executable..."
115
+ check_output_includes "We'll add a call to Ruby."
116
+ end
117
+ end
118
+
119
+ describe "when can't change the dir to INITIAL_DIR" do
120
+ before { force_set_const(Debugger, "INITIAL_DIR", "unexisted/path") }
121
+
122
+ it "must restart anyway" do
123
+ must_restart
124
+ debug_file('restart')
125
+ end
126
+
127
+ it "must show an error message " do
128
+ debug_file('restart')
129
+ check_output_includes "Failed to change initial directory unexisted/path"
130
+ end
131
+ end
132
+ end
133
+
134
+
135
+ describe "Post Mortem" do
136
+ it "must work in post-mortem mode"
137
+
138
+ 0.times do
139
+ must_restart
140
+ enter 'cont', 'restart'
141
+ debug_file 'post_mortem'
142
+ end
143
+ end
144
+
145
+ end
@@ -0,0 +1,94 @@
1
+ require_relative 'test_helper'
2
+
3
+ describe "Save Command" do
4
+ include TestDsl
5
+ let(:file_name) { 'save_output.txt' }
6
+
7
+ describe "successful saving" do
8
+ let(:file_contents) { File.read(file_name) }
9
+ before do
10
+ enter 'break 2', 'break 3 if true', 'catch NoMethodError', 'display 2 + 3', 'display 5 + 6',
11
+ 'set autoeval', 'set autolist',
12
+ "save #{file_name}"
13
+ debug_file 'save'
14
+ end
15
+ after do
16
+ FileUtils.rm(file_name)
17
+ end
18
+
19
+ it "must save usual breakpoints" do
20
+ file_contents.must_include "break #{fullpath('save')}:2"
21
+ end
22
+
23
+ it "must save conditinal breakpoints" do
24
+ file_contents.must_include "break #{fullpath('save')}:3 if true"
25
+ end
26
+
27
+ it "must save catchpoints" do
28
+ file_contents.must_include "catch NoMethodError"
29
+ end
30
+
31
+ # Not sure why it is suppressed, but this is like it is now.
32
+ it "must not save displays" do
33
+ file_contents.wont_include "display 2 + 3"
34
+ end
35
+
36
+ describe "saving settings" do
37
+ it "must save autoeval" do
38
+ file_contents.must_include "set autoeval on"
39
+ end
40
+
41
+ it "must save basename" do
42
+ file_contents.must_include "set basename off"
43
+ end
44
+
45
+ it "must save debuggertesting" do
46
+ file_contents.must_include "set debuggertesting on"
47
+ end
48
+
49
+ it "must save autolist" do
50
+ file_contents.must_include "set autolist on"
51
+ end
52
+
53
+ it "must save autoirb" do
54
+ file_contents.must_include "set autoirb off"
55
+ end
56
+ end
57
+
58
+ it "must show a message about successful saving" do
59
+ check_output_includes "Saved to '#{file_name}'"
60
+ end
61
+
62
+ end
63
+
64
+ describe "without filename" do
65
+ let(:file_contents) { File.read(interface.restart_file) }
66
+ after { FileUtils.rm(interface.restart_file) }
67
+
68
+ it "must fabricate a filename if not provided" do
69
+ enter "save"
70
+ debug_file 'save'
71
+ file_contents.must_include "set autoirb"
72
+ end
73
+
74
+ it "must show a message where the file is saved" do
75
+ enter "save"
76
+ debug_file 'save'
77
+ check_output_includes "Saved to '#{interface.restart_file}'"
78
+ end
79
+ end
80
+
81
+
82
+ describe "Post Mortem" do
83
+ let(:file_contents) { File.read(file_name) }
84
+ after { FileUtils.rm(file_name) }
85
+ it "must work in post-mortem mode"
86
+
87
+ 0.times do
88
+ enter 'cont', "save #{file_name}"
89
+ debug_file 'post_mortem'
90
+ file_contents.must_include "set autoirb off"
91
+ end
92
+ end
93
+
94
+ end
@@ -0,0 +1,183 @@
1
+ require_relative 'test_helper'
2
+
3
+ describe "Set Command" do
4
+ include TestDsl
5
+
6
+ describe "setting to on" do
7
+ temporary_change_hash_value(Debugger::Command.settings, :autolist, 0)
8
+
9
+ it "must set a setting to on" do
10
+ enter 'set autolist on'
11
+ debug_file 'set'
12
+ Debugger::Command.settings[:autolist].must_equal 1
13
+ end
14
+
15
+ it "must set a setting to on by 1" do
16
+ enter 'set autolist 1'
17
+ debug_file 'set'
18
+ Debugger::Command.settings[:autolist].must_equal 1
19
+ end
20
+
21
+ it "must set a setting to on by default" do
22
+ enter 'set autolist'
23
+ debug_file 'set'
24
+ Debugger::Command.settings[:autolist].must_equal 1
25
+ end
26
+
27
+ it "must set a setting using shortcut" do
28
+ enter 'set autol'
29
+ debug_file 'set'
30
+ Debugger::Command.settings[:autolist].must_equal 1
31
+ end
32
+ end
33
+
34
+ describe "setting to off" do
35
+ temporary_change_hash_value(Debugger::Command.settings, :autolist, 1)
36
+
37
+ it "must set a setting to off" do
38
+ enter 'set autolist off'
39
+ debug_file 'set'
40
+ Debugger::Command.settings[:autolist].must_equal 0
41
+ end
42
+
43
+ it "must set a setting to off by 0" do
44
+ enter 'set autolist 0'
45
+ debug_file 'set'
46
+ Debugger::Command.settings[:autolist].must_equal 0
47
+ end
48
+
49
+ it "must set a setting to off by 'no' suffix" do
50
+ enter 'set noautolist'
51
+ debug_file 'set'
52
+ Debugger::Command.settings[:autolist].must_equal 0
53
+ end
54
+ end
55
+
56
+ describe "messages" do
57
+ temporary_change_hash_value(Debugger::Command.settings, :autolist, 0)
58
+
59
+ it "must show a message after setting" do
60
+ enter 'set autolist on'
61
+ debug_file 'set'
62
+ check_output_includes "autolist is on."
63
+ end
64
+ end
65
+
66
+ describe "debuggertesting" do
67
+ temporary_change_hash_value(Debugger::Command.settings, :debuggertesting, false)
68
+ before { $rdebug_state = nil }
69
+ after { $rdebug_state = nil }
70
+
71
+ it "must set $rdebug_context if debuggersetting is on"
72
+ # unsupported
73
+ 0.times do
74
+ enter 'set debuggertesting', 'break 3', 'cont'
75
+ debug_file('set') { state.must_be_kind_of Debugger::CommandProcessor::State }
76
+ end
77
+
78
+ it "must set basename on too" do
79
+ temporary_change_hash_value(Debugger::Command.settings, :basename, false) do
80
+ enter 'set debuggertesting', 'show basename'
81
+ debug_file('set')
82
+ check_output_includes "basename is on."
83
+ end
84
+ end
85
+
86
+ it "must not set $rdebug_context if debuggersetting is off"
87
+ # unsupported
88
+ 0.times do
89
+ enter 'set nodebuggertesting', 'break 3', 'cont'
90
+ debug_file('set') { state.must_be_nil }
91
+ end
92
+ end
93
+
94
+ describe "history" do
95
+ describe "save" do
96
+ it "must set history save to on" do
97
+ enter 'set history save on'
98
+ debug_file 'set'
99
+ interface.history_save.must_equal true
100
+ end
101
+
102
+ it "must show a message" do
103
+ enter 'set history save on'
104
+ debug_file 'set'
105
+ check_output_includes "Saving of history save is on."
106
+ end
107
+
108
+ it "must set history save to off" do
109
+ enter 'set history save off'
110
+ debug_file 'set'
111
+ interface.history_save.must_equal false
112
+ end
113
+ end
114
+
115
+ describe "size" do
116
+ it "must set history size" do
117
+ enter 'set history size 250'
118
+ debug_file 'set'
119
+ interface.history_length.must_equal 250
120
+ end
121
+
122
+ it "must show a message" do
123
+ enter 'set history size 250'
124
+ debug_file 'set'
125
+ check_output_includes "Debugger history size is 250"
126
+ end
127
+ end
128
+
129
+ describe "filename" do
130
+ it "must set history filename" do
131
+ enter 'set history filename .debugger-hist'
132
+ debug_file 'set'
133
+ interface.histfile.must_equal File.join(ENV["HOME"]||ENV["HOMEPATH"]||".", '.debugger-hist')
134
+ end
135
+
136
+ it "must show a message" do
137
+ enter 'set history filename .debugger-hist'
138
+ debug_file 'set'
139
+ check_output_includes "The filename in which to record the command history is \"#{File.join(ENV["HOME"]||ENV["HOMEPATH"]||".", ".debugger-hist")}\""
140
+ end
141
+ end
142
+
143
+ it "must show an error message if used wrong subcommand" do
144
+ enter 'set history bla 2'
145
+ debug_file 'set'
146
+ check_output_includes "Invalid history parameter bla. Should be 'filename', 'save' or 'size'."
147
+ end
148
+
149
+ it "must show an error message if provided only one argument" do
150
+ enter 'set history save'
151
+ debug_file 'set'
152
+ check_output_includes "Need two parameters for 'set history'; got 1."
153
+ end
154
+ end
155
+
156
+ describe "width" do
157
+ temporary_change_hash_value(Debugger::Command.settings, :width, 20)
158
+
159
+ it "must set ENV['COLUMNS'] by the 'set width' command" do
160
+ old_columns = ENV["COLUMNS"]
161
+ begin
162
+ enter 'set width 10'
163
+ debug_file 'set'
164
+ ENV["COLUMNS"].must_equal '10'
165
+ ensure
166
+ ENV["COLUMNS"] = old_columns
167
+ end
168
+ end
169
+ end
170
+
171
+
172
+ describe "Post Mortem" do
173
+ temporary_change_hash_value(Debugger::Command.settings, :autolist, 0)
174
+ it "must work in post-mortem mode"
175
+
176
+ 0.times do
177
+ enter 'cont', "set autolist on"
178
+ debug_file 'post_mortem'
179
+ check_output_includes "autolist is on."
180
+ end
181
+ end
182
+
183
+ end
@@ -0,0 +1,294 @@
1
+ require_relative 'test_helper'
2
+
3
+ describe "Show Command" do
4
+ include TestDsl
5
+
6
+ describe "annotate" do
7
+ temporary_change_method_value(Debugger, :annotate, nil)
8
+
9
+ it "must show annotate setting" do
10
+ enter 'show annotate'
11
+ debug_file 'show'
12
+ check_output_includes "Annotation level is 0"
13
+ end
14
+
15
+ it "must show annotate setting" do
16
+ enter 'show annotate'
17
+ debug_file 'show'
18
+ Debugger.annotate.must_equal 0
19
+ end
20
+ end
21
+
22
+
23
+ describe "args" do
24
+ temporary_change_hash_value(Debugger::Command.settings, :argv, %w{foo bar})
25
+
26
+ it "must show args" do
27
+ Debugger.send(:remove_const, "RDEBUG_SCRIPT") if Debugger.const_defined?("RDEBUG_SCRIPT")
28
+ enter 'show args'
29
+ debug_file 'show'
30
+ check_output_includes 'Argument list to give program being debugged when it is started is "foo bar".'
31
+ end
32
+
33
+ it "must not show the first arg if RDEBUG_SCRIPT is defined" do
34
+ temporary_set_const(Debugger, "RDEBUG_SCRIPT", "bla") do
35
+ enter 'show args'
36
+ debug_file 'show'
37
+ check_output_includes 'Argument list to give program being debugged when it is started is "bar".'
38
+ end
39
+ end
40
+ end
41
+
42
+
43
+ it "must show autolist" do
44
+ temporary_change_hash_value(Debugger::Command.settings, :autolist, 1) do
45
+ enter 'show autolist'
46
+ debug_file 'show'
47
+ check_output_includes 'autolist is on.'
48
+ end
49
+ end
50
+
51
+ it "must show autoeval" do
52
+ temporary_change_hash_value(Debugger::Command.settings, :autoeval, true) do
53
+ enter 'show autoeval'
54
+ debug_file 'show'
55
+ check_output_includes 'autoeval is on.'
56
+ end
57
+ end
58
+
59
+ it "must show autoreload" do
60
+ temporary_change_hash_value(Debugger::Command.settings, :reload_source_on_change, true) do
61
+ enter 'show autoreload'
62
+ debug_file 'show'
63
+ check_output_includes 'autoreload is on.'
64
+ end
65
+ end
66
+
67
+ it "must show autoirb" do
68
+ Debugger::IRBCommand.any_instance.stubs(:execute)
69
+ temporary_change_hash_value(Debugger::Command.settings, :autoirb, 1) do
70
+ enter 'show autoirb'
71
+ debug_file 'show'
72
+ check_output_includes 'autoirb is on.'
73
+ end
74
+ end
75
+
76
+ it "must show basename" do
77
+ temporary_change_hash_value(Debugger::Command.settings, :basename, true) do
78
+ enter 'show basename'
79
+ debug_file 'show'
80
+ check_output_includes 'basename is on.'
81
+ end
82
+ end
83
+
84
+ it "must show callstyle" do
85
+ temporary_change_hash_value(Debugger::Command.settings, :callstyle, :short) do
86
+ enter 'show callstyle'
87
+ debug_file 'show'
88
+ check_output_includes 'Frame call-display style is short.'
89
+ end
90
+ end
91
+
92
+ it "must show forcestep" do
93
+ temporary_change_hash_value(Debugger::Command.settings, :force_stepping, true) do
94
+ enter 'show forcestep'
95
+ debug_file 'show'
96
+ check_output_includes 'force-stepping is on.'
97
+ end
98
+ end
99
+
100
+ it "must show fullpath" do
101
+ temporary_change_hash_value(Debugger::Command.settings, :full_path, true) do
102
+ enter 'show fullpath'
103
+ debug_file 'show'
104
+ check_output_includes "Displaying frame's full file names is on."
105
+ end
106
+ end
107
+
108
+ it "must show linetrace" do
109
+ temporary_change_method_value(Debugger, :tracing, true) do
110
+ enter 'show linetrace'
111
+ debug_file 'show'
112
+ check_output_includes "line tracing is on."
113
+ end
114
+ end
115
+
116
+
117
+ describe "linetrace+" do
118
+ it "must show a message when linetrace+ is on" do
119
+ temporary_change_hash_value(Debugger::Command.settings, :tracing_plus, true) do
120
+ enter 'show linetrace+'
121
+ debug_file 'show'
122
+ check_output_includes "line tracing style is different consecutive lines."
123
+ end
124
+ end
125
+
126
+ it "must show a message when linetrace+ is off" do
127
+ temporary_change_hash_value(Debugger::Command.settings, :tracing_plus, false) do
128
+ enter 'show linetrace+'
129
+ debug_file 'show'
130
+ check_output_includes "line tracing style is every line."
131
+ end
132
+ end
133
+ end
134
+
135
+
136
+ it "must show listsize" do
137
+ temporary_change_hash_value(Debugger::Command.settings, :listsize, 10) do
138
+ enter 'show listsize'
139
+ debug_file 'show'
140
+ check_output_includes 'Number of source lines to list by default is 10.'
141
+ end
142
+ end
143
+
144
+ it "must show port" do
145
+ temporary_set_const(Debugger, "PORT", 12345) do
146
+ enter 'show port'
147
+ debug_file 'show'
148
+ check_output_includes 'server port is 12345.'
149
+ end
150
+ end
151
+
152
+ it "must show trace" do
153
+ temporary_change_hash_value(Debugger::Command.settings, :stack_trace_on_error, true) do
154
+ enter 'show trace'
155
+ debug_file 'show'
156
+ check_output_includes "Displaying stack trace is on."
157
+ end
158
+ end
159
+
160
+ it "must show version" do
161
+ enter 'show version'
162
+ debug_file 'show'
163
+ check_output_includes "ruby-debug #{Debugger::VERSION}"
164
+ end
165
+
166
+ it "must show forcestep" do
167
+ temporary_change_hash_value(Debugger::Command.settings, :width, 35) do
168
+ enter 'show width'
169
+ debug_file 'show'
170
+ check_output_includes 'width is 35.'
171
+ end
172
+ end
173
+
174
+ it "must show a message about unknown command" do
175
+ enter 'show bla'
176
+ debug_file 'show'
177
+ check_output_includes 'Unknown show command bla'
178
+ end
179
+
180
+
181
+ describe "history" do
182
+ describe "without arguments" do
183
+ before do
184
+ interface.histfile = "hist_file.txt"
185
+ interface.history_save = true
186
+ interface.history_length = 25
187
+ enter 'show history'
188
+ debug_file 'show'
189
+ end
190
+
191
+ it "must show history file" do
192
+ check_output_includes /filename: The filename in which to record the command history is "hist_file\.txt"/
193
+ end
194
+
195
+ it "must show history save setting" do
196
+ check_output_includes /save: Saving of history save is on\./
197
+ end
198
+
199
+ it "must show history length" do
200
+ check_output_includes /size: Debugger history size is 25/
201
+ end
202
+ end
203
+
204
+ describe "with 'filename' argument" do
205
+ it "must show history filename" do
206
+ interface.histfile = "hist_file.txt"
207
+ enter 'show history filename'
208
+ debug_file 'show'
209
+ check_output_includes 'The filename in which to record the command history is "hist_file.txt"'
210
+ end
211
+
212
+ it "must show history save setting" do
213
+ interface.history_save = true
214
+ enter 'show history save'
215
+ debug_file 'show'
216
+ check_output_includes 'Saving of history save is on.'
217
+ end
218
+
219
+ it "must show history length" do
220
+ interface.history_length = 30
221
+ enter 'show history size'
222
+ debug_file 'show'
223
+ check_output_includes 'Debugger history size is 30'
224
+ end
225
+ end
226
+ end
227
+
228
+
229
+ describe "commands" do
230
+ before { interface.readline_support = true }
231
+
232
+ it "must not show records from readline if there is no readline support" do
233
+ interface.readline_support = false
234
+ enter 'show commands'
235
+ debug_file 'show'
236
+ check_output_includes "No readline support"
237
+ end
238
+
239
+ it "must show records from readline history" do
240
+ temporary_set_const(Readline, "HISTORY", %w{aaa bbb ccc ddd eee fff}) do
241
+ enter 'show commands'
242
+ debug_file 'show'
243
+ check_output_includes /1 aaa/
244
+ check_output_includes /6 fff/
245
+ end
246
+ end
247
+
248
+ it "must show last 10 records from readline history" do
249
+ temporary_set_const(Readline, "HISTORY", %w{aaa bbb ccc ddd eee fff ggg hhh iii jjj kkk lll mmm nnn}) do
250
+ enter 'show commands'
251
+ debug_file 'show'
252
+ check_output_doesnt_include /3 ccc/
253
+ check_output_includes /4 eee/
254
+ check_output_includes /13 nnn/
255
+ end
256
+ end
257
+
258
+ describe "with specified positions" do
259
+ it "must show records within boundaries" do
260
+ temporary_set_const(Readline, "HISTORY", %w{aaa bbb ccc ddd eee fff ggg hhh iii jjj kkk lll mmm nnn}) do
261
+ # Really don't know why it substracts 4, and shows starting from position 6
262
+ enter 'show commands 10'
263
+ debug_file 'show'
264
+ check_output_doesnt_include /5 fff/
265
+ check_output_includes /6 ggg/
266
+ check_output_includes /13 nnn/
267
+ end
268
+ end
269
+
270
+ it "must adjust first line if it is < 0" do
271
+ temporary_set_const(Readline, "HISTORY", %w{aaa bbb ccc ddd eee fff ggg hhh iii jjj kkk lll mmm nnn}) do
272
+ enter 'show commands 3'
273
+ debug_file 'show'
274
+ check_output_includes /1 bbb/
275
+ check_output_includes /8 iii/
276
+ check_output_doesnt_include /9 jjj/
277
+ end
278
+ end
279
+ end
280
+ end
281
+
282
+ describe "Post Mortem" do
283
+ temporary_change_hash_value(Debugger::Command.settings, :autolist, 0)
284
+
285
+ it "must work in post-mortem mode"
286
+
287
+ 0.times do
288
+ enter 'cont', "show autolist"
289
+ debug_file 'post_mortem'
290
+ check_output_includes "autolist is off."
291
+ end
292
+ end
293
+
294
+ end