debugger 1.2.4 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,56 +0,0 @@
1
- # This tests the functioning of some set/show debugger commands
2
- set debuggertesting on
3
- ### *******************************
4
- ### *** Set/show commands ***
5
- ### *******************************
6
- ########################################
7
- ### test args and baseneme...
8
- ########################################
9
- set args this is a test
10
- show args
11
- show basename
12
- set basename foo
13
- show base
14
- set basename off
15
- show basename
16
- set basename 0
17
- show basename
18
- set basename 1
19
- show basename
20
- ########################################
21
- ### test listsize tests...
22
- ########################################
23
- show listsize
24
- show listsi
25
- set listsize abc
26
- set listsize -20
27
- ########################################
28
- ### test linetrace...
29
- ########################################
30
- set linetrace on
31
- show linetrace
32
- set linetrace off
33
- show linetrace
34
- ########################################
35
- ### show history
36
- ########################################
37
- set history
38
- set history size 10
39
- show history size
40
- set history save off
41
- show history save
42
- set history save 1
43
- show history save
44
- #### Test 'autoeval'...
45
- set autoeval on
46
- puts 'printed via autoeval'
47
- set autoeval off
48
- puts 'autoeval should not run this'
49
- #### Test 'callstyle'...
50
- set callstyle
51
- set callstyle short
52
- set callstyle last
53
- set callstyle tracked
54
- set callstyle foo
55
-
56
-
@@ -1,98 +0,0 @@
1
- gcd.rb:4
2
- def gcd(a, b)
3
- # # This tests the functioning of some set/show debugger commands
4
- # set debuggertesting on
5
- Currently testing the debugger is on.
6
- # ### *******************************
7
- # ### *** Set/show commands ***
8
- # ### *******************************
9
- # ########################################
10
- # ### test args and baseneme...
11
- # ########################################
12
- # set args this is a test
13
- Argument list to give program being debugged when it is started is "this is a test".
14
- # show args
15
- Argument list to give program being debugged when it is started is "this is a test".
16
- # show basename
17
- basename is on.
18
- # set basename foo
19
- Expecting 'on', 1, 'off', or 0. Got: foo.
20
- # show base
21
- basename is on.
22
- # set basename off
23
- basename is off.
24
- # show basename
25
- basename is off.
26
- # set basename 0
27
- basename is off.
28
- # show basename
29
- basename is off.
30
- # set basename 1
31
- basename is on.
32
- # show basename
33
- basename is on.
34
- # ########################################
35
- # ### test listsize tests...
36
- # ########################################
37
- # show listsize
38
- Number of source lines to list by default is 10.
39
- # show listsi
40
- Number of source lines to list by default is 10.
41
- # set listsize abc
42
- Set listsize argument 'abc' needs to be a number.
43
- # set listsize -20
44
- Set listsize argument '-20' needs to at least 1.
45
- # ########################################
46
- # ### test linetrace...
47
- # ########################################
48
- # set linetrace on
49
- line tracing is on.
50
- # show linetrace
51
- line tracing is on.
52
- # set linetrace off
53
- line tracing is off.
54
- # show linetrace
55
- line tracing is off.
56
- # ########################################
57
- # ### show history
58
- # ########################################
59
- # set history
60
- Need two parameters for 'set history'; got 0.
61
- # set history size 10
62
- Debugger history size is 10
63
- # show history size
64
- Debugger history size is 10
65
- # set history save off
66
- Saving of history save is off.
67
- # show history save
68
- Saving of history save is off.
69
- # set history save 1
70
- Saving of history save is on.
71
- # show history save
72
- Saving of history save is on.
73
- # #### Test 'autoeval'...
74
- # set autoeval on
75
- autoeval is on.
76
- # puts 'printed via autoeval'
77
- printed via autoeval
78
- nil
79
- # set autoeval off
80
- autoeval is off.
81
- # puts 'autoeval should not run this'
82
- *** Unknown command: "puts 'autoeval should not run this'". Try "help".
83
- # #### Test 'callstyle'...
84
- # set callstyle
85
- Invalid call style . Should be one of: 'short' or 'last'.
86
- Frame call-display style is last.
87
- # set callstyle short
88
- Frame call-display style is short.
89
- # set callstyle last
90
- Frame call-display style is last.
91
- # set callstyle tracked
92
- Invalid call style tracked. Should be one of: 'short' or 'last'.
93
- Frame call-display style is last.
94
- # set callstyle foo
95
- Invalid call style foo. Should be one of: 'short' or 'last'.
96
- Frame call-display style is last.
97
- #
98
- #
data/test/data/source.cmd DELETED
@@ -1,5 +0,0 @@
1
- # Test the source command
2
- # rdebug-save has breakpoint commands
3
- set debuggertesting on
4
- source ./rdebug-save.1
5
- quit
@@ -1,15 +0,0 @@
1
- gcd.rb:4
2
- def gcd(a, b)
3
- # # Test the source command
4
- # # rdebug-save has breakpoint commands
5
- # set debuggertesting on
6
- Currently testing the debugger is on.
7
- # source ./rdebug-save.1
8
- Breakpoint 1 file gcd.rb, line 10
9
- Breakpoint 2 file gcd.rb, line 12
10
- autoeval is on.
11
- basename is off.
12
- Currently testing the debugger is on.
13
- autolist is off.
14
- autoirb is off.
15
- # quit
@@ -1,21 +0,0 @@
1
- # ***************************************************
2
- # This tests step, next, finish and continue
3
- # ***************************************************
4
- set debuggertesting on
5
- set callstyle last
6
- next
7
- where
8
- step a
9
- set forcestep on
10
- step- ; step-
11
- set forcestep off
12
- where
13
- next
14
- step+
15
- where
16
- step 3
17
- step+
18
- where
19
- next+
20
- # finish
21
- quit
@@ -1,50 +0,0 @@
1
- gcd.rb:4
2
- def gcd(a, b)
3
- # # ***************************************************
4
- # # This tests step, next, finish and continue
5
- # # ***************************************************
6
- # set debuggertesting on
7
- Currently testing the debugger is on.
8
- # set callstyle last
9
- Frame call-display style is last.
10
- # next
11
- gcd.rb:18
12
- gcd(3,5)
13
- # where
14
- --> #0 at line gcd.rb:18
15
- # step a
16
- Step argument 'a' needs to be a number.
17
- # set forcestep on
18
- force-stepping is on.
19
- # step- ; step-
20
- gcd.rb:6
21
- if a > b
22
- # set forcestep off
23
- force-stepping is off.
24
- # where
25
- --> #0 Object.gcd(a#Fixnum, b#Fixnum) at line gcd.rb:6
26
- #1 at line gcd.rb:18
27
- # next
28
- gcd.rb:10
29
- return nil if a <= 0
30
- # step+
31
- gcd.rb:12
32
- if a == 1 or b-a == 0
33
- # where
34
- --> #0 Object.gcd(a#Fixnum, b#Fixnum) at line gcd.rb:12
35
- #1 at line gcd.rb:18
36
- # step 3
37
- gcd.rb:10
38
- return nil if a <= 0
39
- # step+
40
- gcd.rb:12
41
- if a == 1 or b-a == 0
42
- # where
43
- --> #0 Object.gcd(a#Fixnum, b#Fixnum) at line gcd.rb:12
44
- #1 Object.gcd(a#Fixnum, b#Fixnum) at line gcd.rb:15
45
- #2 at line gcd.rb:18
46
- # next+
47
- gcd.rb:15
48
- gcd(b-a, a)
49
- # # finish
50
- # quit
@@ -1,7 +0,0 @@
1
- gcd-dbg.rb:18
2
- if a > b
3
- (rdb:1) p Debugger::PROG_SCRIPT
4
- "./gcd-dbg.rb"
5
- (rdb:1) show args
6
- Argument list to give program being debugged when it is started is "5".
7
- (rdb:1) quit unconditionally
@@ -1,4 +0,0 @@
1
- gcd-dbg.rb:18
2
- if a > b
3
- "./gcd-dbg.rb"
4
- Argument list to give program being debugged when it is started is "5".
@@ -1,5 +0,0 @@
1
- gcd-dbg.rb:18
2
- if a > b
3
- (rdb:1) "./gcd-dbg.rb"
4
- (rdb:1) Argument list to give program being debugged when it is started is "5".
5
- (rdb:1)
@@ -1,14 +0,0 @@
1
- Tracing(1):./gcd.rb:4 def gcd(a, b)
2
- Tracing(1):./gcd.rb:18 gcd(3,5)
3
- Tracing(1):./gcd.rb:6 if a > b
4
- Tracing(1):./gcd.rb:10 return nil if a <= 0
5
- Tracing(1):./gcd.rb:12 if a == 1 or b-a == 0
6
- Tracing(1):./gcd.rb:15 gcd(b-a, a)
7
- Tracing(1):./gcd.rb:6 if a > b
8
- Tracing(1):./gcd.rb:10 return nil if a <= 0
9
- Tracing(1):./gcd.rb:12 if a == 1 or b-a == 0
10
- Tracing(1):./gcd.rb:15 gcd(b-a, a)
11
- Tracing(1):./gcd.rb:6 if a > b
12
- Tracing(1):./gcd.rb:10 return nil if a <= 0
13
- Tracing(1):./gcd.rb:12 if a == 1 or b-a == 0
14
- Tracing(1):./gcd.rb:13 return a
data/test/dollar-0.rb DELETED
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # A test to see that rdebug set's $0 properly.
3
- puts $0
4
- puts __FILE__
5
-
data/test/gcd-dbg-nox.rb DELETED
@@ -1,30 +0,0 @@
1
- # This program is *NOT* supposed to be executable, but called
2
- # via ruby (in order to test that restart provides a funky $:).
3
- # This program is used to test that 'restart' works when we didn't call
4
- # the debugger initially.
5
-
6
- TOP_SRC_DIR = File.join(File.expand_path(File.dirname(__FILE__), '..')) unless
7
- defined?(TOP_SRC_DIR)
8
-
9
- $:.unshift File.join(TOP_SRC_DIR, 'ext')
10
- $:.unshift File.join(TOP_SRC_DIR, 'lib')
11
- require 'ruby-debug'
12
- Debugger.init
13
-
14
- # GCD. We assume positive numbers
15
- def gcd(a, b)
16
- # Make: a <= b
17
- debugger
18
- if a > b
19
- a, b = [b, a]
20
- end
21
-
22
- return nil if a <= 0
23
-
24
- if a == 1 or b-a == 0
25
- return a
26
- end
27
- return gcd(b-a, a)
28
- end
29
-
30
- gcd(3,5)
data/test/gcd-dbg.rb DELETED
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # This program is used to test that 'restart' works when we didn't call
3
- # the debugger initially.
4
-
5
- TOP_SRC_DIR = File.join(File.expand_path(File.dirname(__FILE__), "..")) unless
6
- defined?(TOP_SRC_DIR)
7
-
8
- $:.unshift File.join(TOP_SRC_DIR, "ext")
9
- $:.unshift File.join(TOP_SRC_DIR, "lib")
10
- require 'ruby-debug'
11
-
12
-
13
- # GCD. We assume positive numbers
14
- def gcd(a, b)
15
- # Make: a <= b
16
- debugger
17
- if a > b
18
- a, b = [b, a]
19
- end
20
-
21
- return nil if a <= 0
22
-
23
- if a == 1 or b-a == 0
24
- return a
25
- end
26
- return gcd(b-a, a)
27
- end
28
-
29
- gcd(3,5)
data/test/gcd.rb DELETED
@@ -1,18 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # GCD. We assume positive numbers
4
- def gcd(a, b)
5
- # Make: a <= b
6
- if a > b
7
- a, b = [b, a]
8
- end
9
-
10
- return nil if a <= 0
11
-
12
- if a == 1 or b-a == 0
13
- return a
14
- end
15
- gcd(b-a, a)
16
- end
17
-
18
- gcd(3,5)
data/test/helper.rb DELETED
@@ -1,142 +0,0 @@
1
- # Some common routines used in testing.
2
-
3
- require 'fileutils'
4
- require 'yaml'
5
- # require 'diff/lcs'
6
- # require 'diff/lcs/hunk'
7
-
8
- # require 'ruby-debug'; Debugger.start
9
-
10
- module TestHelper
11
-
12
- # FIXME: turn args into a hash.
13
- def run_debugger(testname, args='', outfile=nil, filter=nil, old_code=false,
14
- debug_pgm='tdebug.rb')
15
- rightfile = File.join('data', "#{testname}.right")
16
-
17
- outfile = "#{testname}.out" unless outfile
18
-
19
- if File.exists?(outfile)
20
- FileUtils.rm(outfile)
21
- end
22
-
23
- ENV['RDEBUG'] = debug_pgm
24
-
25
- if old_code
26
- cmd = "/bin/sh #{File.join('..', 'runner.sh')} #{args} >#{outfile}"
27
- else
28
- cmd = "#{"#{load_ruby} #{load_params} "}../rdbg.rb #{args} > #{outfile}"
29
- end
30
- puts "'#{cmd}'" if $DEBUG
31
- output = `#{cmd}`
32
-
33
- curr_path = Dir.pwd
34
- got_lines = File.read(outfile).split(/\n/).map{|s| s.sub(curr_path, '.') }
35
- correct_lines = File.read(rightfile).split(/\n/)
36
- filter.call(got_lines, correct_lines) if filter
37
- if cheap_diff(got_lines, correct_lines)
38
- FileUtils.rm(outfile)
39
- return true
40
- end
41
- return false
42
- end
43
-
44
- def cheap_diff(got_lines, correct_lines)
45
- if $DEBUG
46
- got_lines.each_with_index do |line, i|
47
- printf "%3d %s\n", i+1, line
48
- end
49
- end
50
- correct_lines.each_with_index do |line, i|
51
- correct_lines[i].chomp!
52
- if got_lines[i] != correct_lines[i]
53
- puts "difference found at line #{i+1}"
54
- puts "got : #{got_lines[i]}"
55
- puts "need: #{correct_lines[i]}"
56
- return false
57
- end
58
- end
59
- if correct_lines.size != got_lines.size
60
- puts("difference in number of lines: " +
61
- "#{correct_lines.size} vs. #{got_lines.size}")
62
- return false
63
- end
64
- return true
65
- end
66
-
67
- # FIXME: using this causes the same test to get run several times
68
- # and some tests fail probably because of a lack of environment isolation.
69
- # Many tests follow a basic pattern: run the debugger with a given
70
- # debugger script and compare output produced. The following creates
71
- # this kind of test.
72
- def add_test(base_name, src_dir, script_name=nil, cmd=nil, test_name=nil)
73
- puts "+++ Adding #{base_name} ++++" if $DEBUG
74
- test_name = base_name unless test_name
75
- script_name = File.join('data', test_name + '.cmd') unless script_name
76
- cmd = 'gcd.rb 3 5' unless cmd
77
- eval <<-EOF
78
- def test_#{test_name}
79
- Dir.chdir(\"#{src_dir}\") do
80
- assert_equal(true,
81
- run_debugger(\"#{base_name}\",
82
- \"--script #{script_name} -- #{cmd}\"))
83
- end
84
- end
85
- EOF
86
- end
87
- module_function :add_test
88
-
89
- # Adapted from the Ruby Cookbook, Section 6.10: Comparing two files.
90
- # def diff_as_string(rightfile, checkfile, format=:unified, context_lines=3)
91
- # right_data = File.read(rightfile)
92
- # check_data = File.read(checkfile)
93
- # output = ''
94
- # diffs = Diff::LCS.diff(right_data, check_data)
95
- # return output if diffs.empty?
96
- # oldhunk = hunk = nil
97
- # file_length_difference = 0
98
- # diffs.each do |piece|
99
- # begin
100
- # hunk = Diff::LCS::Hunk.new(right_data, check_data, piece,
101
- # context_lines, file_length_difference)
102
- # next unless oldhunk
103
- #
104
- # # Hunks may overlap, which is why we need to be careful when our
105
- # # diff includes lines of context. Otherwise, we might print
106
- # # redundant lines.
107
- # if (context_lines > 0) and hunk.overlaps?(oldhunk)
108
- # hunk.unshift(oldhunk)
109
- # else
110
- # output << oldhunk.diff(format)
111
- # end
112
- # ensure
113
- # oldhunk = hunk
114
- # output << '\n'
115
- # end
116
- # end
117
-
118
- # # Handle the last remaining hunk
119
- # output << oldhunk.diff(format) << '\n'
120
- # end
121
-
122
- # Loads key from the _config_._yaml_ file.
123
- def config_load(key, may_be_nil=false, default_value='')
124
- conf = File.join('config.private.yaml') # try private first
125
- conf = File.join('config.yaml') unless File.exists?(conf)
126
- value = YAML.load_file(conf)[key]
127
- assert_not_nil(value, "#{key} is set in config.yaml") unless may_be_nil
128
- value || default_value
129
- end
130
- module_function :config_load
131
-
132
- def load_ruby
133
- config_load('ruby', true)
134
- end
135
- module_function :load_ruby
136
-
137
- def load_params
138
- config_load('ruby_params', true)
139
- end
140
- module_function :load_params
141
-
142
- end