trepanning 0.1.3 → 0.1.4

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 (134) hide show
  1. data/ChangeLog +465 -0
  2. data/NEWS +26 -1
  3. data/README.textile +1 -1
  4. data/app/cmd_parse.kpeg +2 -1
  5. data/app/cmd_parser.rb +30 -3
  6. data/app/core.rb +1 -1
  7. data/app/display.rb +39 -1
  8. data/app/frame.rb +1 -1
  9. data/app/irb.rb +42 -40
  10. data/app/options.rb +3 -2
  11. data/app/run.rb +21 -7
  12. data/app/util.rb +12 -2
  13. data/app/yarv.rb +0 -2
  14. data/bin/trepan +2 -3
  15. data/data/perldb.bindings +17 -0
  16. data/interface/script.rb +1 -1
  17. data/interface/server.rb +1 -1
  18. data/interface/user.rb +3 -1
  19. data/{interface/base_intf.rb → interface.rb} +1 -1
  20. data/io/input.rb +1 -3
  21. data/io/null_output.rb +1 -1
  22. data/io/string_array.rb +1 -2
  23. data/io/tcpclient.rb +1 -1
  24. data/io/tcpserver.rb +1 -1
  25. data/{io/base_io.rb → io.rb} +0 -0
  26. data/lib/trepanning.rb +2 -1
  27. data/processor/command/alias.rb +15 -4
  28. data/processor/command/backtrace.rb +2 -2
  29. data/processor/command/base/subcmd.rb +1 -5
  30. data/processor/command/base/submgr.rb +1 -1
  31. data/processor/command/base/subsubcmd.rb +1 -1
  32. data/processor/command/base/subsubmgr.rb +4 -4
  33. data/processor/command/break.rb +1 -1
  34. data/processor/command/complete.rb +1 -1
  35. data/processor/command/condition.rb +2 -2
  36. data/processor/command/continue.rb +1 -1
  37. data/processor/command/debug.rb +1 -1
  38. data/processor/command/delete.rb +10 -7
  39. data/processor/command/directory.rb +1 -1
  40. data/processor/command/disable.rb +25 -19
  41. data/processor/command/disassemble.rb +1 -1
  42. data/processor/command/display.rb +35 -28
  43. data/processor/command/down.rb +8 -8
  44. data/processor/command/edit.rb +1 -1
  45. data/processor/command/enable.rb +10 -12
  46. data/processor/command/eval.rb +1 -1
  47. data/processor/command/exit.rb +1 -1
  48. data/processor/command/finish.rb +1 -1
  49. data/processor/command/frame.rb +2 -2
  50. data/processor/command/help.rb +6 -8
  51. data/processor/command/info.rb +2 -0
  52. data/processor/command/info_subcmd/files.rb +17 -11
  53. data/processor/command/info_subcmd/frame.rb +0 -1
  54. data/processor/command/info_subcmd/locals.rb +6 -73
  55. data/processor/command/info_subcmd/source.rb +10 -4
  56. data/processor/command/info_subcmd/variables.rb +34 -0
  57. data/processor/command/info_subcmd/variables_subcmd/.gitignore +1 -0
  58. data/processor/command/info_subcmd/variables_subcmd/class.rb +40 -0
  59. data/processor/command/info_subcmd/variables_subcmd/constant.rb +41 -0
  60. data/processor/command/info_subcmd/{globals.rb → variables_subcmd/globals.rb} +21 -16
  61. data/processor/command/info_subcmd/variables_subcmd/instance.rb +41 -0
  62. data/processor/command/info_subcmd/variables_subcmd/locals.rb +99 -0
  63. data/processor/command/kill.rb +9 -8
  64. data/processor/command/list.rb +9 -107
  65. data/processor/command/macro.rb +27 -9
  66. data/processor/command/next.rb +1 -1
  67. data/processor/command/nocache.rb +2 -2
  68. data/processor/command/parsetree.rb +1 -1
  69. data/processor/command/pp.rb +1 -1
  70. data/processor/command/pr.rb +1 -1
  71. data/processor/command/ps.rb +1 -1
  72. data/processor/command/quit.rb +18 -7
  73. data/processor/command/raise.rb +1 -1
  74. data/processor/command/reload.rb +10 -10
  75. data/processor/command/restart.rb +1 -1
  76. data/processor/command/save.rb +1 -1
  77. data/processor/command/server.rb +1 -1
  78. data/processor/command/set_subcmd/auto.rb +7 -1
  79. data/processor/command/set_subcmd/different.rb +5 -4
  80. data/processor/command/set_subcmd/substitute_subcmd/eval.rb +2 -2
  81. data/processor/command/set_subcmd/trace.rb +5 -4
  82. data/processor/command/set_subcmd/trace_subcmd/print.rb +4 -3
  83. data/processor/command/shell.rb +5 -3
  84. data/processor/command/show_subcmd/{alias.rb → aliases.rb} +2 -2
  85. data/processor/command/show_subcmd/auto_subcmd/eval.rb +2 -7
  86. data/processor/command/show_subcmd/trace_subcmd/print.rb +3 -3
  87. data/processor/command/show_subcmd/version.rb +24 -0
  88. data/processor/command/source.rb +1 -1
  89. data/processor/command/step.rb +1 -1
  90. data/processor/command/tbreak.rb +1 -1
  91. data/processor/command/unalias.rb +11 -6
  92. data/processor/command/undisplay.rb +14 -10
  93. data/processor/command/up.rb +12 -13
  94. data/processor/command/watchg.rb +1 -1
  95. data/processor/{command/base/cmd.rb → command.rb} +3 -2
  96. data/processor/display.rb +34 -0
  97. data/processor/frame.rb +2 -2
  98. data/processor/help.rb +6 -4
  99. data/processor/hook.rb +95 -96
  100. data/processor/list.rb +146 -0
  101. data/processor/location.rb +26 -0
  102. data/processor/mock.rb +4 -7
  103. data/processor/msg.rb +54 -42
  104. data/processor/running.rb +6 -3
  105. data/processor/subcmd.rb +16 -41
  106. data/processor/validate.rb +6 -9
  107. data/{processor/main.rb → processor.rb} +11 -40
  108. data/sample/rocky-trepan-colors.rb +0 -1
  109. data/test/data/enable.cmd +1 -1
  110. data/test/data/trace.cmd +6 -0
  111. data/test/data/trace.right +39 -0
  112. data/test/example/gcd.rb +0 -1
  113. data/test/functional/test-next.rb +1 -1
  114. data/test/integration/helper.rb +4 -0
  115. data/test/integration/test-trace.rb +18 -0
  116. data/test/unit/cmd-helper.rb +4 -4
  117. data/test/unit/test-app-cmd_parse.rb +1 -1
  118. data/test/unit/test-app-display.rb +22 -0
  119. data/test/unit/test-app-options.rb +14 -10
  120. data/test/unit/test-app-run.rb +7 -1
  121. data/test/unit/test-base-subcmd.rb +1 -1
  122. data/test/unit/test-cmd-kill.rb +11 -4
  123. data/test/unit/test-cmd-parse_list_cmd.rb +1 -1
  124. data/test/unit/{test-base-cmd.rb → test-command.rb} +1 -1
  125. data/test/unit/test-proc-eval.rb +1 -2
  126. data/test/unit/test-proc-frame.rb +1 -2
  127. data/test/unit/test-proc-list.rb +52 -0
  128. data/test/unit/test-proc-load_cmds.rb +1 -1
  129. data/test/unit/test-proc-location.rb +11 -4
  130. data/test/unit/test-proc-main.rb +1 -1
  131. data/test/unit/test-proc-validate.rb +1 -2
  132. data/test/unit/test-subcmd-help.rb +1 -1
  133. data/trepanning.gemspec +1 -1
  134. metadata +26 -12
