Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add test of test-fn_helper.rb

Appease the RDoc God.
  • Loading branch information...
commit f7f10e99c12dfef4148b9c34297f6b2909407527 1 parent b027ceb
@rocky authored
View
1  .gitignore
@@ -1,3 +1,4 @@
/*~
+/doc
/pkg
/tmp
View
2  app/frame.rb
@@ -255,7 +255,7 @@ def babe(a, b, *rest)
print_stack_trace(RubyVM::ThreadFrame::current)
end
x.call(1,2)
- class C
+ class C # :nodoc
def initialize(a)
print_stack_trace(RubyVM::ThreadFrame::current)
end
View
2  lib/trepanning.rb
@@ -248,7 +248,7 @@ def trepan(opts={}, &block)
end
if __FILE__ == $0
- def square(x)
+ def square(x) # :nodoc
x * x
end
puts 'block debugging...'
View
2  processor/command/alias.rb
@@ -24,7 +24,7 @@ def run(args)
if args.size == 1
@proc.commands['show'].run(%w(show alias))
elsif args.size == 2
- @proc.commands['show'].run(%W(show alias #{args[1]}))
+ @proc.commands['show'].run(['show', 'alias', args[1]])
else
junk, al, command = args
old_command = @proc.aliases[al]
View
2  processor/command/backtrace.rb
@@ -33,7 +33,7 @@ class Trepan::Command::BacktraceCommand < Trepan::Command
include Trepan::Frame
# This method runs the command
- def run(args) # :nodoc
+ def run(args)
unless @proc.frame
errmsg 'No frame.'
return false
View
2  processor/command/break.rb
@@ -25,7 +25,7 @@ class Trepan::Command::BreakCommand < Trepan::Command
end
# This method runs the command
- def run(args) # :nodoc
+ def run(args)
# FIXME: handle more conditions
# a line number
if args.size == 1
View
2  processor/command/continue.rb
@@ -31,7 +31,7 @@ class Trepan::Command::ContinueCommand < Trepan::Command
end
# This method runs the command
- def run(args) # :nodoc
+ def run(args)
if args.size == 1
# Form is: "continue"
@proc.continue
View
43 processor/command/directory.rb
@@ -0,0 +1,43 @@
+# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
+require_relative 'base/cmd'
+class Trepan::Command::DirectoryCommand < Trepan::Command
+
+ unless defined?(HELP)
+ ALIASES = %w(dir)
+ CATEGORY = 'files'
+ MAX_ARGS = 1 # Need at most this many
+ NAME = File.basename(__FILE__, '.rb')
+ HELP = <<-HELP
+Add directory DIR to beginning of search path for source files.
+DIR can also be $cwd for the current working directory, or $cdir for the
+directory in which the debugged file start.
+With no argument, reset the search path to $cdir:$cwd, the default.
+
+This command may be useful for debugging into Rubinius methods such as
+kernel/common/module.rb if have the source code somewhere.
+ HELP
+ SHORT_HELP =
+ 'Add directory DIR to beginning of search path for source files'
+ end
+
+ # This method runs the command
+ def run(args)
+ if args.size > 1
+ settings[:directory] = "#{args[1]}:#{settings[:directory]}"
+ msg "Source directories searched: #{settings[:directory]}"
+ else
+ if confirm('Reintialize source path to empty?', false)
+ settings[:directory] = '$cdir:$cwd'
+ msg 'Source directories searched: $cdir:$cwd'
+ end
+ end
+ end
+end
+
+if __FILE__ == $0
+ require_relative '../mock'
+ name = File.basename(__FILE__, '.rb')
+ dbgr, cmd = MockDebugger::setup(name)
+ cmd.run([name])
+ cmd.run([name, '/tmp'])
+end
View
2  processor/command/exit.rb
@@ -23,7 +23,7 @@ class Trepan::Command::ExitCommand < Trepan::Command
# whether exit! or exit is used.
# This method runs the command
- def run(args) # :nodoc
+ def run(args)
unconditional =
if args.size > 1 && args[1] == 'unconditionally'
args.shift
View
6 processor/command/finish.rb
@@ -27,14 +27,16 @@ class Trepan::Command::FinishCommand < Trepan::Command
ALIASES = %w(fin)
CATEGORY = 'running'
# execution_set = ['Running']
- MAX_ARGS = 1 # Need at most this many.
+
+ # Need at most this many.
+ MAX_ARGS = 1
NAME = File.basename(__FILE__, '.rb')
NEED_STACK = true
SHORT_HELP = 'Step program without entering called functions'
end
# This method runs the command
- def run(args) # :nodoc
+ def run(args)
opts = {}
if args.size == 1
# Form is: "finish" which means "finish 1"
View
2  processor/command/help.rb
@@ -57,7 +57,7 @@ def list_categories
end
# This method runs the command
- def run(args) # :nodoc
+ def run(args)
if args.size > 1
cmd_name = args[1]
if cmd_name == '*'
View
2  processor/command/irb.rb
@@ -38,7 +38,7 @@ class Trepan::Command::IRBCommand < Trepan::Command
end
# This method runs the command
- def run(args) # :nodoc
+ def run(args)
add_debugging =
if args.size > 1
'-d' == args[1]
View
2  processor/command/kill.rb
@@ -19,7 +19,7 @@ class Trepan::Command::KillCommand < Trepan::Command
end
# This method runs the command
- def run(args) # :nodoc
+ def run(args)
if args.size > 1
sig = Integer(args[1]) rescue args[1]
unless sig.is_a?(Integer) || Signal.list.member?(sig)
View
2  processor/command/next.rb
@@ -46,7 +46,7 @@ class Trepan::Command::NextCommand < Trepan::Command
end
# This method runs the command
- def run(args) # :nodoc
+ def run(args)
opts = @proc.parse_next_step_suffix(args[0])
if args.size == 1
# Form is: "next" which means "next 1"
View
2  processor/command/nocache.rb
@@ -15,7 +15,7 @@ class Trepan::Command::NoCacheCommand < Trepan::Command
end
# This method runs the command
- def run(args) # :nodoc
+ def run(args)
if @proc.frame.iseq
puts @proc.frame.iseq.disassemble
count = @proc.frame.iseq.killcache
View
2  processor/command/quit.rb
@@ -31,7 +31,7 @@ class Trepan::Command::QuitCommand < Trepan::Command
# whether exit! or exit is used.
# This method runs the command
- def run(args) # :nodoc
+ def run(args)
unconditional =
if args.size > 1 && args[1] == 'unconditionally'
args.shift
View
2  processor/command/raise.rb
@@ -15,7 +15,7 @@ class Trepan::Command::RaiseCommand < Trepan::Command
end
# This method runs the command
- def run(args) # :nodoc
+ def run(args)
exception =
if args.size > 1
except_str = args[1..-1].join(' ')
View
2  processor/command/restart.rb
@@ -17,7 +17,7 @@ class Trepan::Command::RestartCommand < Trepan::Command
end
# This method runs the command
- def run(args) # :nodoc
+ def run(args)
dbgr = @proc.dbgr
argv = dbgr.restart_argv
View
2  processor/command/save.rb
@@ -14,7 +14,7 @@ class Trepan::Command::SaveCommand < Trepan::Command
end
# This method runs the command
- def run(args) # :nodoc
+ def run(args)
save_filename =
if args.size > 1
args[1]
View
50 processor/frame.rb
@@ -6,31 +6,35 @@ class Trepan
class CmdProcessor
attr_reader :current_thread
- attr_accessor :frame # ThreadFrame, current frame
- attr_accessor :frame_index # frame index in a "where" command
- attr_accessor :hide_level #
- attr_accessor :hidelevels # Hash[thread_id] -> FixNum, the
- # level of the last frame to
- # show. If we called the debugger
- # directly, then there is generally
- # a portion of a backtrace we don't
- # want to show. We don't need to
- # store this for all threads, just
- # those we want to hide frame on. A
- # value of 1 means to hide just the
- # oldest level. The default or
- # showing all levels is 0.
- attr_accessor :remap_container # Hash[container] -> file container
- # Gives us a way to map non-file
- # container objects to a file
- # container for display.
+
+ # ThreadFrame, current frame
+ attr_accessor :frame
+
+ # frame index in a "where" command
+ attr_accessor :frame_index
+ attr_accessor :hide_level
+
+ # Hash[thread_id] -> FixNum, the level of the last frame to
+ # show. If we called the debugger directly, then there is
+ # generally a portion of a backtrace we don't want to show. We
+ # don't need to store this for all threads, just those we want to
+ # hide frame on. A value of 1 means to hide just the oldest
+ # level. The default or showing all levels is 0.
+ attr_accessor :hidelevels
+
+ # Hash[container] -> file container Gives us a way to map non-file
+ # container objects to a file container for display.
attr_accessor :remap_iseq # Hash[iseq] -> file container
- attr_accessor :top_frame # top frame of current thread. Since
- # right now the ThreadFrame method has "prev"
- # but no way to move in the other direction.
- # So we store the top frame.
- attr_reader :threads2frames # Hash[thread_id] -> top_frame
+ attr_accessor :remap_container
+
+ # top frame of current thread. Since right now the ThreadFrame
+ # method has "prev" but no way to move in the other direction. So
+ # we store the top frame.
+ attr_accessor :top_frame
+
+ # Hash[thread_id] -> top_frame
+ attr_reader :threads2frames
def adjust_frame(frame_num, absolute_pos)
View
2  processor/main.rb
@@ -56,7 +56,7 @@ class CmdProcessor
unless defined?(EVENT2ICON)
- # We use event icons in printing locations.
+ # Event icons used in printing locations.
EVENT2ICON = {
'brkpt' => 'xx',
'c-call' => 'C>',
View
42 test/functional/test-fn_helper.rb
@@ -0,0 +1,42 @@
+#!/usr/bin/env ruby
+require 'test/unit'
+require_relative 'fn_helper'
+
+class TestFnTestHelper < Test::Unit::TestCase
+
+ include FnTestHelper
+
+ def test_basic
+ assert_equal(__LINE__, get_lineno, 'get_lineno()')
+ assert_equal(0,
+ '-- (/tmp/trepan/tmp/gcd.rb:4)' =~ TREPAN_LOC)
+ assert_equal(0, '(trepan): exit' =~ TREPAN_PROMPT)
+
+ output='
+-- (/tmp/trepan/tmp/gcd.rb:4)
+(trepan): s
+-- (/tmp/trepan/tmp/gcd.rb:18)
+(trepan): s
+-- (/tmp/trepan/tmp/gcd.rb:19)
+(trepan): s
+.. (/tmp/trepan/tmp/gcd.rb:0)
+(trepan): s
+-> (/tmp/trepan/tmp/gcd.rb:4)
+'.split(/\n/)
+ expect='
+-- (/tmp/trepan/tmp/gcd.rb:4)
+-- (/tmp/trepan/tmp/gcd.rb:18)
+-- (/tmp/trepan/tmp/gcd.rb:19)
+.. (/tmp/trepan/tmp/gcd.rb:0)
+-> (/tmp/trepan/tmp/gcd.rb:4)
+'.split(/\n/)
+ assert_equal(expect, filter_line_cmd(output))
+ end
+
+end
+
+
+
+
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.