rbx-trepanning 0.2.0-universal-rubinius-2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/ChangeLog +2967 -0
- data/LICENSE +25 -0
- data/Makefile +13 -0
- data/NEWS +105 -0
- data/README.textile +34 -0
- data/Rakefile +244 -0
- data/THANKS +14 -0
- data/app/.gitignore +2 -0
- data/app/breakpoint.rb +242 -0
- data/app/brkptmgr.rb +153 -0
- data/app/client.rb +71 -0
- data/app/cmd_parse.kpeg +242 -0
- data/app/cmd_parse.rb +209 -0
- data/app/cmd_parser.rb +2083 -0
- data/app/complete.rb +79 -0
- data/app/condition.rb +22 -0
- data/app/default.rb +71 -0
- data/app/display.rb +186 -0
- data/app/eventbuffer.rb +147 -0
- data/app/file.rb +24 -0
- data/app/frame.rb +120 -0
- data/app/irb.rb +113 -0
- data/app/iseq.rb +188 -0
- data/app/method.rb +178 -0
- data/app/mock.rb +13 -0
- data/app/options.rb +154 -0
- data/app/rbx-llvm.rb +163 -0
- data/app/run.rb +92 -0
- data/app/util.rb +99 -0
- data/app/validate.rb +30 -0
- data/bin/.gitignore +2 -0
- data/bin/trepanx +69 -0
- data/data/.gitignore +2 -0
- data/data/irbrc +41 -0
- data/interface/.gitignore +2 -0
- data/interface/client.rb +84 -0
- data/interface/comcodes.rb +20 -0
- data/interface/script.rb +112 -0
- data/interface/server.rb +147 -0
- data/interface/user.rb +158 -0
- data/interface.rb +109 -0
- data/io/.gitignore +3 -0
- data/io/input.rb +151 -0
- data/io/null_output.rb +46 -0
- data/io/string_array.rb +155 -0
- data/io/tcpclient.rb +129 -0
- data/io/tcpfns.rb +33 -0
- data/io/tcpserver.rb +141 -0
- data/io.rb +148 -0
- data/lib/.gitignore +2 -0
- data/lib/trepanning.rb +467 -0
- data/processor/.gitignore +3 -0
- data/processor/Makefile +7 -0
- data/processor/breakpoint.rb +167 -0
- data/processor/command/.gitignore +2 -0
- data/processor/command/alias.rb +65 -0
- data/processor/command/backtrace.rb +68 -0
- data/processor/command/base/.gitignore +2 -0
- data/processor/command/base/subcmd.rb +226 -0
- data/processor/command/base/submgr.rb +185 -0
- data/processor/command/base/subsubcmd.rb +125 -0
- data/processor/command/base/subsubmgr.rb +196 -0
- data/processor/command/break.rb +78 -0
- data/processor/command/complete.rb +39 -0
- data/processor/command/condition.rb +64 -0
- data/processor/command/continue.rb +61 -0
- data/processor/command/delete.rb +44 -0
- data/processor/command/directory.rb +51 -0
- data/processor/command/disable.rb +71 -0
- data/processor/command/disassemble.rb +180 -0
- data/processor/command/display.rb +84 -0
- data/processor/command/down.rb +54 -0
- data/processor/command/edit.rb +74 -0
- data/processor/command/enable.rb +43 -0
- data/processor/command/eval.rb +93 -0
- data/processor/command/exit.rb +83 -0
- data/processor/command/finish.rb +80 -0
- data/processor/command/frame.rb +93 -0
- data/processor/command/help/.gitignore +1 -0
- data/processor/command/help/README +10 -0
- data/processor/command/help/command.txt +58 -0
- data/processor/command/help/examples.txt +16 -0
- data/processor/command/help/filename.txt +40 -0
- data/processor/command/help/location.txt +37 -0
- data/processor/command/help/suffixes.txt +17 -0
- data/processor/command/help.rb +228 -0
- data/processor/command/info.rb +30 -0
- data/processor/command/info_subcmd/.gitignore +3 -0
- data/processor/command/info_subcmd/breakpoints.rb +103 -0
- data/processor/command/info_subcmd/files.rb +219 -0
- data/processor/command/info_subcmd/frame.rb +68 -0
- data/processor/command/info_subcmd/line.rb +75 -0
- data/processor/command/info_subcmd/locals.rb +22 -0
- data/processor/command/info_subcmd/macro.rb +62 -0
- data/processor/command/info_subcmd/method.rb +71 -0
- data/processor/command/info_subcmd/program.rb +51 -0
- data/processor/command/info_subcmd/ruby.rb +64 -0
- data/processor/command/info_subcmd/source.rb +75 -0
- data/processor/command/info_subcmd/stack.rb +25 -0
- data/processor/command/info_subcmd/variables.rb +35 -0
- data/processor/command/info_subcmd/variables_subcmd/.gitignore +2 -0
- data/processor/command/info_subcmd/variables_subcmd/class.rb +42 -0
- data/processor/command/info_subcmd/variables_subcmd/constant.rb +42 -0
- data/processor/command/info_subcmd/variables_subcmd/globals.rb +69 -0
- data/processor/command/info_subcmd/variables_subcmd/instance.rb +42 -0
- data/processor/command/info_subcmd/variables_subcmd/locals.rb +80 -0
- data/processor/command/kill.rb +79 -0
- data/processor/command/list.rb +234 -0
- data/processor/command/macro.rb +86 -0
- data/processor/command/next.rb +67 -0
- data/processor/command/nexti.rb +59 -0
- data/processor/command/parsetree.rb +51 -0
- data/processor/command/pr.rb +37 -0
- data/processor/command/ps.rb +40 -0
- data/processor/command/restart.rb +60 -0
- data/processor/command/save.rb +58 -0
- data/processor/command/server.rb +72 -0
- data/processor/command/set.rb +47 -0
- data/processor/command/set_subcmd/.gitignore +2 -0
- data/processor/command/set_subcmd/abbrev.rb +25 -0
- data/processor/command/set_subcmd/auto.rb +33 -0
- data/processor/command/set_subcmd/auto_subcmd/.gitignore +2 -0
- data/processor/command/set_subcmd/auto_subcmd/dis.rb +33 -0
- data/processor/command/set_subcmd/auto_subcmd/eval.rb +53 -0
- data/processor/command/set_subcmd/auto_subcmd/irb.rb +33 -0
- data/processor/command/set_subcmd/auto_subcmd/list.rb +33 -0
- data/processor/command/set_subcmd/basename.rb +25 -0
- data/processor/command/set_subcmd/confirm.rb +24 -0
- data/processor/command/set_subcmd/debug.rb +26 -0
- data/processor/command/set_subcmd/debug_subcmd/.gitignore +2 -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 +61 -0
- data/processor/command/set_subcmd/hidelevel.rb +62 -0
- data/processor/command/set_subcmd/highlight.rb +39 -0
- data/processor/command/set_subcmd/kernelstep.rb +60 -0
- data/processor/command/set_subcmd/max.rb +26 -0
- data/processor/command/set_subcmd/max_subcmd/.gitignore +2 -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 +76 -0
- data/processor/command/set_subcmd/max_subcmd/width.rb +49 -0
- data/processor/command/set_subcmd/reload.rb +42 -0
- data/processor/command/set_subcmd/substitute.rb +24 -0
- data/processor/command/set_subcmd/substitute_subcmd/.gitignore +3 -0
- data/processor/command/set_subcmd/substitute_subcmd/path.rb +56 -0
- data/processor/command/set_subcmd/timer.rb +58 -0
- data/processor/command/set_subcmd/trace.rb +37 -0
- data/processor/command/set_subcmd/trace_subcmd/.gitignore +2 -0
- data/processor/command/set_subcmd/trace_subcmd/buffer.rb +42 -0
- data/processor/command/set_subcmd/trace_subcmd/print.rb +41 -0
- data/processor/command/shell.rb +131 -0
- data/processor/command/show.rb +39 -0
- data/processor/command/show_subcmd/.gitignore +3 -0
- data/processor/command/show_subcmd/abbrev.rb +20 -0
- data/processor/command/show_subcmd/aliases.rb +46 -0
- data/processor/command/show_subcmd/args.rb +25 -0
- data/processor/command/show_subcmd/auto.rb +28 -0
- data/processor/command/show_subcmd/auto_subcmd/.gitignore +3 -0
- data/processor/command/show_subcmd/auto_subcmd/dis.rb +37 -0
- data/processor/command/show_subcmd/auto_subcmd/eval.rb +24 -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 +20 -0
- data/processor/command/show_subcmd/confirm.rb +18 -0
- data/processor/command/show_subcmd/debug.rb +26 -0
- data/processor/command/show_subcmd/debug_subcmd/.gitignore +3 -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 +26 -0
- data/processor/command/show_subcmd/directories.rb +22 -0
- data/processor/command/show_subcmd/hidelevel.rb +41 -0
- data/processor/command/show_subcmd/highlight.rb +25 -0
- data/processor/command/show_subcmd/kernelstep.rb +34 -0
- data/processor/command/show_subcmd/max.rb +27 -0
- data/processor/command/show_subcmd/max_subcmd/.gitignore +2 -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/reload.rb +18 -0
- data/processor/command/show_subcmd/timer.rb +18 -0
- data/processor/command/show_subcmd/trace.rb +27 -0
- data/processor/command/show_subcmd/trace_subcmd/.gitignore +2 -0
- data/processor/command/show_subcmd/trace_subcmd/buffer.rb +64 -0
- data/processor/command/show_subcmd/trace_subcmd/print.rb +23 -0
- data/processor/command/show_subcmd/version.rb +23 -0
- data/processor/command/source.rb +133 -0
- data/processor/command/step.rb +97 -0
- data/processor/command/tbreak.rb +20 -0
- data/processor/command/unalias.rb +49 -0
- data/processor/command/undisplay.rb +63 -0
- data/processor/command/up.rb +89 -0
- data/processor/command.rb +173 -0
- data/processor/default.rb +64 -0
- data/processor/disassemble.rb +59 -0
- data/processor/display.rb +53 -0
- data/processor/eval.rb +97 -0
- data/processor/eventbuf.rb +101 -0
- data/processor/frame.rb +265 -0
- data/processor/help.rb +94 -0
- data/processor/hook.rb +134 -0
- data/processor/list.rb +123 -0
- data/processor/load_cmds.rb +253 -0
- data/processor/location.rb +228 -0
- data/processor/mock.rb +138 -0
- data/processor/msg.rb +74 -0
- data/processor/running.rb +244 -0
- data/processor/stepping.rb +135 -0
- data/processor/subcmd.rb +136 -0
- data/processor/validate.rb +379 -0
- data/processor/virtual.rb +33 -0
- data/processor.rb +404 -0
- data/rbx-trepanning.gemspec +39 -0
- data/sample/.gitignore +2 -0
- data/sample/list-terminal-colors.rb +139 -0
- data/sample/rocky-dot-trepanxrc +14 -0
- data/sample/rocky-trepanx-colors.rb +46 -0
- data/test/data/.gitignore +1 -0
- data/test/data/enable.right +36 -0
- data/test/data/fname-with-blank.cmd +6 -0
- data/test/data/fname-with-blank.right +6 -0
- data/test/data/inline-call.cmd +6 -0
- data/test/data/inline-call.right +14 -0
- data/test/data/quit-Xdebug.right +3 -0
- data/test/data/quit.cmd +5 -0
- data/test/data/quit.right +3 -0
- data/test/data/quit2.cmd +6 -0
- data/test/data/quit2.right +3 -0
- data/test/example/.gitignore +2 -0
- data/test/example/debugger-stop.rb +16 -0
- data/test/example/factorial.rb +10 -0
- data/test/example/fname with blank.rb +1 -0
- data/test/example/gcd-server.rb +22 -0
- data/test/example/gcd.rb +19 -0
- data/test/example/goto2goto.rb +11 -0
- data/test/example/inline-call.rb +23 -0
- data/test/example/null.rb +1 -0
- data/test/example/thread1.rb +3 -0
- data/test/functional/.gitignore +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 +85 -0
- data/test/functional/test-eval.rb +115 -0
- data/test/functional/test-finish.rb +70 -0
- data/test/functional/test-fn_helper.rb +43 -0
- data/test/functional/test-list.rb +56 -0
- data/test/functional/test-next-bug.rb +49 -0
- data/test/functional/test-next.rb +101 -0
- data/test/functional/test-recursive-bt.rb +94 -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/.gitignore +3 -0
- data/test/integration/file-diff.rb +89 -0
- data/test/integration/helper.rb +81 -0
- data/test/integration/test-fname-with-blank.rb +16 -0
- data/test/integration/test-inline-call.rb +20 -0
- data/test/integration/test-quit.rb +47 -0
- data/test/unit/.gitignore +3 -0
- data/test/unit/cmd-helper.rb +50 -0
- data/test/unit/mock-helper.rb +10 -0
- data/test/unit/test-app-brkpt.rb +31 -0
- data/test/unit/test-app-brkptmgr.rb +51 -0
- data/test/unit/test-app-cmd_parse.rb +97 -0
- data/test/unit/test-app-cmd_parser.rb +23 -0
- data/test/unit/test-app-complete.rb +39 -0
- data/test/unit/test-app-condition.rb +18 -0
- data/test/unit/test-app-display.rb +22 -0
- data/test/unit/test-app-iseq.rb +64 -0
- data/test/unit/test-app-method.rb +54 -0
- data/test/unit/test-app-options.rb +94 -0
- data/test/unit/test-app-run.rb +14 -0
- data/test/unit/test-app-util.rb +44 -0
- data/test/unit/test-app-validate.rb +18 -0
- data/test/unit/test-base-cmd.rb +45 -0
- data/test/unit/test-base-subcmd.rb +57 -0
- data/test/unit/test-base-submgr.rb +24 -0
- data/test/unit/test-base-subsubcmd.rb +17 -0
- data/test/unit/test-bin-trepanx.rb +48 -0
- data/test/unit/test-cmd-alias.rb +48 -0
- data/test/unit/test-cmd-break.rb +66 -0
- data/test/unit/test-cmd-edit.rb +34 -0
- data/test/unit/test-cmd-exit.rb +27 -0
- data/test/unit/test-cmd-finish.rb +31 -0
- data/test/unit/test-cmd-help.rb +104 -0
- data/test/unit/test-cmd-kill.rb +54 -0
- data/test/unit/test-cmd-parse_list_cmd.rb +36 -0
- data/test/unit/test-cmd-source.rb +34 -0
- data/test/unit/test-cmd-step.rb +29 -0
- data/test/unit/test-command.rb +45 -0
- data/test/unit/test-completion.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-io-tcp.rb +33 -0
- data/test/unit/test-io-tcpclient.rb +54 -0
- data/test/unit/test-io-tcpfns.rb +17 -0
- data/test/unit/test-io-tcpserver.rb +50 -0
- data/test/unit/test-proc-eval.rb +35 -0
- data/test/unit/test-proc-frame.rb +81 -0
- data/test/unit/test-proc-help.rb +16 -0
- data/test/unit/test-proc-hook.rb +30 -0
- data/test/unit/test-proc-list.rb +55 -0
- data/test/unit/test-proc-load_cmds.rb +51 -0
- data/test/unit/test-proc-location.rb +67 -0
- data/test/unit/test-proc-main.rb +95 -0
- data/test/unit/test-proc-validate.rb +139 -0
- data/test/unit/test-subcmd-help.rb +43 -0
- metadata +545 -0
@@ -0,0 +1,54 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../../app/method'
|
5
|
+
|
6
|
+
class TestAppMethod < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def test_find_method_with_line
|
9
|
+
method = Rubinius::VM.backtrace(0, true)[0].method
|
10
|
+
line = __LINE__
|
11
|
+
##############################
|
12
|
+
def foo # line + 2
|
13
|
+
a = 5 # line + 3
|
14
|
+
b = 6 # line + 4
|
15
|
+
end # line + 5
|
16
|
+
1.times do # line + 6
|
17
|
+
1.times do # line + 7
|
18
|
+
x = 11 # line + 8
|
19
|
+
foo # line + 9
|
20
|
+
end # line + 10
|
21
|
+
c = 14 # line + 11
|
22
|
+
end # line + 12
|
23
|
+
################################################
|
24
|
+
meths = [] # line + 14
|
25
|
+
expect = Array.new(22, true) # line + 15
|
26
|
+
[5, 10, 12, 13, 18].each do |i|
|
27
|
+
expect[i] = false # line + 17
|
28
|
+
end # line + 18
|
29
|
+
(2..21).each do |l| # line + 19
|
30
|
+
meth = Trepanning::Method.find_method_with_line(method, line+l)
|
31
|
+
meths << meth # line + 21
|
32
|
+
assert_equal(expect[l], !!meth, "Mismatched line #{line+l}")
|
33
|
+
end
|
34
|
+
pairs = [[1,2], [0,4], [5,9], [6,7], [14,15], [20,21]]
|
35
|
+
pairs.each do |pair|
|
36
|
+
assert_equal(meths[pair[0]].inspect, meths[pair[1]].inspect,
|
37
|
+
"Method compare")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
def test_valid_ip?
|
41
|
+
meth = Rubinius::VM.backtrace(0, true)[0].method
|
42
|
+
ip = Trepanning::Method.locate_line( __LINE__, meth)[1]
|
43
|
+
assert_equal(true, ip.kind_of?(Fixnum),
|
44
|
+
"locate line of #{__LINE__} should have gotten an IP;" +
|
45
|
+
" got: #{ip.inspect}")
|
46
|
+
[[-1, false],
|
47
|
+
[ 0, true],
|
48
|
+
[ip, true],
|
49
|
+
[100000, false]].each do |ip, expect|
|
50
|
+
assert_equal expect, Trepanning::Method.valid_ip?(meth, ip)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'stringio'
|
4
|
+
require 'tempfile'
|
5
|
+
require 'rubygems'; require 'require_relative'
|
6
|
+
require_relative '../../app/options'
|
7
|
+
|
8
|
+
# To have something to work with.
|
9
|
+
load 'tmpdir.rb'
|
10
|
+
|
11
|
+
class TestAppOptions < Test::Unit::TestCase
|
12
|
+
|
13
|
+
def setup
|
14
|
+
@options = Trepan::DEFAULT_CMDLINE_SETTINGS.clone
|
15
|
+
@stderr = StringIO.new
|
16
|
+
@stdout = StringIO.new
|
17
|
+
@options = Trepan::copy_default_options
|
18
|
+
@opts = Trepan::setup_options(@options, @stdout, @stderr)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_cd
|
22
|
+
rest = @opts.parse(['--cd', Dir.tmpdir])
|
23
|
+
assert_equal(Dir.tmpdir, @options[:chdir])
|
24
|
+
assert_equal('', @stderr.string)
|
25
|
+
assert_equal('', @stdout.string)
|
26
|
+
|
27
|
+
setup
|
28
|
+
tf = Tempfile.new("delete-me")
|
29
|
+
orig_cd = @options[:chdir]
|
30
|
+
rest = @opts.parse(['--cd', tf.path])
|
31
|
+
assert_equal(orig_cd, @options[:chdir])
|
32
|
+
assert_not_equal('', @stderr.string)
|
33
|
+
assert_equal('', @stdout.string)
|
34
|
+
File.unlink tf.path
|
35
|
+
# FIXME: add test where directory isn't executable.
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_binary_opts
|
39
|
+
%w(nx readline).each do |name|
|
40
|
+
setup
|
41
|
+
o = ["--#{name}"]
|
42
|
+
rest = @opts.parse o
|
43
|
+
assert_equal('', @stderr.string)
|
44
|
+
assert_equal(true, @options[name.to_sym])
|
45
|
+
end
|
46
|
+
# --no- options
|
47
|
+
%w(readline).each do |name|
|
48
|
+
o = ["--no-#{name}"]
|
49
|
+
rest = @opts.parse o
|
50
|
+
assert_equal('', @stderr.string)
|
51
|
+
assert_equal(false, @options[name.to_sym])
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_help_and_version_opts
|
56
|
+
omit unless Process.respond_to?(:fork)
|
57
|
+
Process.fork {
|
58
|
+
%w(help version).each do |name|
|
59
|
+
setup
|
60
|
+
o = ["--#{name}"]
|
61
|
+
rest = @opts.parse o
|
62
|
+
assert_not_equal('', @stdout.string)
|
63
|
+
assert_equal('', @stderr.string)
|
64
|
+
assert_equal(true, @options[name.to_sym])
|
65
|
+
other_sym = 'help' == name ? :version : :help
|
66
|
+
assert_equal(false, @options.member?(other_sym))
|
67
|
+
end
|
68
|
+
}
|
69
|
+
Process.wait
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_both_client_server_opts
|
73
|
+
# Try each of --client and --server options separately
|
74
|
+
%w(client server).each do |name|
|
75
|
+
setup
|
76
|
+
o = ["--#{name}"]
|
77
|
+
rest = @opts.parse o
|
78
|
+
assert_equal('', @stdout.string)
|
79
|
+
assert_equal('', @stderr.string)
|
80
|
+
assert_equal(true, @options[name.to_sym])
|
81
|
+
end
|
82
|
+
|
83
|
+
# Try both --client and --server together. Should give a warning
|
84
|
+
setup
|
85
|
+
o = %w(--client --server)
|
86
|
+
rest = @opts.parse o
|
87
|
+
assert_not_equal('', @stderr.string)
|
88
|
+
assert_equal('', @stdout.string)
|
89
|
+
assert_equal(true, @options[:client])
|
90
|
+
assert_equal(false, @options[:server])
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../../app/run'
|
5
|
+
|
6
|
+
class TestAppRun < Test::Unit::TestCase
|
7
|
+
include Trepanning
|
8
|
+
def test_basic
|
9
|
+
assert_equal(true, File.executable?(whence_file('irb')))
|
10
|
+
ng = whence_file('probably-does-not-exist')
|
11
|
+
assert_equal(true, File.executable?(ng) || ng == 'probably-does-not-exist')
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../../app/util'
|
5
|
+
|
6
|
+
class TestAppUtil < Test::Unit::TestCase
|
7
|
+
include Trepan::Util
|
8
|
+
def test_safe_repr
|
9
|
+
string = 'The time has come to talk of many things.'
|
10
|
+
assert_equal(string, safe_repr(string, 50))
|
11
|
+
assert_equal('The time... things.', safe_repr(string, 17))
|
12
|
+
assert_equal('"The tim... things."', safe_repr(string.inspect, 17))
|
13
|
+
string = "'The time has come to talk of many things.'"
|
14
|
+
assert_equal("'The tim... things.'", safe_repr(string, 17))
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_find_main_script
|
18
|
+
locs = Rubinius::VM.backtrace(0, true)
|
19
|
+
i = find_main_script(locs)
|
20
|
+
assert_equal(true, !!i)
|
21
|
+
assert_equal(false, !!find_main_script(locs[0..i]))
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_abbrev
|
25
|
+
list = %w(disassemble disable distance up)
|
26
|
+
[['dis', 'dis'],
|
27
|
+
['disas', 'disassemble'],
|
28
|
+
['u', 'up'],
|
29
|
+
['upper', 'upper'],
|
30
|
+
['foo', 'foo']].each do |name, expect|
|
31
|
+
assert_equal expect, uniq_abbrev(list, name)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_extract_expression
|
36
|
+
[['if condition("if")', 'condition("if")'],
|
37
|
+
['until until_termination', 'until_termination'],
|
38
|
+
['return return_value', 'return_value'],
|
39
|
+
['nothing_to_be.done', 'nothing_to_be.done'],
|
40
|
+
].each do |stmt, expect|
|
41
|
+
assert_equal expect, extract_expression(stmt)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../../app/validate'
|
5
|
+
|
6
|
+
class TestAppValidate < Test::Unit::TestCase
|
7
|
+
include Trepan::Validate
|
8
|
+
def test_line_or_ip
|
9
|
+
[
|
10
|
+
['@2', [2, nil]],
|
11
|
+
['oink', [nil, nil]],
|
12
|
+
['1' , [nil, 1]],
|
13
|
+
['12', [nil, 12]],
|
14
|
+
['-12', [nil, -12]]].each do |arg, expect|
|
15
|
+
assert_equal(line_or_ip(arg), expect)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../../processor/command'
|
5
|
+
|
6
|
+
class Trepan::Command::Test < Trepan::Command
|
7
|
+
NAME = 'test'
|
8
|
+
CATEGORY = 'testcategory'
|
9
|
+
completion %w(a aa ab ba aac)
|
10
|
+
end
|
11
|
+
|
12
|
+
class TestBaseCommand < Test::Unit::TestCase
|
13
|
+
|
14
|
+
class MockCmdProcessor
|
15
|
+
# The below functions aren't tested/called, but they are the
|
16
|
+
# methods required by a command and are placeholders for when we
|
17
|
+
# do start testing.
|
18
|
+
def initialize(dbgr)
|
19
|
+
end
|
20
|
+
def confirm(message, default)
|
21
|
+
p ['confirm: ', message, default]
|
22
|
+
end
|
23
|
+
def errmsg(message, opts)
|
24
|
+
p ['err:', message, opts]
|
25
|
+
end
|
26
|
+
def msg(message, opts)
|
27
|
+
p [message, opts]
|
28
|
+
end
|
29
|
+
def msg_nocr(message, opts)
|
30
|
+
p ['nocr: ', message, opts]
|
31
|
+
end
|
32
|
+
def section(message, opts)
|
33
|
+
p ['section: ', message, opts]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def setup
|
38
|
+
@proc = MockCmdProcessor.new(nil)
|
39
|
+
@cmd = Trepan::Command::Test.new(@proc)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_base_completion
|
43
|
+
assert_equal(%w(aa aac), @cmd.complete('aa'))
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
# require_relative '../../app/core'
|
5
|
+
require_relative '../../processor'
|
6
|
+
require_relative '../../processor/command/exit'
|
7
|
+
require_relative '../../processor/command/base/subcmd'
|
8
|
+
|
9
|
+
$errors = []
|
10
|
+
class TestBaseSubCommand < Test::Unit::TestCase
|
11
|
+
|
12
|
+
Trepan::Subcommand.const_set(:NAME, 'bogus')
|
13
|
+
def setup
|
14
|
+
$errors = []
|
15
|
+
$msgs = []
|
16
|
+
@dbgr = Trepan.new
|
17
|
+
# @core = Trepan::Core.new(@dbgr)
|
18
|
+
@cmdproc = Trepan::CmdProcessor.new(@dbgr)
|
19
|
+
@cmds = @cmdproc.instance_variable_get('@commands')
|
20
|
+
@exit_cmd = @cmds['exit']
|
21
|
+
@exit_subcmd = Trepan::Subcommand.new(@exit_cmd)
|
22
|
+
def @exit_subcmd.msg(message)
|
23
|
+
$msgs << message
|
24
|
+
end
|
25
|
+
def @exit_subcmd.errmsg(message)
|
26
|
+
$errors << message
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_base_subcommand
|
31
|
+
assert @exit_subcmd
|
32
|
+
assert_raises RuntimeError do
|
33
|
+
@exit_subcmd.run
|
34
|
+
end
|
35
|
+
assert_equal([], $errors)
|
36
|
+
@exit_subcmd.run_set_int('', 'testing 1 2 3')
|
37
|
+
assert_equal(1, $errors.size)
|
38
|
+
assert_equal(Fixnum, @exit_subcmd.settings[:maxwidth].class)
|
39
|
+
@cmds.each do |cmd_name, cmd_obj|
|
40
|
+
next unless cmd_obj.is_a?(Trepan::SubcommandMgr)
|
41
|
+
cmd_obj.subcmds.subcmds.each do |subcmd_name, subcmd_obj|
|
42
|
+
%w(HELP NAME PREFIX).each do |attr|
|
43
|
+
assert_equal(true, subcmd_obj.class.constants.member?(attr),
|
44
|
+
"Constant #{attr} should be defined in \"#{cmd_obj.name} #{subcmd_obj.class::NAME}\"")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_show_on_off
|
52
|
+
assert_equal('on', @exit_subcmd.show_onoff(true))
|
53
|
+
assert_equal('off', @exit_subcmd.show_onoff(false))
|
54
|
+
assert_equal('unset', @exit_subcmd.show_onoff(nil))
|
55
|
+
assert_equal('??', @exit_subcmd.show_onoff(5))
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative 'cmd-helper'
|
4
|
+
# We will use set as our canonical example
|
5
|
+
require_relative '../../processor/command/set'
|
6
|
+
|
7
|
+
class TestBaseSubcommandMgr < Test::Unit::TestCase
|
8
|
+
|
9
|
+
include UnitHelper
|
10
|
+
def setup
|
11
|
+
common_setup
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_basic
|
15
|
+
my_cmd = @cmds['show']
|
16
|
+
# require 'trepanning'; debugger
|
17
|
+
assert_equal(%w(debug different directories), my_cmd.complete('d'),
|
18
|
+
"Should be able to complete 'd'")
|
19
|
+
assert_equal(%w(show args), my_cmd.subcmds.lookup('ar').prefix,
|
20
|
+
"Should be able to complete lookup('ar')")
|
21
|
+
assert_equal(nil, my_cmd.subcmds.lookup('a'),
|
22
|
+
"Shouldn't find since we have 'show args' and 'show auto'")
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../../processor/command/base/subsubcmd'
|
5
|
+
|
6
|
+
$errors = []
|
7
|
+
class TestBaseSubCommand < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def test_prefix_set
|
10
|
+
Trepanning::SubSubcommand.set_name_prefix('/tmp/show_subcmd/auto_subcmd/food.rb',
|
11
|
+
self.class)
|
12
|
+
assert_equal('food', NAME, "should have set NAME")
|
13
|
+
assert_equal('show auto food', CMD)
|
14
|
+
assert_equal(%w(show auto food), PREFIX)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -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_RbConfig_ruby
|
12
|
+
rb_path = RbConfig.ruby
|
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,48 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative 'cmd-helper'
|
4
|
+
require_relative '../../processor/command/alias'
|
5
|
+
require_relative '../../processor/command/unalias'
|
6
|
+
|
7
|
+
# Test commands alias and unalias
|
8
|
+
class TestCommandAliasUnalias < Test::Unit::TestCase
|
9
|
+
|
10
|
+
include UnitHelper
|
11
|
+
def setup
|
12
|
+
common_setup
|
13
|
+
@name = File.basename(__FILE__, '.rb').split(/-/)[2]
|
14
|
+
end
|
15
|
+
|
16
|
+
def check_alias(should_not_have, cmd_name, *args)
|
17
|
+
@cmdproc.instance_variable_set('@msgs', [])
|
18
|
+
@cmdproc.instance_variable_set('@errmsgs', [])
|
19
|
+
arg_str = args.join(' ')
|
20
|
+
my_cmd = @cmds[cmd_name]
|
21
|
+
my_cmd.run([cmd_name] + args)
|
22
|
+
shoulda = should_not_have ? ['no ', ''] : ['', 'no ']
|
23
|
+
msgs = @cmdproc.instance_variable_get('@msgs')
|
24
|
+
errmsgs = @cmdproc.instance_variable_get('@errmsgs')
|
25
|
+
assert_equal(should_not_have, msgs.empty?,
|
26
|
+
"Expecting %s%s for #{arg_str}.\n Got #{msgs}" %
|
27
|
+
[shoulda[0], cmd_name])
|
28
|
+
assert_equal(!should_not_have, errmsgs.empty?,
|
29
|
+
"Expecting %serror for #{arg_str}.\n Got #{errmsgs}" %
|
30
|
+
shoulda[1])
|
31
|
+
end
|
32
|
+
|
33
|
+
def alias_defined?(alias_name)
|
34
|
+
@cmdproc.aliases.member?(alias_name)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_alias_command
|
38
|
+
|
39
|
+
assert_equal(false, @cmdproc.aliases.empty?,
|
40
|
+
'There should be some aliases defined')
|
41
|
+
|
42
|
+
assert_equal(false, alias_defined?('ki'))
|
43
|
+
check_alias(false, 'alias', 'ki', 'kill')
|
44
|
+
assert_equal(true, alias_defined?('ki'))
|
45
|
+
check_alias(false, 'unalias', 'ki')
|
46
|
+
assert_equal(false, alias_defined?('ki'))
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative 'cmd-helper'
|
4
|
+
|
5
|
+
class TestCommandBreak < Test::Unit::TestCase
|
6
|
+
|
7
|
+
include UnitHelper
|
8
|
+
def setup
|
9
|
+
common_setup
|
10
|
+
@cmdproc.frame_setup
|
11
|
+
@name = File.basename(__FILE__, '.rb').split(/-/)[2]
|
12
|
+
@my_cmd = @cmds[@name]
|
13
|
+
@brkpt_set_pat = /^Set breakpoint \d+: .*$/
|
14
|
+
end
|
15
|
+
|
16
|
+
def run_cmd(cmd, args)
|
17
|
+
cmd.proc.instance_variable_set('@cmd_argstr', args[1..-1].join(' '))
|
18
|
+
cmd.run(args)
|
19
|
+
end
|
20
|
+
|
21
|
+
# require_relative '../../lib/trepanning'
|
22
|
+
def test_basic
|
23
|
+
assert true
|
24
|
+
return
|
25
|
+
# [
|
26
|
+
# [@name, __LINE__.to_s],
|
27
|
+
# ].each_with_index do |args, i|
|
28
|
+
# run_cmd(@my_cmd, args)
|
29
|
+
# assert_equal(true, @cmdproc.errmsgs.empty?, @cmdproc.errmsgs)
|
30
|
+
# assert_equal(0, @cmdproc.msgs[0] =~ @brkpt_set_pat, @cmdproc.msgs[0])
|
31
|
+
# reset_cmdproc_vars
|
32
|
+
# end
|
33
|
+
|
34
|
+
# pc_offset = tf.pc_offset
|
35
|
+
# [[@name],
|
36
|
+
# [@name, "@#{pc_offset}"],
|
37
|
+
# #[@name, 'FileUtils.cp']
|
38
|
+
# ].each_with_index do |args, i|
|
39
|
+
# run_cmd(@my_cmd, args)
|
40
|
+
# assert_equal(true, @cmdproc.errmsgs.empty?, @cmdproc.errmsgs)
|
41
|
+
# assert_equal(0, @cmdproc.msgs[0] =~ @brkpt_set_pat, @cmdproc.msgs[0])
|
42
|
+
# reset_cmdproc_vars
|
43
|
+
# end
|
44
|
+
|
45
|
+
common_setup
|
46
|
+
def foo
|
47
|
+
5
|
48
|
+
end
|
49
|
+
[[@name, 'foo', (__LINE__-3).to_s]].each_with_index do |args, i|
|
50
|
+
run_cmd(@my_cmd, args)
|
51
|
+
assert_equal(true, @cmdproc.errmsgs.empty?,
|
52
|
+
@cmdproc.errmsgs)
|
53
|
+
assert_equal(true, @cmdproc.errmsgs.empty?, @cmdproc.errmsgs)
|
54
|
+
reset_cmdproc_vars
|
55
|
+
end
|
56
|
+
|
57
|
+
# [[@name, 'foo']].each_with_index do |args, i|
|
58
|
+
# run_cmd(@my_cmd, args)
|
59
|
+
# assert_equal(true, @cmdproc.errmsgs.empty?,
|
60
|
+
# @cmdproc.errmsgs)
|
61
|
+
# assert_equal(0, @cmdproc.msgs[0] =~ @brkpt_set_pat, @cmdproc.msgs[0])
|
62
|
+
# reset_cmdproc_vars
|
63
|
+
# end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative './mock-helper'
|
4
|
+
require_relative './cmd-helper'
|
5
|
+
require_relative '../../processor/command/edit'
|
6
|
+
|
7
|
+
class TestCommandEdit < Test::Unit::TestCase
|
8
|
+
include MockUnitHelper
|
9
|
+
def setup
|
10
|
+
@name = File.basename(__FILE__, '.rb').split(/-/)[2]
|
11
|
+
$msgs = []
|
12
|
+
$errmsgs = []
|
13
|
+
common_setup(@name)
|
14
|
+
def @cmd.msg(message)
|
15
|
+
$msgs << message
|
16
|
+
end
|
17
|
+
def @cmd.errmsg(message)
|
18
|
+
$errmsgs << message
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_basic
|
23
|
+
old_editor = ENV['EDITOR']
|
24
|
+
ENV['EDITOR'] = '#'
|
25
|
+
base_file = File.basename(__FILE__)
|
26
|
+
@cmd.proc.settings[:basename] = true
|
27
|
+
@cmd.run([@name])
|
28
|
+
assert_equal "Running # +7 \"mock-helper.rb\"...", $msgs[-1]
|
29
|
+
@cmd.run([@name, 8])
|
30
|
+
assert_equal "Running # +8 \"mock-helper.rb\"...", $msgs[-1]
|
31
|
+
@cmd.run([@name, __FILE__])
|
32
|
+
assert_equal "Running # +1 \"#{base_file}\"...", $msgs[-1]
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative './mock-helper'
|
5
|
+
require_relative '../../processor/command/exit'
|
6
|
+
|
7
|
+
class TestCommandExit < Test::Unit::TestCase
|
8
|
+
include MockUnitHelper
|
9
|
+
def setup
|
10
|
+
@name = File.basename(__FILE__, '.rb').split(/-/)[2]
|
11
|
+
common_setup(@name)
|
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,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative 'cmd-helper'
|
4
|
+
|
5
|
+
class TestCommandFinish < Test::Unit::TestCase
|
6
|
+
|
7
|
+
include UnitHelper
|
8
|
+
def setup
|
9
|
+
common_setup
|
10
|
+
@cmdproc.frame_setup
|
11
|
+
@name = File.basename(__FILE__, '.rb').split(/-/)[2]
|
12
|
+
@my_cmd = @cmds[@name]
|
13
|
+
end
|
14
|
+
|
15
|
+
def teardown
|
16
|
+
common_teardown
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_basic
|
20
|
+
[
|
21
|
+
[%W(#{@name}), 'finish', -1],
|
22
|
+
[%W(#{@name} 2-1), 'finish', -1],
|
23
|
+
].each do |c, rtp, count|
|
24
|
+
@cmdproc.instance_variable_set('@return_to_program', false)
|
25
|
+
@my_cmd.run(c)
|
26
|
+
assert_equal(rtp, @cmdproc.instance_variable_get('@return_to_program'))
|
27
|
+
assert_equal(count, @cmdproc.instance_variable_get('@step_count'))
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|