@@ -27,12 +27,8 @@ class Trepan
27
27
  include Trepan::ThreadHelper
28
28
  include Trepan::Condition
29
29
 
30
- def confirm(msg, default)
31
- @settings[:confirm] ? @dbgr.intf[-1].confirm(msg, default) : true
32
- end
33
-
34
- # Like cmdfns.get_an_int(), but if there's a stack frame use that
35
- # in evaluation.
30
+ # Check that arg is an Integer between opts[:min_value] and
31
+ # opts[:max_value]
36
32
  def get_an_int(arg, opts={})
37
33
  ret_value = get_int_noerr(arg)
38
34
  if !ret_value
@@ -230,7 +226,7 @@ class Trepan
230
226
  else
231
227
  errmsg "Come back later..."
232
228
  end
233
- elsif @frame.iseq.source_container[1] == file
229
+ elsif @frame.file == file
234
230
  line_no, vm_offset = position_to_line_and_offset(@frame.iseq, position,
235
231
  offset_type)
236
232
  return [@frame.iseq, line_no, vm_offset] + tail
@@ -362,8 +358,9 @@ if __FILE__ == $0
362
358
  require_relative '../app/mock'
363
359
  require_relative './default'
364
360
  require_relative 'frame'
365
- require_relative 'main' # Have to include before defining CmdProcessor!
366
- # FIXME
361
+
362
+ # FIXME: Have to include before defining CmdProcessor!
363
+ require_relative '../processor'
367
364
 
