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.
Files changed (241) hide show
  1. data/.gitignore +14 -0
  2. data/.travis.yml +0 -1
  3. data/CHANGELOG.md +9 -0
  4. data/Gemfile +3 -0
  5. data/README.md +2 -0
  6. data/Rakefile +3 -55
  7. data/debugger.gemspec +2 -0
  8. data/lib/debugger/version.rb +1 -1
  9. data/lib/ruby-debug-base.rb +3 -1
  10. data/lib/ruby-debug/commands/irb.rb +1 -1
  11. data/lib/ruby-debug/commands/jump.rb +1 -1
  12. data/lib/ruby-debug/commands/method.rb +1 -1
  13. data/lib/ruby-debug/commands/show.rb +1 -1
  14. data/lib/ruby-debug/commands/trace.rb +2 -2
  15. data/lib/ruby-debug/commands/variables.rb +3 -3
  16. data/test/breakpoints_test.rb +365 -0
  17. data/test/conditions_test.rb +76 -0
  18. data/test/continue_test.rb +28 -0
  19. data/test/display_test.rb +141 -0
  20. data/test/edit_test.rb +55 -0
  21. data/test/eval_test.rb +92 -0
  22. data/test/examples/breakpoint1.rb +15 -0
  23. data/test/examples/breakpoint2.rb +7 -0
  24. data/test/examples/conditions.rb +4 -0
  25. data/test/examples/continue.rb +4 -0
  26. data/test/examples/display.rb +5 -0
  27. data/test/examples/edit.rb +3 -0
  28. data/test/examples/edit2.rb +3 -0
  29. data/test/examples/eval.rb +4 -0
  30. data/test/examples/finish.rb +20 -0
  31. data/test/examples/frame.rb +31 -0
  32. data/test/examples/help.rb +2 -0
  33. data/test/examples/info.rb +48 -0
  34. data/test/examples/info2.rb +3 -0
  35. data/test/examples/irb.rb +6 -0
  36. data/test/examples/jump.rb +14 -0
  37. data/test/examples/kill.rb +2 -0
  38. data/test/examples/list.rb +12 -0
  39. data/test/examples/method.rb +15 -0
  40. data/test/examples/post_mortem.rb +19 -0
  41. data/test/examples/quit.rb +2 -0
  42. data/test/examples/reload.rb +6 -0
  43. data/test/examples/restart.rb +6 -0
  44. data/test/examples/save.rb +3 -0
  45. data/test/examples/set.rb +3 -0
  46. data/test/examples/set_annotate.rb +12 -0
  47. data/test/examples/settings.rb +1 -0
  48. data/test/examples/show.rb +2 -0
  49. data/test/examples/source.rb +3 -0
  50. data/test/examples/stepping.rb +21 -0
  51. data/test/examples/thread.rb +32 -0
  52. data/test/examples/tmate.rb +10 -0
  53. data/test/examples/trace.rb +7 -0
  54. data/test/examples/trace_threads.rb +20 -0
  55. data/test/examples/variables.rb +26 -0
  56. data/test/finish_test.rb +48 -0
  57. data/test/frame_test.rb +140 -0
  58. data/test/help_test.rb +50 -0
  59. data/test/info_test.rb +325 -0
  60. data/test/irb_test.rb +81 -0
  61. data/test/jump_test.rb +70 -0
  62. data/test/kill_test.rb +47 -0
  63. data/test/list_test.rb +145 -0
  64. data/test/method_test.rb +70 -0
  65. data/test/post_mortem_test.rb +25 -0
  66. data/test/quit_test.rb +55 -0
  67. data/test/reload_test.rb +43 -0
  68. data/test/restart_test.rb +143 -0
  69. data/test/save_test.rb +92 -0
  70. data/test/set_test.rb +163 -0
  71. data/test/show_test.rb +292 -0
  72. data/test/source_test.rb +44 -0
  73. data/test/stepping_test.rb +118 -0
  74. data/test/support/breakpoint.rb +12 -0
  75. data/test/support/context.rb +14 -0
  76. data/test/support/matchers.rb +67 -0
  77. data/test/support/mocha_extensions.rb +71 -0
  78. data/test/support/processor.rb +7 -0
  79. data/test/support/test_dsl.rb +205 -0
  80. data/test/support/test_interface.rb +66 -0
  81. data/test/test_helper.rb +8 -0
  82. data/test/thread_test.rb +122 -0
  83. data/test/tmate_test.rb +43 -0
  84. data/test/trace_test.rb +154 -0
  85. data/test/variables_test.rb +114 -0
  86. metadata +107 -158
  87. data/test/base/base.rb +0 -71
  88. data/test/base/binding.rb +0 -24
  89. data/test/base/catchpoint.rb +0 -22
  90. data/test/base/load.rb +0 -36
  91. data/test/bp_loop_issue.rb +0 -3
  92. data/test/classes.rb +0 -11
  93. data/test/config.yaml +0 -8
  94. data/test/data/annotate.cmd +0 -29
  95. data/test/data/annotate.right +0 -139
  96. data/test/data/break_bad.cmd +0 -18
  97. data/test/data/break_bad.right +0 -28
  98. data/test/data/break_loop_bug.cmd +0 -5
  99. data/test/data/break_loop_bug.right +0 -15
  100. data/test/data/breakpoints.cmd +0 -38
  101. data/test/data/breakpoints.right +0 -98
  102. data/test/data/catch.cmd +0 -20
  103. data/test/data/catch.right +0 -49
  104. data/test/data/catch2.cmd +0 -19
  105. data/test/data/catch2.right +0 -65
  106. data/test/data/catch3.cmd +0 -11
  107. data/test/data/catch3.right +0 -37
  108. data/test/data/condition.cmd +0 -28
  109. data/test/data/condition.right +0 -65
  110. data/test/data/ctrl.cmd +0 -23
  111. data/test/data/ctrl.right +0 -70
  112. data/test/data/display.cmd +0 -24
  113. data/test/data/display.right +0 -44
  114. data/test/data/dollar-0.right +0 -2
  115. data/test/data/dollar-0a.right +0 -2
  116. data/test/data/dollar-0b.right +0 -2
  117. data/test/data/edit.cmd +0 -12
  118. data/test/data/edit.right +0 -19
  119. data/test/data/emacs_basic.cmd +0 -43
  120. data/test/data/emacs_basic.right +0 -106
  121. data/test/data/enable.cmd +0 -20
  122. data/test/data/enable.right +0 -36
  123. data/test/data/finish.cmd +0 -16
  124. data/test/data/finish.right +0 -31
  125. data/test/data/frame.cmd +0 -26
  126. data/test/data/frame.right +0 -55
  127. data/test/data/help.cmd +0 -20
  128. data/test/data/help.right +0 -21
  129. data/test/data/history.right +0 -7
  130. data/test/data/info-thread.cmd +0 -13
  131. data/test/data/info-thread.right +0 -37
  132. data/test/data/info-var-bug2.cmd +0 -5
  133. data/test/data/info-var-bug2.right +0 -10
  134. data/test/data/info-var.cmd +0 -23
  135. data/test/data/info-var.right +0 -52
  136. data/test/data/info.cmd +0 -21
  137. data/test/data/info.right +0 -65
  138. data/test/data/jump.cmd +0 -16
  139. data/test/data/jump.right +0 -56
  140. data/test/data/jump2.cmd +0 -16
  141. data/test/data/jump2.right +0 -44
  142. data/test/data/linetrace.cmd +0 -6
  143. data/test/data/linetrace.right +0 -23
  144. data/test/data/list.cmd +0 -19
  145. data/test/data/list.right +0 -127
  146. data/test/data/method.cmd +0 -10
  147. data/test/data/method.right +0 -21
  148. data/test/data/methodsig.cmd +0 -10
  149. data/test/data/methodsig.right +0 -20
  150. data/test/data/next.cmd +0 -22
  151. data/test/data/next.right +0 -61
  152. data/test/data/noquit.right +0 -1
  153. data/test/data/output.cmd +0 -6
  154. data/test/data/output.right +0 -31
  155. data/test/data/pm-bug.cmd +0 -7
  156. data/test/data/pm-bug.right +0 -12
  157. data/test/data/post-mortem-next.cmd +0 -8
  158. data/test/data/post-mortem-next.right +0 -14
  159. data/test/data/post-mortem-osx.right +0 -31
  160. data/test/data/post-mortem.cmd +0 -13
  161. data/test/data/post-mortem.right +0 -32
  162. data/test/data/quit.cmd +0 -6
  163. data/test/data/quit.right +0 -0
  164. data/test/data/raise.cmd +0 -11
  165. data/test/data/raise.right +0 -23
  166. data/test/data/save.cmd +0 -34
  167. data/test/data/save.right +0 -59
  168. data/test/data/scope-var.cmd +0 -42
  169. data/test/data/scope-var.right +0 -587
  170. data/test/data/setshow.cmd +0 -56
  171. data/test/data/setshow.right +0 -98
  172. data/test/data/source.cmd +0 -5
  173. data/test/data/source.right +0 -15
  174. data/test/data/stepping.cmd +0 -21
  175. data/test/data/stepping.right +0 -50
  176. data/test/data/test-init-cygwin.right +0 -7
  177. data/test/data/test-init-osx.right +0 -4
  178. data/test/data/test-init.right +0 -5
  179. data/test/data/trace.right +0 -14
  180. data/test/dollar-0.rb +0 -5
  181. data/test/gcd-dbg-nox.rb +0 -30
  182. data/test/gcd-dbg.rb +0 -29
  183. data/test/gcd.rb +0 -18
  184. data/test/helper.rb +0 -142
  185. data/test/info-var-bug.rb +0 -47
  186. data/test/info-var-bug2.rb +0 -2
  187. data/test/jump.rb +0 -14
  188. data/test/jump2.rb +0 -27
  189. data/test/lib/commands/catchpoint_test.rb +0 -28
  190. data/test/lib/commands/unit/regexp.rb +0 -38
  191. data/test/next.rb +0 -18
  192. data/test/null.rb +0 -1
  193. data/test/output.rb +0 -2
  194. data/test/pm-base.rb +0 -17
  195. data/test/pm-bug.rb +0 -3
  196. data/test/pm-catch.rb +0 -12
  197. data/test/pm-catch2.rb +0 -27
  198. data/test/pm-catch3.rb +0 -47
  199. data/test/pm.rb +0 -11
  200. data/test/raise.rb +0 -3
  201. data/test/rdebug-save.1 +0 -7
  202. data/test/runall +0 -12
  203. data/test/scope-var.rb +0 -29
  204. data/test/tdebug.rb +0 -246
  205. data/test/test-annotate.rb +0 -24
  206. data/test/test-break-bad.rb +0 -36
  207. data/test/test-breakpoints.rb +0 -24
  208. data/test/test-catch.rb +0 -24
  209. data/test/test-catch2.rb +0 -24
  210. data/test/test-catch3.rb +0 -24
  211. data/test/test-condition.rb +0 -24
  212. data/test/test-ctrl.rb +0 -51
  213. data/test/test-display.rb +0 -25
  214. data/test/test-dollar-0.rb +0 -39
  215. data/test/test-edit.rb +0 -25
  216. data/test/test-emacs-basic.rb +0 -25
  217. data/test/test-enable.rb +0 -24
  218. data/test/test-finish.rb +0 -33
  219. data/test/test-frame.rb +0 -33
  220. data/test/test-help.rb +0 -54
  221. data/test/test-hist.rb +0 -65
  222. data/test/test-info-thread.rb +0 -31
  223. data/test/test-info-var.rb +0 -46
  224. data/test/test-info.rb +0 -25
  225. data/test/test-init.rb +0 -43
  226. data/test/test-jump.rb +0 -34
  227. data/test/test-list.rb +0 -24
  228. data/test/test-method.rb +0 -33
  229. data/test/test-next.rb +0 -24
  230. data/test/test-output.rb +0 -25
  231. data/test/test-quit.rb +0 -29
  232. data/test/test-raise.rb +0 -24
  233. data/test/test-remote.rb +0 -14
  234. data/test/test-save.rb +0 -30
  235. data/test/test-scope-var.rb +0 -24
  236. data/test/test-setshow.rb +0 -24
  237. data/test/test-source.rb +0 -24
  238. data/test/test-stepping.rb +0 -25
  239. data/test/test-trace.rb +0 -46
  240. data/test/thread1.rb +0 -25
  241. data/test/trunc-call.rb +0 -30
