rbx-trepanning 0.0.1-universal-rubinius
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.
- data/ChangeLog +376 -0
- data/LICENSE +25 -0
- data/NEWS +2 -0
- data/README.textile +28 -0
- data/Rakefile +165 -0
- data/THANKS +14 -0
- data/app/breakpoint.rb +218 -0
- data/app/breakpoint.rbc +3564 -0
- data/app/brkptmgr.rb +138 -0
- data/app/brkptmgr.rbc +2827 -0
- data/app/default.rb +61 -0
- data/app/default.rbc +1011 -0
- data/app/display.rb +35 -0
- data/app/display.rbc +968 -0
- data/app/frame.rb +98 -0
- data/app/frame.rbc +1808 -0
- data/app/irb.rb +112 -0
- data/app/irb.rbc +2111 -0
- data/app/iseq.rb +95 -0
- data/app/iseq.rbc +1801 -0
- data/app/method.rb +173 -0
- data/app/method.rbc +2492 -0
- data/app/mock.rb +13 -0
- data/app/mock.rbc +398 -0
- data/app/options.rb +123 -0
- data/app/options.rbc +2183 -0
- data/app/run.rb +86 -0
- data/app/run.rbc +1244 -0
- data/app/util.rb +49 -0
- data/app/util.rbc +1144 -0
- data/app/validate.rb +30 -0
- data/app/validate.rbc +676 -0
- data/bin/trepan.compiled.rbc +1043 -0
- data/bin/trepanx +63 -0
- data/bin/trepanx.compiled.rbc +985 -0
- data/interface/base_intf.rb +95 -0
- data/interface/base_intf.rbc +1742 -0
- data/interface/script.rb +104 -0
- data/interface/script.rbc +1642 -0
- data/interface/user.rb +91 -0
- data/interface/user.rbc +1418 -0
- data/io/base_io.rb +94 -0
- data/io/base_io.rbc +1404 -0
- data/io/input.rb +112 -0
- data/io/input.rbc +1979 -0
- data/io/null_output.rb +42 -0
- data/io/null_output.rbc +730 -0
- data/io/string_array.rb +156 -0
- data/io/string_array.rbc +2466 -0
- data/lib/trepanning.rb +398 -0
- data/lib/trepanning.rbc +6661 -0
- data/processor/breakpoint.rb +161 -0
- data/processor/command/alias.rb +55 -0
- data/processor/command/backtrace.rb +46 -0
- data/processor/command/base/cmd.rb +124 -0
- data/processor/command/base/subcmd.rb +213 -0
- data/processor/command/base/submgr.rb +179 -0
- data/processor/command/base/subsubcmd.rb +103 -0
- data/processor/command/base/subsubmgr.rb +184 -0
- data/processor/command/break.rb +100 -0
- data/processor/command/continue.rb +82 -0
- data/processor/command/delete.rb +30 -0
- data/processor/command/directory.rb +43 -0
- data/processor/command/disassemble.rb +103 -0
- data/processor/command/down.rb +54 -0
- data/processor/command/eval.rb +31 -0
- data/processor/command/exit.rb +58 -0
- data/processor/command/finish.rb +78 -0
- data/processor/command/frame.rb +89 -0
- data/processor/command/help.rb +146 -0
- data/processor/command/info.rb +28 -0
- data/processor/command/info_subcmd/breakpoints.rb +75 -0
- data/processor/command/info_subcmd/file.rb +153 -0
- data/processor/command/info_subcmd/method.rb +71 -0
- data/processor/command/info_subcmd/program.rb +59 -0
- data/processor/command/info_subcmd/variables.rb +40 -0
- data/processor/command/irb.rb +96 -0
- data/processor/command/kill.rb +70 -0
- data/processor/command/list.rb +296 -0
- data/processor/command/next.rb +66 -0
- data/processor/command/nexti.rb +59 -0
- data/processor/command/pr.rb +38 -0
- data/processor/command/ps.rb +40 -0
- data/processor/command/restart.rb +60 -0
- data/processor/command/set.rb +47 -0
- data/processor/command/set_subcmd/auto.rb +28 -0
- data/processor/command/set_subcmd/auto_subcmd/dis.rb +33 -0
- data/processor/command/set_subcmd/auto_subcmd/eval.rb +54 -0
- data/processor/command/set_subcmd/auto_subcmd/irb.rb +34 -0
- data/processor/command/set_subcmd/auto_subcmd/list.rb +34 -0
- data/processor/command/set_subcmd/basename.rb +26 -0
- data/processor/command/set_subcmd/debug.rb +27 -0
- data/processor/command/set_subcmd/debug_subcmd/dbgr.rb +36 -0
- data/processor/command/set_subcmd/debug_subcmd/skip.rb +23 -0
- data/processor/command/set_subcmd/debug_subcmd/step.rb +23 -0
- data/processor/command/set_subcmd/different.rb +60 -0
- data/processor/command/set_subcmd/hidelevel.rb +63 -0
- data/processor/command/set_subcmd/kernelstep.rb +61 -0
- data/processor/command/set_subcmd/max.rb +29 -0
- data/processor/command/set_subcmd/max_subcmd/list.rb +49 -0
- data/processor/command/set_subcmd/max_subcmd/stack.rb +50 -0
- data/processor/command/set_subcmd/max_subcmd/string.rb +54 -0
- data/processor/command/set_subcmd/max_subcmd/width.rb +49 -0
- data/processor/command/set_subcmd/substitute.rb +25 -0
- data/processor/command/set_subcmd/substitute_subcmd/path.rb +56 -0
- data/processor/command/set_subcmd/trace.rb +37 -0
- data/processor/command/set_subcmd/trace_subcmd/print.rb +57 -0
- data/processor/command/show.rb +27 -0
- data/processor/command/show_subcmd/alias.rb +43 -0
- data/processor/command/show_subcmd/args.rb +26 -0
- data/processor/command/show_subcmd/auto.rb +28 -0
- data/processor/command/show_subcmd/auto_subcmd/dis.rb +37 -0
- data/processor/command/show_subcmd/auto_subcmd/eval.rb +28 -0
- data/processor/command/show_subcmd/auto_subcmd/irb.rb +23 -0
- data/processor/command/show_subcmd/auto_subcmd/list.rb +22 -0
- data/processor/command/show_subcmd/basename.rb +22 -0
- data/processor/command/show_subcmd/debug.rb +27 -0
- data/processor/command/show_subcmd/debug_subcmd/dbgr.rb +21 -0
- data/processor/command/show_subcmd/debug_subcmd/skip.rb +22 -0
- data/processor/command/show_subcmd/debug_subcmd/step.rb +22 -0
- data/processor/command/show_subcmd/different.rb +27 -0
- data/processor/command/show_subcmd/hidelevel.rb +42 -0
- data/processor/command/show_subcmd/kernelstep.rb +37 -0
- data/processor/command/show_subcmd/max.rb +30 -0
- data/processor/command/show_subcmd/max_subcmd/list.rb +38 -0
- data/processor/command/show_subcmd/max_subcmd/stack.rb +36 -0
- data/processor/command/show_subcmd/max_subcmd/string.rb +42 -0
- data/processor/command/show_subcmd/max_subcmd/width.rb +37 -0
- data/processor/command/show_subcmd/trace.rb +29 -0
- data/processor/command/show_subcmd/trace_subcmd/print.rb +38 -0
- data/processor/command/source.rb +83 -0
- data/processor/command/step.rb +41 -0
- data/processor/command/tbreak.rb +19 -0
- data/processor/command/unalias.rb +44 -0
- data/processor/command/up.rb +87 -0
- data/processor/default.rb +56 -0
- data/processor/disassemble.rb +32 -0
- data/processor/eval.rb +96 -0
- data/processor/frame.rb +211 -0
- data/processor/help.rb +72 -0
- data/processor/hook.rb +133 -0
- data/processor/load_cmds.rb +101 -0
- data/processor/location.rb +128 -0
- data/processor/main.rb +394 -0
- data/processor/mock.rb +137 -0
- data/processor/msg.rb +28 -0
- data/processor/running.rb +230 -0
- data/processor/stepping.rb +115 -0
- data/processor/subcmd.rb +160 -0
- data/processor/validate.rb +355 -0
- data/test/data/enable.right +36 -0
- data/test/data/fname-with-blank.cmd +6 -0
- data/test/data/fname-with-blank.right +1 -0
- data/test/data/quit-Xdebug.right +3 -0
- data/test/data/quit.cmd +5 -0
- data/test/data/quit.right +0 -0
- data/test/example/fname with blank.rb +1 -0
- data/test/example/gcd-xx.rb +18 -0
- data/test/example/gcd.rb +19 -0
- data/test/example/gcd1.rb +24 -0
- data/test/example/null.rb +1 -0
- data/test/example/thread1.rb +3 -0
- data/test/functional/fn_helper.rb +112 -0
- data/test/functional/test-break-name.rb +52 -0
- data/test/functional/test-break.rb +51 -0
- data/test/functional/test-finish.rb +70 -0
- data/test/functional/test-fn_helper.rb +43 -0
- data/test/functional/test-list.rb +55 -0
- data/test/functional/test-next-bug.rb +49 -0
- data/test/functional/test-next.rb +101 -0
- data/test/functional/test-step.rb +272 -0
- data/test/functional/test-step2.rb +35 -0
- data/test/functional/test-tbreak.rb +41 -0
- data/test/integration/file-diff.rb +89 -0
- data/test/integration/helper.rb +78 -0
- data/test/integration/test-fname-with-blank.rb +12 -0
- data/test/integration/test-quit.rb +25 -0
- data/test/unit/cmd-helper.rb +46 -0
- data/test/unit/test-app-brkpt.rb +30 -0
- data/test/unit/test-app-brkptmgr.rb +51 -0
- data/test/unit/test-app-iseq.rb +49 -0
- data/test/unit/test-app-method.rb +54 -0
- data/test/unit/test-app-options.rb +61 -0
- data/test/unit/test-app-run.rb +16 -0
- data/test/unit/test-app-util.rb +28 -0
- data/test/unit/test-app-validate.rb +18 -0
- data/test/unit/test-base-subcmd.rb +61 -0
- data/test/unit/test-bin-trepanx.rb +48 -0
- data/test/unit/test-cmd-alias.rb +49 -0
- data/test/unit/test-cmd-break.rb +23 -0
- data/test/unit/test-cmd-exit.rb +27 -0
- data/test/unit/test-cmd-help.rb +101 -0
- data/test/unit/test-cmd-kill.rb +48 -0
- data/test/unit/test-intf-user.rb +46 -0
- data/test/unit/test-io-input.rb +27 -0
- data/test/unit/test-proc-eval.rb +37 -0
- data/test/unit/test-proc-frame.rb +79 -0
- data/test/unit/test-proc-help.rb +16 -0
- data/test/unit/test-proc-hook.rb +30 -0
- data/test/unit/test-proc-load_cmds.rb +41 -0
- data/test/unit/test-proc-location.rb +48 -0
- data/test/unit/test-proc-main.rb +96 -0
- data/test/unit/test-proc-validate.rb +91 -0
- data/test/unit/test-subcmd-help.rb +51 -0
- metadata +337 -0
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rbconfig'
|
4
|
+
load File.join(File.dirname(__FILE__), %w(.. .. bin trepanx))
|
5
|
+
|
6
|
+
# Test bin/trepan Module methods
|
7
|
+
class TestBinTrepan < Test::Unit::TestCase
|
8
|
+
|
9
|
+
include Trepanning
|
10
|
+
|
11
|
+
def test_ruby_path
|
12
|
+
rb_path = ruby_path
|
13
|
+
assert_equal(true, File.executable?(rb_path),
|
14
|
+
"#{rb_path} should be an executable Ruby interpreter")
|
15
|
+
|
16
|
+
# Let us test that we get *exactly* the same configuration as we
|
17
|
+
# have in this. I'm a ball buster.
|
18
|
+
cmd = "#{rb_path} -rrbconfig -e 'puts Marshal.dump(RbConfig::CONFIG)'"
|
19
|
+
rb_config = Marshal.load(`#{cmd}`)
|
20
|
+
assert_equal(RbConfig::CONFIG, rb_config,
|
21
|
+
"#{rb_path} config doesn't match got:
|
22
|
+
#{rb_config}
|
23
|
+
expected:
|
24
|
+
#{RbConfig::CONFIG}
|
25
|
+
")
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_whence_file
|
29
|
+
abs_path_me = File.expand_path(__FILE__)
|
30
|
+
assert_equal(abs_path_me, whence_file(abs_path_me),
|
31
|
+
"whence_file should have just returned #{abs_path_me}")
|
32
|
+
|
33
|
+
basename_me = File.basename(__FILE__)
|
34
|
+
dirname_me = File.dirname(__FILE__)
|
35
|
+
|
36
|
+
# Add my directory onto the beginning of PATH
|
37
|
+
path_dirs = ENV['PATH'].split(File::PATH_SEPARATOR)
|
38
|
+
path_dirs.unshift(dirname_me)
|
39
|
+
ENV['PATH'] = path_dirs.join(File::PATH_SEPARATOR)
|
40
|
+
|
41
|
+
assert_equal(File.join(dirname_me, basename_me),
|
42
|
+
whence_file(basename_me),
|
43
|
+
"whence_file should have found me")
|
44
|
+
# Restore old path
|
45
|
+
path_dirs.shift
|
46
|
+
ENV['PATH'] = path_dirs.join(File::PATH_SEPARATOR)
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'cmd-helper'
|
5
|
+
require_relative '../../processor/command/alias'
|
6
|
+
require_relative '../../processor/command/unalias'
|
7
|
+
|
8
|
+
# Test commands alias and unalias
|
9
|
+
class TestCommandAliasUnalias < Test::Unit::TestCase
|
10
|
+
|
11
|
+
include UnitHelper
|
12
|
+
def setup
|
13
|
+
common_setup
|
14
|
+
@name = File.basename(__FILE__, '.rb').split(/-/)[2]
|
15
|
+
end
|
16
|
+
|
17
|
+
def check_alias(should_not_have, cmd_name, *args)
|
18
|
+
@cmdproc.instance_variable_set('@msgs', [])
|
19
|
+
@cmdproc.instance_variable_set('@errmsgs', [])
|
20
|
+
arg_str = args.join(' ')
|
21
|
+
my_cmd = @cmds[cmd_name]
|
22
|
+
my_cmd.run([cmd_name] + args)
|
23
|
+
shoulda = should_not_have ? ['no ', ''] : ['', 'no ']
|
24
|
+
msgs = @cmdproc.instance_variable_get('@msgs')
|
25
|
+
errmsgs = @cmdproc.instance_variable_get('@errmsgs')
|
26
|
+
assert_equal(should_not_have, msgs.empty?,
|
27
|
+
"Expecting %s%s for #{arg_str}.\n Got #{msgs}" %
|
28
|
+
[shoulda[0], cmd_name])
|
29
|
+
assert_equal(!should_not_have, errmsgs.empty?,
|
30
|
+
"Expecting %serror for #{arg_str}.\n Got #{errmsgs}" %
|
31
|
+
shoulda[1])
|
32
|
+
end
|
33
|
+
|
34
|
+
def alias_defined?(alias_name)
|
35
|
+
@cmdproc.aliases.member?(alias_name)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_alias_command
|
39
|
+
|
40
|
+
assert_equal(false, @cmdproc.aliases.empty?,
|
41
|
+
'There should be some aliases defined')
|
42
|
+
|
43
|
+
assert_equal(false, alias_defined?('ki'))
|
44
|
+
check_alias(false, 'alias', 'ki', 'kill')
|
45
|
+
assert_equal(true, alias_defined?('ki'))
|
46
|
+
check_alias(false, 'unalias', 'ki')
|
47
|
+
assert_equal(false, alias_defined?('ki'))
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'cmd-helper'
|
5
|
+
|
6
|
+
class TestCommandBreak < Test::Unit::TestCase
|
7
|
+
|
8
|
+
include UnitHelper
|
9
|
+
def setup
|
10
|
+
common_setup
|
11
|
+
@cmdproc.frame_setup
|
12
|
+
@name = File.basename(__FILE__, '.rb').split(/-/)[2]
|
13
|
+
@my_cmd = @cmds[@name]
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_basic
|
17
|
+
place = "#{self.class}#test_basic:#{__LINE__}"
|
18
|
+
@my_cmd.run([@name, place])
|
19
|
+
assert_equal(true, @cmdproc.errmsgs.empty?,
|
20
|
+
@cmdproc.errmsgs)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../../processor/mock'
|
5
|
+
require_relative '../../processor/command/exit'
|
6
|
+
|
7
|
+
class TestCommandExit < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@name = File.basename(__FILE__, '.rb').split(/-/)[2]
|
11
|
+
@dbg, @cmd = MockDebugger::setup(@name, false)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_basic
|
15
|
+
pid = fork { @cmd.run([@name, '10']) }
|
16
|
+
Process.wait
|
17
|
+
assert_equal(10, $?.exitstatus)
|
18
|
+
pid = fork { @cmd.run([@name]) }
|
19
|
+
Process.wait
|
20
|
+
assert_equal(0, $?.exitstatus)
|
21
|
+
# FIXME: should test that finalization routines get run;
|
22
|
+
# should test 'confirm' gets run; and should test that
|
23
|
+
# 'unconditional' is handled correctly.
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'cmd-helper'
|
5
|
+
require_relative '../../processor/command/help'
|
6
|
+
|
7
|
+
class TestCommandHelp < Test::Unit::TestCase
|
8
|
+
|
9
|
+
include UnitHelper
|
10
|
+
def setup
|
11
|
+
common_setup
|
12
|
+
@name = File.basename(__FILE__, '.rb').split(/-/)[2]
|
13
|
+
@my_cmd = @cmds[@name]
|
14
|
+
end
|
15
|
+
|
16
|
+
def check_help(should_not_have, *args)
|
17
|
+
@cmdproc.instance_variable_set('@msgs', [])
|
18
|
+
@cmdproc.instance_variable_set('@errmsgs', [])
|
19
|
+
arg_str = args.join(' ')
|
20
|
+
@my_cmd.run([@name] + args)
|
21
|
+
shoulda = should_not_have ? ['no ', ''] : ['', 'no ']
|
22
|
+
msgs = @cmdproc.instance_variable_get('@msgs')
|
23
|
+
errmsgs = @cmdproc.instance_variable_get('@errmsgs')
|
24
|
+
assert_equal(should_not_have, msgs.empty?,
|
25
|
+
"Expecting %shelp for %s.\n Got %s" %
|
26
|
+
[shoulda[0], arg_str, msgs])
|
27
|
+
assert_equal(!should_not_have, errmsgs.empty?,
|
28
|
+
"Expecting %serror for %s.\n Got %s" %
|
29
|
+
[shoulda[1], arg_str, msgs])
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_help_command
|
33
|
+
|
34
|
+
# Test we can run 'help *cmd* for each command
|
35
|
+
@cmds.keys.each do |cmd_name|
|
36
|
+
check_help(false, cmd_name)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Test we can run 'help *alias* for each alias
|
40
|
+
@cmdproc.aliases.keys.each do |alias_name|
|
41
|
+
check_help(false, alias_name)
|
42
|
+
end
|
43
|
+
|
44
|
+
# double-check specific commands and aliases
|
45
|
+
%w(kill n help).each do |cmd_pat|
|
46
|
+
check_help(false, cmd_pat)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Test patterns
|
50
|
+
%w(* k.* ki).each do |cmd_pat|
|
51
|
+
check_help(false, cmd_pat)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Test categories
|
55
|
+
%w(running stack).each do |cmd_pat|
|
56
|
+
check_help(false, cmd_pat)
|
57
|
+
end
|
58
|
+
|
59
|
+
# # Test sub help and subhelp patterns
|
60
|
+
# [%w(info file), %w(show *)].each do |args|
|
61
|
+
# check_help(false, args)
|
62
|
+
# end
|
63
|
+
|
64
|
+
# Test invalid commands
|
65
|
+
%w(bogus abcd.*).each do |cmd_pat|
|
66
|
+
check_help(true, cmd_pat)
|
67
|
+
end
|
68
|
+
|
69
|
+
# invalid help subcommands
|
70
|
+
[%w(info fdafds), %w(fedafdsa *)].each do |args|
|
71
|
+
check_help(true, *args)
|
72
|
+
end
|
73
|
+
|
74
|
+
# screwball error
|
75
|
+
check_help(true, '["info",')
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
# FIXME: Do better than this.
|
80
|
+
def check_subcmd_help(cmd_name, subcmd, *args)
|
81
|
+
def subcmd.msg(mess)
|
82
|
+
@msgs << mess
|
83
|
+
end
|
84
|
+
subcmd.instance_variable_set('@msgs', [])
|
85
|
+
subcmd.instance_variable_set('@errmsgs', [])
|
86
|
+
subcmd.help(cmd_name)
|
87
|
+
assert subcmd.instance_variable_get('@msgs')
|
88
|
+
# subcmd.help
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_help_subcommand
|
92
|
+
# Get list of commands with subcmds
|
93
|
+
cmd_names = @cmds.values.map do |c|
|
94
|
+
c.instance_variable_defined?(:@subcmds) ? c.name : nil
|
95
|
+
end.compact
|
96
|
+
cmd_names.each do |cmd_name|
|
97
|
+
check_subcmd_help(cmd_name, @cmds[cmd_name].subcmds)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../../processor/mock'
|
5
|
+
require_relative '../../processor/command/kill'
|
6
|
+
|
7
|
+
class TestCommandKill < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@name = File.basename(__FILE__, '.rb').split(/-/)[2]
|
11
|
+
@dbg, @cmd = MockDebugger::setup(@name, false)
|
12
|
+
def @cmd.msg(message)
|
13
|
+
@msgs << message
|
14
|
+
end
|
15
|
+
def @cmd.errmsg(message)
|
16
|
+
@errmsgs << message
|
17
|
+
end
|
18
|
+
reset_cmdproc_vars
|
19
|
+
end
|
20
|
+
|
21
|
+
def reset_cmdproc_vars
|
22
|
+
@cmd.instance_variable_set('@msgs', [])
|
23
|
+
@cmd.instance_variable_set('@errmsgs', [])
|
24
|
+
@cmd.proc.leave_cmd_loop = false
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_kill_command
|
28
|
+
@cmd.run([@name, 'foo'])
|
29
|
+
assert_equal(false, @cmd.proc.leave_cmd_loop)
|
30
|
+
assert_equal(1, @cmd.instance_variable_get('@errmsgs').size)
|
31
|
+
|
32
|
+
if false
|
33
|
+
save_trap = Signal.trap(10) {
|
34
|
+
@success = true
|
35
|
+
}
|
36
|
+
|
37
|
+
@success = false
|
38
|
+
@cmd.run([@name, '10'])
|
39
|
+
# assert_equal(true, @success,
|
40
|
+
# 'Should have run the handler')
|
41
|
+
end
|
42
|
+
|
43
|
+
ensure
|
44
|
+
# restore old trap if any
|
45
|
+
trap(10, save_trap)
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Unit test for rbdbgr.interface.user
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
require 'rubygems'; require 'require_relative'
|
6
|
+
require_relative '../../interface/user'
|
7
|
+
|
8
|
+
# Tests Trepan::UserInterface
|
9
|
+
class TestInterfaceUser < Test::Unit::TestCase
|
10
|
+
|
11
|
+
# Test UserInterface.confirm()
|
12
|
+
def test_confirm
|
13
|
+
|
14
|
+
user_intf = Trepan::UserInterface.new
|
15
|
+
def user_intf.readline(prompt)
|
16
|
+
$response_answer
|
17
|
+
end
|
18
|
+
|
19
|
+
['y', 'Y', 'Yes', ' YES '].each do |s|
|
20
|
+
$response_answer = s
|
21
|
+
ans = user_intf.confirm('Testing', true)
|
22
|
+
assert_equal(true, ans)
|
23
|
+
end
|
24
|
+
|
25
|
+
['n', 'N', 'No', ' NO '].each do |s|
|
26
|
+
$response_answer = s
|
27
|
+
ans = user_intf.confirm('Testing', true)
|
28
|
+
assert_equal(false, ans)
|
29
|
+
end
|
30
|
+
|
31
|
+
def user_intf.readline(prompt)
|
32
|
+
raise EOFError
|
33
|
+
end
|
34
|
+
|
35
|
+
[true, false].each do |tf|
|
36
|
+
assert_equal(tf, user_intf.confirm('default testing', tf))
|
37
|
+
end
|
38
|
+
|
39
|
+
# Ok, we'll throw in one test of EOFError
|
40
|
+
assert_raises EOFError do
|
41
|
+
user_intf.readline('')
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
# FIXME: more thorough testing of other routines in user.
|
46
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../../io/input'
|
5
|
+
|
6
|
+
# Test Trepan::UserInput
|
7
|
+
class TestIOInput < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def test_UserInput
|
10
|
+
inp = Trepan::UserInput.open(__FILE__)
|
11
|
+
assert inp, 'Should have gotten a Trepan::UserInput object back'
|
12
|
+
line = inp.readline.chomp
|
13
|
+
assert_equal '#!/usr/bin/env ruby', line
|
14
|
+
assert_equal false, inp.eof?
|
15
|
+
inp.close
|
16
|
+
assert_equal true, inp.closed?
|
17
|
+
inp = Trepan::UserInput.open(__FILE__)
|
18
|
+
while not inp.eof?
|
19
|
+
begin
|
20
|
+
inp.readline
|
21
|
+
rescue EOFError
|
22
|
+
assert_equal(true, inp.eof?,
|
23
|
+
'EOF should be true after EOFError')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'cmd-helper'
|
5
|
+
require_relative '../../processor/main' # Have to include before frame!
|
6
|
+
# FIXME
|
7
|
+
require_relative '../../app/frame'
|
8
|
+
require_relative '../../processor/eval'
|
9
|
+
require_relative '../../processor/mock'
|
10
|
+
|
11
|
+
# Test Trepan::CmdProcessor Eval portion
|
12
|
+
class TestProcEval < Test::Unit::TestCase
|
13
|
+
|
14
|
+
include UnitHelper
|
15
|
+
def test_basic
|
16
|
+
common_setup
|
17
|
+
@dbgr = Trepan.new
|
18
|
+
@cmdproc = Trepan::CmdProcessor.new(@dbgrr)
|
19
|
+
assert_equal('(eval "x = 1; y = 2")',
|
20
|
+
|
21
|
+
@cmdproc.fake_eval_filename('x = 1; y = 2'))
|
22
|
+
assert_equal('(eval "x = 1;"...)',
|
23
|
+
@cmdproc.fake_eval_filename('x = 1; y = 2', 7))
|
24
|
+
|
25
|
+
@cmdproc.instance_variable_set('@settings', {:stack_trace_on_error => true})
|
26
|
+
# x = 1
|
27
|
+
# vm_locations = Rubinius::VM.backtrace(0, true)
|
28
|
+
# @dbgr.instance_variable_set('@vm_locations', vm_locations)
|
29
|
+
# @cmdproc.instance_variable_set('@current_frame',
|
30
|
+
# Trepan::Frame.new(self, 0, vm_locations[0]))
|
31
|
+
# @cmdproc.instance_variable_set('@settings', {:stack_trace_on_error => true})
|
32
|
+
# assert_equal('1', @cmdproc.debug_eval('x = "#{x}"'))
|
33
|
+
# x = 2
|
34
|
+
# assert_equal('2', @cmdproc.debug_eval_no_errmsg('x = "#{x}"'))
|
35
|
+
# assert_equal(nil, @cmdproc.debug_eval_no_errmsg('x+'))
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../../processor/main' # Have to include before frame!
|
5
|
+
# FIXME
|
6
|
+
require_relative '../../processor/frame'
|
7
|
+
require_relative '../../processor/mock'
|
8
|
+
|
9
|
+
$errors = []
|
10
|
+
$msgs = []
|
11
|
+
|
12
|
+
# Test Trepan::CmdProcessor Frame portion
|
13
|
+
class TestCmdProcessorFrame < Test::Unit::TestCase
|
14
|
+
|
15
|
+
def setup
|
16
|
+
$errors = []
|
17
|
+
$msgs = []
|
18
|
+
@dbgr = MockDebugger::MockDebugger.new
|
19
|
+
@proc = Trepan::CmdProcessor.new(@dbgr)
|
20
|
+
@proc.frame_index = 0
|
21
|
+
@proc.frame_initialize
|
22
|
+
class << @proc
|
23
|
+
def errmsg(msg)
|
24
|
+
$errors << msg
|
25
|
+
end
|
26
|
+
def print_location
|
27
|
+
# $msgs << "#{@frame.source_container} #{@frame.source_location[0]}"
|
28
|
+
$msgs << File.basename(@frame.file)
|
29
|
+
# puts $msgs
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# See that we have can load up commands
|
35
|
+
def test_basic
|
36
|
+
@proc.frame_setup
|
37
|
+
|
38
|
+
# Test absolute positioning. Should all be okay
|
39
|
+
0.upto(@proc.stack_size-1) do |i|
|
40
|
+
@proc.adjust_frame(i, true)
|
41
|
+
assert_equal(0, $errors.size)
|
42
|
+
assert_equal(i+1, $msgs.size)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Test absolute before the beginning fo the stack
|
46
|
+
frame_index = @proc.frame_index
|
47
|
+
@proc.adjust_frame(-1, true)
|
48
|
+
assert_equal(0, $errors.size)
|
49
|
+
assert_equal(frame_index, @proc.frame_index)
|
50
|
+
@proc.adjust_frame(-@proc.stack_size-1, true)
|
51
|
+
assert_equal(1, $errors.size, $errors)
|
52
|
+
assert_equal(frame_index, @proc.frame_index)
|
53
|
+
|
54
|
+
## FIXME: look over and reinstate this code...
|
55
|
+
# setup
|
56
|
+
# @proc.top_frame = @proc.frame = @dbgr.vm_locations[0]
|
57
|
+
# @proc.adjust_frame(0, true)
|
58
|
+
|
59
|
+
# @dbgr.vm_locations.size-1.times do
|
60
|
+
# frame_index = @proc.frame_index
|
61
|
+
# @proc.adjust_frame(1, false)
|
62
|
+
# assert_equal(0, $errors.size)
|
63
|
+
# assert_not_equal(frame_index, @proc.frame_index,
|
64
|
+
# '@proc.frame_index should have moved')
|
65
|
+
# end
|
66
|
+
|
67
|
+
# FIXME: bug in threadframe top_frame.stack_size?
|
68
|
+
# # Adjust relative beyond the end
|
69
|
+
# @proc.adjust_frame(1, false)
|
70
|
+
# assert_equal(1, $errors.size)
|
71
|
+
|
72
|
+
# Should have stayed at the end
|
73
|
+
# proc.adjust_frame(proc.top_frame.stack_size-1, true)
|
74
|
+
# proc.top_frame.stack_size.times { proc.adjust_frame(-1, false) }
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../../processor/help'
|
5
|
+
|
6
|
+
# Test Trepan::CmdProcessor
|
7
|
+
class TestCmdProcessor < Test::Unit::TestCase
|
8
|
+
|
9
|
+
include Trepan::Help
|
10
|
+
# See that we have can load up commands
|
11
|
+
def test_abbrev_stringify
|
12
|
+
assert_equal('(test)ing',
|
13
|
+
abbrev_stringify('testing', 'test'.size))
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../../processor/hook'
|
5
|
+
|
6
|
+
# Test Debugger:CmdProcessor Hook portion
|
7
|
+
class TestProcHook < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def test_basic
|
10
|
+
@args = []
|
11
|
+
hook1 = Proc.new {|name, a| @args << [name, a]}
|
12
|
+
hooks = Trepan::CmdProcessor::Hook.new()
|
13
|
+
assert_equal(true, hooks.empty?)
|
14
|
+
hooks.insert(-1, 'hook1', hook1)
|
15
|
+
hooks.run
|
16
|
+
assert_equal([['hook1', nil]], @args)
|
17
|
+
hooks.insert_if_new(-1, 'hook1', hook1)
|
18
|
+
assert_equal([['hook1', nil]], @args)
|
19
|
+
|
20
|
+
@args = []
|
21
|
+
hooks.insert_if_new(-1, 'hook2', hook1)
|
22
|
+
hooks.run(10)
|
23
|
+
assert_equal([['hook1', 10], ['hook2', 10]], @args)
|
24
|
+
|
25
|
+
@args = []
|
26
|
+
hooks.delete_by_name('hook2')
|
27
|
+
hooks.run(30)
|
28
|
+
assert_equal([['hook1', 30]], @args)
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../../processor/main'
|
5
|
+
require_relative '../../app/mock'
|
6
|
+
|
7
|
+
class TestCmdProcessorLoadCmds < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@proc = Trepan::CmdProcessor.new(Trepan::MockCore.new())
|
11
|
+
@proc.instance_variable_set('@settings', {})
|
12
|
+
end
|
13
|
+
|
14
|
+
# See that we have can load up commands
|
15
|
+
def test_basic
|
16
|
+
@proc.load_cmds_initialize
|
17
|
+
assert_equal(false, @proc.commands.empty?)
|
18
|
+
assert_equal(false, @proc.aliases.empty?)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_run_cmd
|
22
|
+
$errors = []
|
23
|
+
|
24
|
+
def @proc.errmsg(mess)
|
25
|
+
$errors << mess
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_it(size, *args)
|
29
|
+
@proc.run_cmd(*args)
|
30
|
+
assert_equal(size, $errors.size, $errors)
|
31
|
+
end
|
32
|
+
test_it(1, 'foo')
|
33
|
+
test_it(2, [])
|
34
|
+
test_it(3, ['list', 5])
|
35
|
+
# See that we got different error messages
|
36
|
+
assert_not_equal($errors[0], $errors[1], $errors)
|
37
|
+
assert_not_equal($errors[1], $errors[2], $errors)
|
38
|
+
assert_not_equal($errors[2], $errors[0], $errors)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require 'linecache'
|
5
|
+
require_relative '../../processor/main' # Have to include before frame!
|
6
|
+
# FIXME
|
7
|
+
require_relative '../../processor/location'
|
8
|
+
require_relative '../../processor/mock'
|
9
|
+
|
10
|
+
$errors = []
|
11
|
+
$msgs = []
|
12
|
+
|
13
|
+
# Test Trepan::CmdProcessor location portion
|
14
|
+
class TestCmdProcessorLocation < Test::Unit::TestCase
|
15
|
+
|
16
|
+
def setup
|
17
|
+
$errors = []
|
18
|
+
$msgs = []
|
19
|
+
@dbgr = MockDebugger::MockDebugger.new
|
20
|
+
@proc = Trepan::CmdProcessor.new(@dbgr)
|
21
|
+
@file = File.basename(__FILE__)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Test resolve_file_with_dir() and line_at()
|
25
|
+
def test_line_at
|
26
|
+
@proc.settings[:directory] = ''
|
27
|
+
assert_equal(nil, @proc.resolve_file_with_dir(@file))
|
28
|
+
assert_equal(nil, @proc.line_at(@file, __LINE__))
|
29
|
+
dir = @proc.settings[:directory] = File.dirname(__FILE__)
|
30
|
+
assert_equal(File.join(dir, @file),
|
31
|
+
@proc.resolve_file_with_dir('test-proc-location.rb'))
|
32
|
+
test_line = 'test_line'
|
33
|
+
line = @proc.line_at(@file, __LINE__-1)
|
34
|
+
assert_match(/#{line}/, line)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_loc_and_text
|
38
|
+
@proc.frame_index = 0
|
39
|
+
@proc.frame_initialize
|
40
|
+
@proc.frame_setup
|
41
|
+
LineCache::clear_file_cache
|
42
|
+
dir = @proc.settings[:directory] = File.dirname(__FILE__)
|
43
|
+
loc, line_no, text = @proc.loc_and_text('hi')
|
44
|
+
assert loc and line_no.is_a?(Fixnum) and text
|
45
|
+
# FIXME test that filename remapping works.
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|