368
365
  cmdproc = Trepan::CmdProcessor.new(Trepan::MockCore.new())
369
366
  cmdproc.frame_initialize
@@ -2,14 +2,12 @@
2
2
  # The main "driver" class for a command processor. Other parts of the
3
3
  # command class and debugger command objects are pulled in from here.
4
4
 
5
- require 'set'
6
-
7
5
  %w(default breakpoint display eventbuf eval load_cmds location frame hook msg
8
6
  running validate).each do
9
7
  |mod_str|
10
- require_relative mod_str
8
+ require_relative "processor/#{mod_str}"
11
9
  end
12
- require_relative '../app/brkptmgr'
10
+ require_relative 'app/brkptmgr'
13
11
 
14
12
  class Trepan
15
13
  class CmdProcessor < VirtualCmdProcessor
@@ -34,6 +32,7 @@ class Trepan
34
32
  attr_accessor :event # Stop event. Same as @core.event
35
33
  attr_reader :intf # Current interface
36
34
  # Trepan::Core instance)
35
+ attr_reader :interfaces # Array of all interfaces
37
36
  attr_accessor :leave_cmd_loop # Commands set this to signal to leave
38
37
  # the command loop (which often continues to
39
38
  # run the debugged program).
@@ -58,35 +57,6 @@ class Trepan
58
57
  # current_thread, pc_offset]
59
58
 
60
59
 
61
- unless defined?(EVENT2ICON)
62
- # Event icons used in printing locations.
63
- EVENT2ICON = {
64
- 'brkpt' => 'xx',
65
- 'tbrkpt' => 'x1',
66
- 'c-call' => 'C>',
67
- 'c-return' => '<C',
68
- 'call' => '->',
69
- 'send' => '=>',
70
- 'leave' => '<=',
71
- 'class' => '::',
72
- 'coverage' => '[]',
73
- 'debugger-call' => ':o',
74
- 'end' => '-|',
75
- 'line' => '--',
76
- 'raise' => '!!',
77
- 'return' => '<-',
78
- 'switch' => 'sw',
79
- 'trace-var' => '$V',
80
- 'unknown' => '?!',
81
- 'vm' => 'VM',
82
- 'vm-insn' => '..',
83
- 'yield' => '<>',
84
- }
85
- # These events are important enough event that we always want to
86
- # stop on them.
87
- UNMASKABLE_EVENTS = Set.new(['end', 'raise', 'unknown'])
88
- end
89
-
90
60
  def initialize(core, settings={})
91
61
  @cmd_queue = []
92
62
  @core = core
@@ -128,6 +98,8 @@ class Trepan
128
98
  self.send("#{submod}_initialize")
129
99
  end
130
100
  hook_initialize(commands)
101
+ unconditional_prehooks.insert_if_new(-1, *trace_hook) if
102
+ @settings[:traceprint]
131
103
 
132
104
  # FIXME: run start file and start commands.
133
105
  end
@@ -194,11 +166,7 @@ class Trepan
194
166
  @cmd_queue.shift
195
167
  end
196
168
  if @current_command.empty?
197
- if @last_command && intf.interactive?
198
- @current_command = @last_command
199
- else
200
- next
201
- end
169
+ next unless @last_command && intf.interactive?;
202
170
  end
203
171
  next if @current_command[0..0] == '#' # Skip comment lines
204
172
  break
@@ -253,8 +221,11 @@ class Trepan
253
221
  @frame.pc_offset]
254
222
  else
255
223
  return if stepping_skip? || @stack_size <= @hide_level
224
+ if @settings[:traceprint]
225
+ step
226
+ return
227
+ end
256
228
  end