@@ -0,0 +1,143 @@
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" do
137
+ must_restart
138
+ enter 'cont', 'restart'
139
+ debug_file 'post_mortem'
140
+ end
141
+ end
142
+
143
+ end
data/test/save_test.rb ADDED
@@ -0,0 +1,92 @@
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" do
86
+ enter 'cont', "save #{file_name}"
87
+ debug_file 'post_mortem'
88
+ file_contents.must_include "set autoirb off"
89
+ end
90
+ end
91
+
92
+ end
data/test/set_test.rb ADDED
@@ -0,0 +1,163 @@
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" do
72
+ enter 'set debuggertesting', 'break 3', 'cont'
73
+ debug_file('set') { state.must_be_kind_of Debugger::CommandProcessor::State }
74
+ end
75
+
76
+ it "must set basename on too" do
77
+ temporary_change_hash_value(Debugger::Command.settings, :basename, false) do
78
+ enter 'set debuggertesting', 'show basename'
79
+ debug_file('set')
80
+ check_output_includes "basename is on."
81
+ end
82
+ end
83
+
84
+ it "must not set $rdebug_context if debuggersetting is off" do
85
+ enter 'set nodebuggertesting', 'break 3', 'cont'
86
+ debug_file('set') { state.must_be_nil }
87
+ end
88
+ end
89
+
90
+ describe "history" do
91
+ describe "save" do
92
+ it "must set history save to on" do
93
+ enter 'set history save on'
94
+ debug_file 'set'
95
+ interface.history_save.must_equal true
96
+ end
97
+
98
+ it "must show a message" do
99
+ enter 'set history save on'
100
+ debug_file 'set'
101
+ check_output_includes "Saving of history save is on."
102
+ end
103
+
104
+ it "must set history save to off" do
105
+ enter 'set history save off'
106
+ debug_file 'set'
107
+ interface.history_save.must_equal false
108
+ end
109
+ end
110
+
111
+ describe "size" do
112
+ it "must set history size" do
113
+ enter 'set history size 250'
114
+ debug_file 'set'
115
+ interface.history_length.must_equal 250
116
+ end
117
+
118
+ it "must show a message" do
119
+ enter 'set history size 250'
120
+ debug_file 'set'
121
+ check_output_includes "Debugger history size is 250"
122
+ end
123
+ end
124
+
125
+ it "must show an error message if used wrong subcommand" do
126
+ enter 'set history bla 2'
127
+ debug_file 'set'
128
+ check_output_includes "Invalid history parameter bla. Should be 'save' or 'size'."
129
+ end
130
+
131
+ it "must show an error message if provided only one argument" do
132
+ enter 'set history save'
133
+ debug_file 'set'
134
+ check_output_includes "Need two parameters for 'set history'; got 1."
135
+ end
136
+ end
137
+
138
+ describe "width" do
139
+ temporary_change_hash_value(Debugger::Command.settings, :width, 20)
140
+
141
+ it "must set ENV['COLUMNS'] by the 'set width' command" do
142
+ old_columns = ENV["COLUMNS"]
143
+ begin
144
+ enter 'set width 10'
145
+ debug_file 'set'
146
+ ENV["COLUMNS"].must_equal '10'
147
+ ensure
148
+ ENV["COLUMNS"] = old_columns
149
+ end
150
+ end
151
+ end
152
+
153
+
154
+ describe "Post Mortem" do
155
+ temporary_change_hash_value(Debugger::Command.settings, :autolist, 0)
156
+ it "must work in post-mortem mode" do
157
+ enter 'cont', "set autolist on"
158
+ debug_file 'post_mortem'
159
+ check_output_includes "autolist is on."
160
+ end
161
+ end
162
+
163
+ end
data/test/show_test.rb ADDED
@@ -0,0 +1,292 @@
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" do
286
+ enter 'cont', "show autolist"
287
+ debug_file 'post_mortem'
288
+ check_output_includes "autolist is off."
289
+ end
290
+ end
291
+
292
+ end