rbx-trepanning 0.0.5-universal-rubinius-1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +2002 -0
- data/LICENSE +25 -0
- data/NEWS +31 -0
- data/README.textile +34 -0
- data/Rakefile +165 -0
- data/THANKS +14 -0
- data/app/breakpoint.rb +219 -0
- data/app/breakpoint.rbc +3551 -0
- data/app/brkptmgr.rb +140 -0
- data/app/brkptmgr.rbc +2903 -0
- data/app/client.rb +61 -0
- data/app/client.rbc +1225 -0
- data/app/complete.rb +52 -0
- data/app/complete.rbc +1288 -0
- data/app/default.rb +71 -0
- data/app/default.rbc +1132 -0
- data/app/display.rb +148 -0
- data/app/display.rbc +2578 -0
- data/app/frame.rb +98 -0
- data/app/frame.rbc +1808 -0
- data/app/irb.rb +111 -0
- data/app/irb.rbc +2094 -0
- data/app/iseq.rb +117 -0
- data/app/iseq.rbc +2192 -0
- data/app/llvm.rbc +2478 -0
- data/app/method.rb +173 -0
- data/app/method.rbc +2492 -0
- data/app/method_name.rbc +2467 -0
- data/app/mock.rb +13 -0
- data/app/mock.rbc +398 -0
- data/app/options.rb +137 -0
- data/app/options.rbc +2898 -0
- data/app/rbx-llvm.rb +165 -0
- data/app/rbx-llvm.rbc +2478 -0
- data/app/run.rb +86 -0
- data/app/run.rbc +1244 -0
- data/app/util.rb +49 -0
- data/app/util.rbc +1146 -0
- data/app/validate.rb +30 -0
- data/app/validate.rbc +676 -0
- data/bin/trepan.compiled.rbc +1043 -0
- data/bin/trepanx +69 -0
- data/bin/trepanx.compiled.rbc +1049 -0
- data/data/irbrc +41 -0
- data/data/irbrc.compiled.rbc +640 -0
- data/interface/base_intf.rb +105 -0
- data/interface/base_intf.rbc +1899 -0
- data/interface/client.rb +80 -0
- data/interface/client.rbc +1072 -0
- data/interface/comcodes.rb +20 -0
- data/interface/comcodes.rbc +385 -0
- data/interface/script.rb +104 -0
- data/interface/script.rbc +1642 -0
- data/interface/server.rb +143 -0
- data/interface/server.rbc +2213 -0
- data/interface/user.rb +150 -0
- data/interface/user.rbc +2867 -0
- data/io/base_io.rb +148 -0
- data/io/base_io.rbc +2111 -0
- data/io/input.rb +135 -0
- data/io/input.rbc +2528 -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/io/tcpclient.rb +129 -0
- data/io/tcpclient.rbc +2419 -0
- data/io/tcpfns.rb +33 -0
- data/io/tcpfns.rbc +694 -0
- data/io/tcpserver.rb +141 -0
- data/io/tcpserver.rbc +2638 -0
- data/lib/trepanning.rb +474 -0
- data/lib/trepanning.rbc +7705 -0
- data/lib/trepanning2.rb +441 -0
- data/processor/breakpoint.rb +164 -0
- data/processor/command/alias.rb +55 -0
- data/processor/command/backtrace.rb +76 -0
- data/processor/command/base/cmd.rb +173 -0
- data/processor/command/base/subcmd.rb +229 -0
- data/processor/command/base/submgr.rb +182 -0
- data/processor/command/base/subsubcmd.rb +103 -0
- data/processor/command/base/subsubmgr.rb +195 -0
- data/processor/command/break.rb +100 -0
- data/processor/command/complete.rb +37 -0
- data/processor/command/continue.rb +91 -0
- data/processor/command/delete.rb +30 -0
- data/processor/command/directory.rb +51 -0
- data/processor/command/disassemble.rb +145 -0
- data/processor/command/display.rb +82 -0
- data/processor/command/down.rb +54 -0
- data/processor/command/eval.rb +51 -0
- data/processor/command/exit.rb +62 -0
- data/processor/command/finish.rb +80 -0
- data/processor/command/frame.rb +89 -0
- data/processor/command/help.rb +251 -0
- data/processor/command/info.rb +28 -0
- data/processor/command/info_subcmd/breakpoints.rb +73 -0
- data/processor/command/info_subcmd/files.rb +209 -0
- data/processor/command/info_subcmd/line.rb +86 -0
- data/processor/command/info_subcmd/method.rb +71 -0
- data/processor/command/info_subcmd/program.rb +49 -0
- data/processor/command/info_subcmd/ruby.rb +62 -0
- data/processor/command/info_subcmd/variables.rb +48 -0
- data/processor/command/irb.rb +128 -0
- data/processor/command/kill.rb +70 -0
- data/processor/command/list.rb +300 -0
- data/processor/command/macro.rb +76 -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/server.rb +72 -0
- data/processor/command/set.rb +47 -0
- data/processor/command/set_subcmd/auto.rb +27 -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 +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/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 +59 -0
- data/processor/command/set_subcmd/hidelevel.rb +62 -0
- data/processor/command/set_subcmd/highlight.rb +33 -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/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/substitute.rb +24 -0
- data/processor/command/set_subcmd/substitute_subcmd/path.rb +56 -0
- data/processor/command/set_subcmd/trace.rb +36 -0
- data/processor/command/set_subcmd/trace_subcmd/print.rb +57 -0
- data/processor/command/show.rb +38 -0
- data/processor/command/show_subcmd/alias.rb +42 -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/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 +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/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/hidelevel.rb +41 -0
- data/processor/command/show_subcmd/highlight.rb +24 -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/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 +27 -0
- data/processor/command/show_subcmd/trace_subcmd/print.rb +38 -0
- data/processor/command/show_subcmd/version.rb +23 -0
- data/processor/command/source.rb +126 -0
- data/processor/command/step.rb +84 -0
- data/processor/command/tbreak.rb +19 -0
- data/processor/command/unalias.rb +44 -0
- data/processor/command/undisplay.rb +59 -0
- data/processor/command/up.rb +86 -0
- data/processor/default.rb +58 -0
- data/processor/disassemble.rb +46 -0
- data/processor/display.rb +18 -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 +185 -0
- data/processor/location.rb +137 -0
- data/processor/main.rb +412 -0
- data/processor/mock.rb +144 -0
- data/processor/msg.rb +43 -0
- data/processor/running.rb +234 -0
- data/processor/stepping.rb +114 -0
- data/processor/subcmd.rb +161 -0
- data/processor/validate.rb +355 -0
- data/sample/list-terminal-colors.rb +139 -0
- data/sample/list-terminal-colors.rbc +2318 -0
- data/sample/rocky-dot-trepanxrc +14 -0
- data/sample/rocky-trepanx-colors.rb +47 -0
- data/sample/rocky-trepanx-colors.rbc +530 -0
- data/test/data/enable.right +36 -0
- data/test/data/fname-with-blank.cmd +6 -0
- data/test/data/fname-with-blank.right +4 -0
- data/test/data/inline-call.cmd +6 -0
- data/test/data/inline-call.right +13 -0
- data/test/data/quit-Xdebug.right +3 -0
- data/test/data/quit.cmd +5 -0
- data/test/data/quit.right +2 -0
- data/test/data/quit2.cmd +6 -0
- data/test/data/quit2.right +3 -0
- data/test/data/step-bug.cmd +11 -0
- data/test/data/step-bug.right +3 -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/inline-call.rb +23 -0
- data/test/example/null.rb +1 -0
- data/test/example/step-bug.rb +14 -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/skip-test-step-bug.rb +17 -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/cmd-helper.rb +50 -0
- data/test/unit/mock-helper.rb +10 -0
- data/test/unit/test-app-brkpt.rb +29 -0
- data/test/unit/test-app-brkptmgr.rb +51 -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 +82 -0
- data/test/unit/test-app-run.rb +16 -0
- data/test/unit/test-app-util.rb +27 -0
- data/test/unit/test-app-validate.rb +18 -0
- data/test/unit/test-base-cmd.rb +47 -0
- data/test/unit/test-base-subcmd.rb +61 -0
- data/test/unit/test-base-submgr.rb +24 -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 +22 -0
- data/test/unit/test-cmd-exit.rb +27 -0
- data/test/unit/test-cmd-finish.rb +27 -0
- data/test/unit/test-cmd-help.rb +104 -0
- data/test/unit/test-cmd-kill.rb +47 -0
- data/test/unit/test-cmd-source.rb +34 -0
- data/test/unit/test-cmd-step.rb +29 -0
- data/test/unit/test-completion.rb +38 -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 +36 -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 +50 -0
- data/test/unit/test-proc-location.rb +53 -0
- data/test/unit/test-proc-main.rb +99 -0
- data/test/unit/test-proc-validate.rb +91 -0
- data/test/unit/test-subcmd-help.rb +47 -0
- metadata +398 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../../app/brkptmgr'
|
5
|
+
require_relative '../../app/breakpoint'
|
6
|
+
|
7
|
+
class TestLibAppBrkptMgr < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@meth = Rubinius::CompiledMethod.of_sender
|
11
|
+
@brkpts = Trepan::BreakpointMgr.new
|
12
|
+
@offset = 0
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_basic
|
16
|
+
assert_equal(0, @brkpts.size)
|
17
|
+
b1 = @brkpts.add("<start>", @meth, @offset, 0, 1)
|
18
|
+
assert_equal(b1, @brkpts.find(@meth, @offset))
|
19
|
+
assert_equal(1, @brkpts.size)
|
20
|
+
# require 'trepanning'
|
21
|
+
# dbgr = Trepan.new(:set_restart => true); dbgr.start
|
22
|
+
assert_equal(b1, @brkpts.delete(b1.id))
|
23
|
+
assert_equal(0, @brkpts.size)
|
24
|
+
|
25
|
+
# Try adding via << rather than .add
|
26
|
+
b2 = @brkpts << Trepan::Breakpoint.new(@meth, 5, nil, :temp => true)
|
27
|
+
|
28
|
+
assert_equal(nil, @brkpts.find(@meth, 6))
|
29
|
+
@brkpts.reset
|
30
|
+
assert_equal(0, @brkpts.size)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_multiple_brkpt_per_offset
|
34
|
+
b1 = @brkpts.add("b1", @meth, @offset, 5, 2)
|
35
|
+
b2 = @brkpts.add("b2", @meth, @offset, 5, 2)
|
36
|
+
assert_equal(2, @brkpts.size)
|
37
|
+
assert_equal(1, @brkpts.set.size,
|
38
|
+
'Two breakpoints but only one @meth/offset')
|
39
|
+
@brkpts.delete_by_brkpt(b1)
|
40
|
+
assert_equal(1, @brkpts.size,
|
41
|
+
'One breakpoint after 2nd breakpoint deleted')
|
42
|
+
assert_equal(1, @brkpts.set.size,
|
43
|
+
'Two breakpoints, but only one @meth/offset')
|
44
|
+
@brkpts.delete_by_brkpt(b2)
|
45
|
+
assert_equal(0, @brkpts.size,
|
46
|
+
'Both breakpoints deleted')
|
47
|
+
assert_equal(0, @brkpts.set.size,
|
48
|
+
'Second breakpoint delete should delete @meth/offset')
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../../app/iseq'
|
5
|
+
|
6
|
+
class TestAppISeq < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def test_disasm_prefix
|
9
|
+
meth = Rubinius::VM.backtrace(0, true)[0].method
|
10
|
+
assert_equal(' -->', Trepan::ISeq.disasm_prefix(0, 0, meth))
|
11
|
+
assert_equal(' ', Trepan::ISeq.disasm_prefix(0, 1, meth))
|
12
|
+
meth.set_breakpoint(0, nil)
|
13
|
+
assert_equal('B-->', Trepan::ISeq.disasm_prefix(0, 0, meth))
|
14
|
+
assert_equal('B ', Trepan::ISeq.disasm_prefix(0, 1, meth))
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_basic
|
18
|
+
|
19
|
+
def single_return
|
20
|
+
cm = Rubinius::VM.backtrace(0, true)[0].method
|
21
|
+
last = cm.lines.last
|
22
|
+
first = 0
|
23
|
+
0.upto((cm.lines.last+1)/2) do |i|
|
24
|
+
first = cm.lines[i*2]
|
25
|
+
break if -1 != first
|
26
|
+
end
|
27
|
+
[last, Trepan::ISeq.yield_or_return_between(cm, first, last)]
|
28
|
+
end
|
29
|
+
|
30
|
+
def branching(bool)
|
31
|
+
cm = Rubinius::VM.backtrace(0, true)[0].method
|
32
|
+
last = cm.lines.last
|
33
|
+
first = nil
|
34
|
+
0.upto((cm.lines.last+1)/2) do |i|
|
35
|
+
first = cm.lines[i*2]
|
36
|
+
break if -1 != first
|
37
|
+
end
|
38
|
+
|
39
|
+
if bool
|
40
|
+
x = 5
|
41
|
+
else
|
42
|
+
x = 6
|
43
|
+
end
|
44
|
+
Trepan::ISeq.goto_between(cm, first, last)
|
45
|
+
end
|
46
|
+
|
47
|
+
def no_branching
|
48
|
+
cm = Rubinius::VM.backtrace(0, true)[0].method
|
49
|
+
last = cm.lines.last
|
50
|
+
first = 0
|
51
|
+
0.upto((cm.lines.last+1)/2) do |i|
|
52
|
+
first = cm.lines[i*2]
|
53
|
+
break if -1 != first
|
54
|
+
end
|
55
|
+
Trepan::ISeq.goto_between(cm, first, last)
|
56
|
+
end
|
57
|
+
|
58
|
+
last, return_ips = single_return
|
59
|
+
assert_equal([last-1], return_ips)
|
60
|
+
assert_equal(-2, no_branching)
|
61
|
+
assert_equal(2, branching(true).size)
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -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,82 @@
|
|
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
|
+
# FIXME: add test where directory isn't executable.
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_binary_opts
|
38
|
+
%w(nx).each do |name|
|
39
|
+
setup
|
40
|
+
o = ["--#{name}"]
|
41
|
+
rest = @opts.parse o
|
42
|
+
assert_equal('', @stderr.string)
|
43
|
+
assert_equal(true, @options[name.to_sym])
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_help_and_version_opts
|
48
|
+
%w(help version).each do |name|
|
49
|
+
setup
|
50
|
+
o = ["--#{name}"]
|
51
|
+
rest = @opts.parse o
|
52
|
+
assert_not_equal('', @stdout.string)
|
53
|
+
assert_equal('', @stderr.string)
|
54
|
+
assert_equal(true, @options[name.to_sym])
|
55
|
+
other_sym = 'help' == name ? :version : :help
|
56
|
+
assert_equal(false, @options.member?(other_sym))
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_both_client_server_opts
|
61
|
+
# Try each of --client and --server options separately
|
62
|
+
%w(client server).each do |name|
|
63
|
+
setup
|
64
|
+
o = ["--#{name}"]
|
65
|
+
rest = @opts.parse o
|
66
|
+
assert_equal('', @stdout.string)
|
67
|
+
assert_equal('', @stderr.string)
|
68
|
+
assert_equal(true, @options[name.to_sym])
|
69
|
+
end
|
70
|
+
|
71
|
+
# Try both --client and --server together. Should give a warning
|
72
|
+
setup
|
73
|
+
o = %w(--client --server)
|
74
|
+
rest = @opts.parse o
|
75
|
+
assert_not_equal('', @stderr.string)
|
76
|
+
assert_equal('', @stdout.string)
|
77
|
+
assert_equal(true, @options[:client])
|
78
|
+
assert_equal(false, @options[:server])
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
@@ -0,0 +1,16 @@
|
|
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
|
+
rp = ruby_path
|
13
|
+
assert_equal(true, File.executable?(rp))
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,27 @@
|
|
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
|
+
j = locs.size - i
|
22
|
+
if j > 0
|
23
|
+
locs = Rubinius::VM.backtrace(j, true)
|
24
|
+
assert_equal(false, !!find_main_script(locs))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
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
|
+
[['o1', [1, nil]],
|
10
|
+
['O2', [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,47 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../../processor/command/base/cmd'
|
5
|
+
|
6
|
+
class Trepan
|
7
|
+
class Command::Test < Trepan::Command
|
8
|
+
NAME = 'test'
|
9
|
+
CATEGORY = 'testcategory'
|
10
|
+
completion %w(a aa ab ba aac)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class TestBaseCommand < Test::Unit::TestCase
|
15
|
+
|
16
|
+
class MockCmdProcessor
|
17
|
+
# The below functions aren't tested/called, but they are the
|
18
|
+
# methods required by a command and are placeholders for when we
|
19
|
+
# do start testing.
|
20
|
+
def initialize(dbgr)
|
21
|
+
end
|
22
|
+
def confirm(message, default)
|
23
|
+
p ['confirm: ', message, default]
|
24
|
+
end
|
25
|
+
def errmsg(message, opts)
|
26
|
+
p ['err:', message, opts]
|
27
|
+
end
|
28
|
+
def msg(message, opts)
|
29
|
+
p [message, opts]
|
30
|
+
end
|
31
|
+
def msg_nocr(message, opts)
|
32
|
+
p ['nocr: ', message, opts]
|
33
|
+
end
|
34
|
+
def section(message, opts)
|
35
|
+
p ['section: ', message, opts]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def setup
|
40
|
+
@proc = MockCmdProcessor.new(nil)
|
41
|
+
@cmd = Trepan::Command::Test.new(@proc)
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_base_completion
|
45
|
+
assert_equal(%w(aa aac), @cmd.complete('aa'))
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
# require_relative '../../app/core'
|
5
|
+
require_relative '../../processor/main'
|
6
|
+
require_relative '../../processor/command/exit'
|
7
|
+
require_relative '../../processor/command/base/subcmd'
|
8
|
+
|
9
|
+
# Mock debugger stub. FIXME: put in common helper routine.
|
10
|
+
class Trepan
|
11
|
+
end
|
12
|
+
|
13
|
+
$errors = []
|
14
|
+
class TestBaseSubCommand < Test::Unit::TestCase
|
15
|
+
|
16
|
+
Trepan::Subcommand.const_set(:NAME, 'bogus')
|
17
|
+
def setup
|
18
|
+
$errors = []
|
19
|
+
$msgs = []
|
20
|
+
@dbgr = Trepan.new
|
21
|
+
# @core = Trepan::Core.new(@dbgr)
|
22
|
+
@cmdproc = Trepan::CmdProcessor.new(@dbgr)
|
23
|
+
@cmds = @cmdproc.instance_variable_get('@commands')
|
24
|
+
@exit_cmd = @cmds['exit']
|
25
|
+
@exit_subcmd = Trepan::Subcommand.new(@exit_cmd)
|
26
|
+
def @exit_subcmd.msg(message)
|
27
|
+
$msgs << message
|
28
|
+
end
|
29
|
+
def @exit_subcmd.errmsg(message)
|
30
|
+
$errors << message
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_base_subcommand
|
35
|
+
assert @exit_subcmd
|
36
|
+
assert_raises RuntimeError do
|
37
|
+
@exit_subcmd.run
|
38
|
+
end
|
39
|
+
assert_equal([], $errors)
|
40
|
+
@exit_subcmd.run_set_int('', 'testing 1 2 3')
|
41
|
+
assert_equal(1, $errors.size)
|
42
|
+
assert_equal(Fixnum, @exit_subcmd.settings[:maxwidth].class)
|
43
|
+
@cmds.each do |cmd_name, cmd_obj|
|
44
|
+
next unless cmd_obj.is_a?(Trepan::SubcommandMgr)
|
45
|
+
cmd_obj.subcmds.subcmds.each do |subcmd_name, subcmd_obj|
|
46
|
+
%w(HELP NAME PREFIX).each do |attr|
|
47
|
+
assert_equal(true, subcmd_obj.class.constants.member?(attr),
|
48
|
+
"Constant #{attr} should be defined in \"#{cmd_obj.name} #{subcmd_obj.class::NAME}\"")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_show_on_off
|
56
|
+
assert_equal('on', @exit_subcmd.show_onoff(true))
|
57
|
+
assert_equal('off', @exit_subcmd.show_onoff(false))
|
58
|
+
assert_equal('unset', @exit_subcmd.show_onoff(nil))
|
59
|
+
assert_equal('??', @exit_subcmd.show_onoff(5))
|
60
|
+
end
|
61
|
+
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), 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
|