257
-
258
229
  @prompt = compute_prompt
259
230
 
260
231
  @leave_cmd_loop = false
@@ -376,7 +347,7 @@ end
376
347
 
377
348
  if __FILE__ == $0
378
349
  $0 = 'foo' # So we don't get here again
379
- require_relative '../lib/trepanning'
350
+ require_relative 'lib/trepanning'
380
351
  dbg = Trepan.new(:nx => true)
381
352
  dbg.core.processor.msg('I am main')
382
353
  cmdproc = dbg.core.processor
@@ -14,7 +14,6 @@
14
14
 
15
15
  require 'rubygems'
16
16
  require 'coderay'
17
- require 'coderay/encoders/term'
18
17
  TERM_TOKEN_COLORS = {
19
18
  :comment => '3;37', # sienna #8b4726
20
19
  :constant => '1;34', # Bold Midnight Blue #191970
data/test/data/enable.cmd CHANGED
@@ -1,7 +1,7 @@
1
1
  # ********************************************************
2
2
  # This tests the enable command.
3
3
  # ********************************************************
4
- set basename off
4
+ set basename on
5
5
  break gcd
6
6
  # Should have a breakpoint 1
7
7
  enable 1
@@ -0,0 +1,6 @@
1
+ # ***************************************************
2
+ # This file is not used, but is here to make it
3
+ # easy for the helper function.
4
+ # ***************************************************
5
+ continue
6
+
@@ -0,0 +1,39 @@
1
+ -- (gcd.rb:4 @2)
2
+ def gcd(a, b)
3
+ -- (gcd.rb:18 @2)
4
+ a, b = ARGV[0..1].map {|arg| arg.to_i}
5
+ -- (gcd.rb:18 @2)
6
+ a, b = ARGV[0..1].map {|arg| arg.to_i}
7
+ <= (gcd.rb:18 @11)
8
+ a, b = ARGV[0..1].map {|arg| arg.to_i}
9
+ -- (gcd.rb:19 @45)
10
+ puts "The GCD of %d and %d is %d" % [a, b, gcd(a, b)]
11
+ -- (gcd.rb:6 @4)
12
+ if a > b
13
+ -- (gcd.rb:12 @40)
14
+ if a == 1 or b-a == 0
15
+ METHOD Object#gcd(a, b)
16
+ -> (gcd.rb:4 @2)
17
+ def gcd(a, b)
18
+ -- (gcd.rb:10 @24)
19
+ return nil if a <= 0
20
+ -- (gcd.rb:15 @71)
21
+ return gcd(b-a, a)
22
+ -- (gcd.rb:6 @4)
23
+ if a > b
24
+ -- (gcd.rb:12 @40)
25
+ if a == 1 or b-a == 0
26
+ <- (gcd.rb:13 @68)
27
+ R=> 1
28
+ return a
29
+ <- (gcd.rb:16 @88)
30
+ R=> 1
31
+ end
32
+ <- (gcd.rb:16 @88)
33
+ R=> 1
34
+ end
35
+ <= (gcd.rb:16 @88)
36
+ end
37
+ The GCD of 3 and 5 is 1
38
+ <= (gcd.rb:19 @73)
39
+ puts "The GCD of %d and %d is %d" % [a, b, gcd(a, b)]
data/test/example/gcd.rb CHANGED
@@ -3,7 +3,6 @@
3
3
  # GCD. We assume positive numbers
4
4
  def gcd(a, b)
5
5
  # Make: a <= b
6
- debugger
7
6
  if a > b
8
7
  a, b = [b, a]
9
8
  end
@@ -65,7 +65,7 @@ class TestNext < Test::Unit::TestCase
65
65
  end
66
66
  ##############################
67
67
  d.stop # ({:remove => true})
68
- out = ['-- ', 'begin']
68
+ out = ['-- ', 'begin', "#<ZeroDivisionError: divided by 0>", "!! ", "x = 4/0"]
69
69
  compare_output(out, d, cmds)
70
70
  end
71
71
  end
@@ -36,6 +36,10 @@ def run_debugger(testname, ruby_file, opts={})
36
36
  if opts[:standalone]
37
37
  "%s %s %s >%s 2>&1" %
38
38
  [RbConfig.ruby, programfile, opts[:args], outfile]
39
+ elsif opts[:nocommand]
40
+ "%s %s --nx %s '%s' %s >%s 2>&1" %
41
+ [RbConfig.ruby, dbgr_path, opts[:dbgr],
42
+ programfile, opts[:args], outfile]
39
43
  else
40
44
  "%s %s --nx --command %s %s '%s' %s >%s 2>&1" %
41
45
  [RbConfig.ruby, dbgr_path, cmdfile, opts[:dbgr],
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ require 'test/unit'
3
+ require_relative 'helper'
4
+
5
+ class TestTrace < Test::Unit::TestCase
6
+ @@NAME = File.basename(__FILE__, '.rb')[5..-1]
7
+ TREPAN_LOC = /.. \(.+:\d+( @\d+)?\)/
8
+
9
+ def test_trepan_trace
10
+ opts = {:dbgr => '-x', :args => '3 5', :nocommand => true}
11
+ opts[:filter] = Proc.new{|got_lines, correct_lines|
12
+ got_lines.each do |line|
13
+ line.gsub!(/\((?:.*\/)?(.+:\d+) @/, '(\1 @') if line =~ TREPAN_LOC
14
+ end
15
+ }
16
+ assert_equal(true, run_debugger(@@NAME, 'gcd.rb', opts))
17
+ end
18
+ end
@@ -7,10 +7,10 @@ require_relative '../../processor/frame'
7
7
  module UnitHelper
8
8
 
9
9
  def common_setup
10
- @dbg = Trepan::MockDebugger.new(:nx => true)
11
- @core = Trepan::Core.new(@dbg)
12
- @cmdproc = @core.processor = Trepan::CmdProcessor.new(@core)
13
- @cmds = @cmdproc.commands
10
+ @dbg ||= Trepan::MockDebugger.new(:nx => true)
11
+ @core ||= Trepan::Core.new(@dbg)
12
+ @cmdproc ||= @core.processor = Trepan::CmdProcessor.new(@core)
13
+ @cmds ||= @cmdproc.commands
14
14
 
15
15
  def @cmdproc.msg(message, opts={})
16
16
  @msgs << message
@@ -101,7 +101,7 @@ class TestCmdParse < Test::Unit::TestCase
101
101
  end
102
102
  %w(O5).each do |str|
103
103
  meth = meth_for_string(str, binding)
104
- assert_equal nil, meth, "should have found a method for #{str}"
104
+ assert_equal nil, meth, "should not have found a method for #{str}"
105
105
  end
106
106
  end
107
107
  end
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+ require 'test/unit'
3
+ require_relative '../../app/display'
4
+ require 'thread_frame'
5
+
6
+ class TestLibAppBrkptMgr < Test::Unit::TestCase
7
+
8
+ def test_basic
9
+ tf = RubyVM::ThreadFrame.current
10
+ mgr = DisplayMgr.new
11
+ x = 1
12
+ assert_equal(0, mgr.size)
13
+ disp = mgr.add(tf, 'x > 1')
14
+ assert_equal(1, mgr.max)
15
+ assert_equal(true, disp.enabled?)
16
+
17
+ mgr.enable_disable(disp.number, false)
18
+ assert_equal(false, disp.enabled?)
19
+ mgr.enable_disable(disp.number, true)
20
+ assert_equal(true, disp.enabled?)
21
+ end
22
+ end
@@ -52,16 +52,20 @@ class TestAppOptions < Test::Unit::TestCase
52
52
  end
53
53
 
54
54
  def test_help_and_version_opts
55
- %w(help version).each do |name|
56
- setup
57
- o = ["--#{name}"]
58
- rest = @opts.parse o
59
- assert_not_equal('', @stdout.string)
60
- assert_equal('', @stderr.string)
61
- assert_equal(true, @options[name.to_sym])
62
- other_sym = 'help' == name ? :version : :help
63
- assert_equal(false, @options.member?(other_sym))
64
- end
55
+ omit unless Process.respond_to?(:fork)
56
+ Process.fork {
57
+ %w(help version).each do |name|
58
+ setup
59
+ o = ["--#{name}"]
60
+ rest = @opts.parse o
61
+ assert_not_equal('', @stdout.string)
62
+ assert_equal('', @stderr.string)
63
+ assert_equal(true, @options[name.to_sym])
64
+ other_sym = 'help' == name ? :version : :help
65
+ assert_equal(false, @options.member?(other_sym))
66
+ end
67
+ }
68
+ Process.wait
65
69
  end
66
70
 
67
71
  def test_both_client_server_opts
@@ -4,10 +4,16 @@ require_relative '../../app/run'
4
4
 
5
5
  class TestAppRun < Test::Unit::TestCase
6
6
  include Trepanning
7
- def test_basic
7
+ def test_whence
8
8
  assert_equal(true, File.executable?(whence_file('irb')))
9
9
  ng = whence_file('probably-does-not-exist')
10
10
  assert_equal(true, File.executable?(ng) || ng == 'probably-does-not-exist')
11
11
  end
12
12
 
13
+ def test_ruby_syntax_errors
14
+ assert_nil ruby_syntax_errors __FILE__
15
+ readme = File.join(File.dirname(__FILE__), %w(.. .. README.textile))
16
+ assert ruby_syntax_errors(readme)
17
+ end
18
+
13
19
  end
@@ -2,7 +2,7 @@
2
2
  require 'test/unit'
3
3
  require_relative '../../app/core'
4
4
  require_relative '../../app/mock'
5
- require_relative '../../processor/main'
5
+ require_relative '../../processor'
6
6
  require_relative '../../processor/command/exit'
7
7
  require_relative '../../processor/command/base/subcmd'
8
8
 
@@ -23,10 +23,17 @@ class TestCommandKill < Test::Unit::TestCase
23
23
  end
24
24
 
25
25
  def test_kill_command
26
- @cmd.run([@name, 'foo'])
27
- assert_equal(false, @cmd.proc.leave_cmd_loop)
28
- assert_equal(1, @cmd.instance_variable_get('@errmsgs').size)
29
-
26
+ assert_equal(['unconditionally'], @cmd.complete('uncon'))
27
+
28
+ if Signal.list.member?('HUP')
29
+ assert_equal(['hup'], @cmd.complete('hu'))
30
+ assert_equal(['HUP'], @cmd.complete('HU'))
31
+ end
32
+
33
+ @cmd.run([@name, 'foo'])
34
+ assert_equal(false, @cmd.proc.leave_cmd_loop)
35
+ assert_equal(1, @cmd.instance_variable_get('@errmsgs').size)
36
+
30
37
  if false
31
38
  save_trap = Signal.trap(10) {
32
39
  @success = true
@@ -24,7 +24,7 @@ class TestCommandParseListCmd < Test::Unit::TestCase
24
24
  ['Columnize.columnize 30 3', ['columnize.rb', 30, 32]],
25
25
  ['Columnize.columnize 40 50', ['columnize.rb', 40, 50]],
26
26
  ].each do |arg_str, expect|
27
- got = @cmd.parse_list_cmd(arg_str, listsize, listsize/2)[1..-1]
27
+ got = @cmdproc.parse_list_cmd(arg_str, listsize, listsize/2)[1..-1]
28
28
  got[0] = File.basename(got[0])
29
29
  assert_equal expect, got
30
30
  end
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'test/unit'
3
- require_relative '../../processor/command/base/cmd'
3
+ require_relative '../../processor/command'
4
4
 
5
5
  class Trepan::Command::Test < Trepan::Command
6
6
  NAME = 'test'
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'test/unit'
3
- require_relative '../../processor/main' # Have to include before frame!
4
- # FIXME
3
+ require_relative '../../processor'
5
4
  require_relative '../../processor/eval'
6
5
  require_relative '../../app/mock'
7
6
 
@@ -1,8 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'test/unit'
3
3
  require 'thread_frame'
4
- require_relative '../../processor/main' # Have to include before frame!
5
- # FIXME
4
+ require_relative '../../processor'
6
5
  require_relative '../../processor/frame'
7
6
  require_relative '../../app/mock'
8
7
 
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env ruby
2
+ require 'test/unit'
3
+ require_relative '../../processor'
4
+ require_relative '../../processor/list'
5
+ require_relative '../../app/mock'
6
+
7
+ # Test Trepan::CmdProcessor List portion
8
+ class TestProcList < Test::Unit::TestCase
9
+
10
+ def setup
11
+ $errors = []
12
+ $msgs = []
13
+ @proc = Trepan::CmdProcessor.new(Trepan::MockCore.new())
14
+ @proc.frame_index = 0
15
+ @proc.frame_initialize
16
+ class << @proc
17
+ def msg(msg)
18
+ $msgs << msg
19
+ end
20
+ def errmsg(msg)
21
+ $errors << msg
22
+ end
23
+ def print_location
24
+ # $msgs << "#{@frame.source_container} #{@frame.source_location[0]}"
25
+ $msgs << "#{@frame.source_container} "
26
+ # puts $msgs
27
+ end
28
+ end
29
+ end
30
+
31
+ def test_basic
32
+ @proc.frame_setup(RubyVM::ThreadFrame.current)
33
+
34
+ def foo; 5 end
35
+ def check(cmdp, arg, last=10)
36
+ r = cmdp.parse_list_cmd('.', last)
37
+ assert r[1]
38
+ assert r[2]
39
+ assert r[3]
40
+ end
41
+ check(@proc, '-')
42
+ check(@proc, 'foo')
43
+ check(@proc, '@0')
44
+ check(@proc, "#{__LINE__}")
45
+ check(@proc, "#{__FILE__} @0")
46
+ check(@proc, "#{__FILE__}:#{__LINE__}")
47
+ check(@proc, "#{__FILE__} #{__LINE__}")
48
+ check(@proc, "#{__FILE__} #{__LINE__}", -10)
49
+ check(@proc, "@proc.errmsg")
50
+ check(@proc, "@proc.errmsg:@0")
51
+ end
52
+ end
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'test/unit'
3
- require_relative '../../processor/main'
3
+ require_relative '../../processor'
4
4
  require_relative '../../app/mock'
5
5
 
6
6
  class TestCmdProcessorLoadCmds < Test::Unit::TestCase
@@ -1,17 +1,24 @@
1
1
  #!/usr/bin/env ruby
2
2
  require_relative 'cmd-helper'
3
3
 
4
- # Test Debugger:CmdProcessor Location portion
5
- class TestProcLocation < Test::Unit::TestCase
4
+ # Test Debugger:CmdProcessor location portion
5
+ class TestCmdProcessorLocation < Test::Unit::TestCase
6
6
 
7
7
  include UnitHelper
8
8
  def setup
9
9
  common_setup
10
- @name = File.basename(__FILE__, '.rb').split(/-/)[2]
10
+ @name ||= File.basename(__FILE__, '.rb').split(/-/)[2]
11
11
  @cmdproc.settings[:basename] = true
12
12
  end
13
13
 
14
- def test_it
14
+ def test_canonic_file
15
+ @cmdproc.settings[:basename] = false
16
+ assert_equal File.expand_path(__FILE__), @cmdproc.canonic_file(__FILE__)
17
+ @cmdproc.settings[:basename] = true
18
+ assert_equal File.basename(__FILE__), @cmdproc.canonic_file(__FILE__)
19
+ end
20
+
21
+ def test_eval_current_source_text
15
22
  assert_equal File.basename(__FILE__), @cmdproc.canonic_file(__FILE__)
16
23
  eval <<-EOE
17
24
  @cmdproc.frame_initialize
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'test/unit'
3
3
  require_relative '../../app/mock'
4
- require_relative '../../processor/main'
4
+ require_relative '../../processor'
5
5
  require_relative '../../app/core'
6
6
 
7
7
  # Test Trepan:CmdProcessor
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'test/unit'
3
- require_relative '../../processor/main' # Have to include before validate!
4
- # FIXME
3
+ require_relative '../../processor'
5
4
  require_relative '../../processor/validate'
6
5
  require_relative '../../app/mock'
7
6
  require 'thread_frame'
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'test/unit'
3
- require_relative '../../processor/main'
3
+ require_relative '../../processor'
4
4
  require_relative '../../app/core'
5
5
 
6
6
  # Test Trepan::CmdProcessor
data/trepanning.gemspec CHANGED
@@ -22,7 +22,7 @@ EOF
22
22
  spec.add_dependency('rb-trace', '>= 0.5')
23
23
  spec.add_dependency('linecache-tf', '>= 1.0')
24
24
  spec.add_dependency('columnize')
25
- spec.add_dependency('diff-lcs') # For testing only
25
+ spec.add_development_dependency('diff-lcs') # For testing only
26
26
  spec.author = 'R. Bernstein'
27
27
  spec.bindir = 'bin'
28
28
  spec.email = 'rockyb@rubyforge.net'