trepanning 0.1.0 → 0.1.1
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/.gitignore +4 -0
- data/ChangeLog +1279 -235
- data/Makefile +13 -0
- data/NEWS +30 -0
- data/Rakefile +50 -14
- data/app/.gitignore +1 -0
- data/app/breakpoint.rb +7 -2
- data/app/brkptmgr.rb +12 -0
- data/app/cmd_parse.citrus +167 -0
- data/app/cmd_parse.kpeg +221 -0
- data/app/cmd_parse.rb +201 -0
- data/app/cmd_parser.rb +1914 -0
- data/app/complete.rb +79 -0
- data/app/condition.rb +1 -1
- data/app/core.rb +7 -11
- data/app/default.rb +1 -1
- data/app/disassemble.rb +3 -2
- data/app/file.rb +12 -36
- data/app/frame.rb +3 -2
- data/app/irb.rb +9 -5
- data/app/iseq.rb +46 -0
- data/app/options.rb +6 -30
- data/app/run.rb +5 -2
- data/app/util.rb +1 -2
- data/app/yarv.rb +11 -1
- data/bin/.gitignore +1 -0
- data/bin/trepan +6 -6
- data/data/.gitignore +1 -0
- data/interface/.gitignore +1 -0
- data/interface/base_intf.rb +9 -5
- data/interface/comcodes.rb +10 -8
- data/interface/user.rb +76 -17
- data/io/.gitignore +1 -0
- data/io/input.rb +39 -15
- data/io/tcpclient.rb +7 -1
- data/io/tcpfns.rb +5 -3
- data/io/tcpserver.rb +13 -10
- data/lib/.gitignore +1 -0
- data/lib/trepanning.rb +50 -13
- data/processor/.gitignore +1 -0
- data/processor/Makefile +7 -0
- data/processor/breakpoint.rb +7 -2
- data/processor/command/.gitignore +1 -0
- data/processor/command/Makefile +7 -0
- data/processor/command/alias.rb +2 -2
- data/processor/command/backtrace.rb +4 -0
- data/processor/command/base/cmd.rb +45 -2
- data/processor/command/base/subcmd.rb +4 -2
- data/processor/command/base/submgr.rb +23 -19
- data/processor/command/base/subsubcmd.rb +23 -1
- data/processor/command/base/subsubmgr.rb +13 -0
- data/processor/command/break.rb +34 -29
- data/processor/command/complete.rb +37 -0
- data/processor/command/condition.rb +2 -0
- data/processor/command/continue.rb +15 -18
- data/processor/command/disassemble.rb +5 -0
- data/processor/command/down.rb +1 -1
- data/processor/command/eval.rb +70 -0
- data/processor/command/exit.rb +4 -1
- data/processor/command/finish.rb +6 -4
- data/processor/command/frame.rb +6 -3
- data/processor/command/help.rb +97 -54
- data/processor/command/help/.gitignore +1 -0
- data/processor/command/help/README +10 -0
- data/processor/command/help/command.txt +48 -0
- data/processor/command/help/filename.txt +40 -0
- data/processor/command/help/location.txt +37 -0
- data/processor/command/info_subcmd/.gitignore +1 -0
- data/processor/command/info_subcmd/breakpoints.rb +9 -9
- data/processor/command/info_subcmd/{file.rb → files.rb} +92 -27
- data/processor/command/info_subcmd/frame.rb +41 -15
- data/processor/command/info_subcmd/iseq.rb +39 -17
- data/processor/command/info_subcmd/program.rb +2 -8
- data/processor/command/info_subcmd/registers.rb +12 -10
- data/processor/command/info_subcmd/registers_subcmd/.gitignore +1 -0
- data/processor/command/info_subcmd/ruby.rb +60 -0
- data/processor/command/irb.rb +26 -3
- data/processor/command/kill.rb +21 -10
- data/processor/command/list.rb +1 -1
- data/processor/command/macro.rb +37 -23
- data/processor/command/pr.rb +1 -1
- data/processor/command/reload.rb +4 -0
- data/processor/command/reload_subcmd/.gitignore +1 -0
- data/processor/command/restart.rb +9 -9
- data/processor/command/save.rb +29 -36
- data/processor/command/set_subcmd/.gitignore +1 -0
- data/processor/command/set_subcmd/auto_subcmd/.gitignore +1 -0
- data/processor/command/set_subcmd/confirm.rb +23 -0
- data/processor/command/set_subcmd/debug_subcmd/.gitignore +1 -0
- data/processor/command/set_subcmd/different.rb +2 -0
- data/processor/command/set_subcmd/events.rb +2 -0
- data/processor/command/set_subcmd/max.rb +9 -12
- data/processor/command/set_subcmd/max_subcmd/.gitignore +1 -0
- data/processor/command/set_subcmd/substitute_subcmd/.gitignore +1 -0
- data/processor/command/set_subcmd/trace.rb +7 -13
- data/processor/command/set_subcmd/trace_subcmd/.gitignore +1 -0
- data/processor/command/set_subcmd/trace_subcmd/buffer.rb +12 -27
- data/processor/command/set_subcmd/trace_subcmd/print.rb +10 -8
- data/processor/command/set_subcmd/trace_subcmd/var.rb +6 -10
- data/processor/command/show.rb +12 -1
- data/processor/command/show_subcmd/.gitignore +1 -0
- data/processor/command/show_subcmd/alias.rb +11 -15
- data/processor/command/show_subcmd/auto_subcmd/.gitignore +1 -0
- data/processor/command/show_subcmd/basename.rb +1 -9
- data/processor/command/show_subcmd/confirm.rb +25 -0
- data/processor/command/show_subcmd/debug_subcmd/.gitignore +1 -0
- data/processor/command/show_subcmd/macro.rb +32 -14
- data/processor/command/show_subcmd/max_subcmd/.gitignore +1 -0
- data/processor/command/show_subcmd/trace_subcmd/.gitignore +1 -0
- data/processor/command/show_subcmd/trace_subcmd/buffer.rb +11 -31
- data/processor/command/show_subcmd/trace_subcmd/print.rb +4 -20
- data/processor/command/source.rb +7 -1
- data/processor/command/up.rb +7 -4
- data/processor/default.rb +3 -1
- data/processor/eval.rb +13 -0
- data/processor/eventbuf.rb +3 -2
- data/processor/frame.rb +19 -0
- data/processor/help.rb +20 -0
- data/processor/load_cmds.rb +143 -24
- data/processor/location.rb +61 -10
- data/processor/main.rb +30 -11
- data/processor/mock.rb +5 -3
- data/processor/msg.rb +17 -0
- data/processor/running.rb +1 -1
- data/processor/subcmd.rb +3 -2
- data/processor/validate.rb +173 -185
- data/sample/.gitignore +1 -0
- data/sample/list-terminal-colors.rb +139 -0
- data/sample/rocky-dot-trepanrc +14 -0
- data/sample/rocky-trepan-colors.rb +47 -0
- data/test/Makefile +7 -0
- data/test/data/.gitignore +1 -0
- data/test/data/debugger-stop.cmd +3 -0
- data/test/data/debugger-stop.right +5 -0
- data/test/data/fname-with-blank.right +0 -3
- data/test/data/quit.right +0 -1
- data/test/data/quit2.cmd +6 -0
- data/test/data/quit2.right +3 -0
- data/test/data/testing.cmd +1 -0
- data/test/example/.gitignore +1 -0
- data/test/example/debugger-stop.rb +14 -0
- data/test/functional/.gitignore +2 -0
- data/test/functional/fn_helper.rb +7 -9
- data/test/functional/test-break-long.rb +7 -7
- data/test/functional/test-break.rb +7 -7
- data/test/functional/test-condition.rb +4 -4
- data/test/functional/test-delete.rb +6 -5
- data/test/functional/test-eval.rb +115 -0
- data/test/functional/test-raise.rb +1 -1
- data/test/functional/test-return.rb +1 -1
- data/test/integration/.gitignore +2 -0
- data/test/integration/helper.rb +6 -3
- data/test/integration/test-debugger-stop.rb +22 -0
- data/test/integration/test-quit.rb +8 -0
- data/test/unit/.gitignore +1 -0
- data/test/unit/Makefile +7 -0
- data/test/unit/test-app-brkpt.rb +0 -1
- data/test/unit/test-app-cmd_parse.rb +107 -0
- data/test/unit/test-app-cmd_parser.rb +22 -0
- data/test/unit/test-app-complete.rb +38 -0
- data/test/unit/test-app-condition.rb +20 -0
- data/test/unit/test-app-iseq.rb +31 -0
- data/test/unit/test-app-options.rb +9 -1
- data/test/unit/test-app-util.rb +0 -1
- data/test/unit/test-base-cmd.rb +46 -0
- data/test/unit/test-base-subcmd.rb +11 -2
- data/test/unit/test-base-submgr.rb +23 -0
- data/test/unit/test-base-subsubcmd.rb +20 -0
- data/test/unit/test-cmd-break.rb +22 -23
- data/test/unit/test-cmd-help.rb +4 -0
- data/test/unit/test-completion.rb +43 -0
- data/test/unit/test-io-tcpclient.rb +3 -2
- data/test/unit/test-proc-load_cmds.rb +10 -1
- data/test/unit/test-proc-location.rb +39 -0
- data/test/unit/test-proc-main.rb +1 -1
- data/test/unit/test-proc-validate.rb +47 -31
- data/trepanning.gemspec +45 -0
- metadata +247 -179
- data/app/core.rb-consider +0 -198
- data/test/functional/tmp/b3.rb +0 -5
- data/test/functional/tmp/immediate-bug1.rb +0 -9
data/test/integration/helper.rb
CHANGED
@@ -25,14 +25,15 @@ def run_debugger(testname, ruby_file, opts={})
|
|
25
25
|
rightfile = File.join(datadir, short_right)
|
26
26
|
|
27
27
|
short_cmd = "#{opts[:short_cmd] || testname}.cmd"
|
28
|
-
cmdfile = File.join(datadir, short_cmd)
|
28
|
+
cmdfile = opts[:cmdfile] || File.join(datadir, short_cmd)
|
29
29
|
outfile = opts[:outfile] ||
|
30
30
|
File.join(srcdir, "#{testname}.out")
|
31
31
|
programfile = ruby_file ? File.join(progdir, ruby_file) : ''
|
32
32
|
|
33
33
|
FileUtils.rm(outfile) if File.exist?(outfile)
|
34
34
|
|
35
|
-
cmd =
|
35
|
+
cmd = opts[:feed_input] ? "#{opts[:feed_input]} |" : ''
|
36
|
+
cmd +=
|
36
37
|
if opts[:standalone]
|
37
38
|
"%s %s %s >%s 2>&1" %
|
38
39
|
[Trepanning::ruby_path, programfile, opts[:args], outfile]
|
@@ -41,13 +42,15 @@ def run_debugger(testname, ruby_file, opts={})
|
|
41
42
|
[Trepanning::ruby_path, dbgr_path, cmdfile, opts[:dbgr],
|
42
43
|
programfile, opts[:args], outfile]
|
43
44
|
end
|
44
|
-
|
45
|
+
puts cmd if opts[:verbose]
|
45
46
|
system(cmd)
|
46
47
|
return false unless 0 == $?.exitstatus
|
47
48
|
if opts[:do_diff]
|
48
49
|
expected_lines = File.open(rightfile).readlines()
|
49
50
|
got_lines = File.open(outfile).readlines()
|
50
51
|
opts[:filter].call(got_lines, expected_lines) if opts[:filter]
|
52
|
+
# puts "=" * 80
|
53
|
+
# got_lines.map{|line| puts line}
|
51
54
|
|
52
55
|
# Seems to be a bug in LCS in that it will return a diff even if two
|
53
56
|
# files are the same.
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require_relative 'helper'
|
4
|
+
|
5
|
+
class TestDebuggerStop < Test::Unit::TestCase
|
6
|
+
@@NAME = File.basename(__FILE__, '.rb')[5..-1]
|
7
|
+
|
8
|
+
def test_it
|
9
|
+
opts = {}
|
10
|
+
opts[:feed_input] = "echo 'info program ;; continue ;; quit!' "
|
11
|
+
opts[:filter] = Proc.new{|got_lines, correct_lines|
|
12
|
+
got_lines[0].gsub!(/\(.*debugger-stop.rb[:]\d+ @\d+/,
|
13
|
+
'debugger-stop.rb:14 @1955')
|
14
|
+
# require_relative '../../lib/trepanning'; debugger
|
15
|
+
got_lines[2].gsub!(/PC offset \d+ .*<top .+debugger-stop.rb/,
|
16
|
+
"PC offset 100 <top debugger-stop.rb")
|
17
|
+
got_lines[3].gsub!(/\(.*debugger-stop.rb[:]\d+ @\d+/,
|
18
|
+
'debugger-stop.rb:10 @1954')
|
19
|
+
}
|
20
|
+
assert_equal(true, run_debugger(@@NAME, @@NAME + '.rb', opts))
|
21
|
+
end
|
22
|
+
end
|
@@ -5,6 +5,14 @@ require_relative 'helper'
|
|
5
5
|
class TestQuit < Test::Unit::TestCase
|
6
6
|
@@NAME = File.basename(__FILE__, '.rb')[5..-1]
|
7
7
|
|
8
|
+
# def test_trepanx_set_confirm_off
|
9
|
+
# opts = {}
|
10
|
+
# opts[:filter] = Proc.new{|got_lines, correct_lines|
|
11
|
+
# got_lines[0] = "-> (null.rb:1 @0)\n"
|
12
|
+
# }
|
13
|
+
# assert_equal(true, run_debugger('quit2', 'null.rb', opts))
|
14
|
+
# end
|
15
|
+
|
8
16
|
def test_trepan_call
|
9
17
|
opts = {}
|
10
18
|
opts[:filter] = Proc.new{|got_lines, correct_lines|
|
@@ -0,0 +1 @@
|
|
1
|
+
/*~
|
data/test/unit/Makefile
ADDED
data/test/unit/test-app-brkpt.rb
CHANGED
@@ -0,0 +1,107 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require_relative '../../app/cmd_parse'
|
4
|
+
|
5
|
+
class TestCmdParse < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def no__test_parse_location
|
8
|
+
['fn', 'fn 5', 'fn @5', '@5', '5', 'fn:5', 'fn:@5'].each do |location|
|
9
|
+
begin
|
10
|
+
match = MethodName.parse(location, :root => :location)
|
11
|
+
assert_equal location, match.to_s, "should be able to parse of #{location}"
|
12
|
+
rescue Citrus::ParseError
|
13
|
+
assert false, "should be able to parse of #{location}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# Check actual values
|
18
|
+
[['@5', 5, :vm_offset], ['10', 10, :line_number]].each do
|
19
|
+
|position, expect, symbol|
|
20
|
+
match = MethodName.parse(position, :root => symbol)
|
21
|
+
assert_equal(expect, match.value.value,
|
22
|
+
"should be able to get value of location #{position}")
|
23
|
+
end
|
24
|
+
# %w(0 1e10 a.b).each do |location|
|
25
|
+
# begin
|
26
|
+
# match = MethodName.parse(location, :root => :identifier)
|
27
|
+
# assert false, "should not have been able to parse of #{location}"
|
28
|
+
# rescue Citrus::ParseError
|
29
|
+
# assert true, "should not have been able to parse of #{location}"
|
30
|
+
# end
|
31
|
+
# end
|
32
|
+
end
|
33
|
+
|
34
|
+
module Testing
|
35
|
+
def testing; 5 end
|
36
|
+
module_function :testing
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_parse_identifier
|
40
|
+
%w(a a1 $global __FILE__ Constant).each do |name|
|
41
|
+
cp = CmdParse.new(name)
|
42
|
+
assert cp._identifier, "should be able to parse of #{name}"
|
43
|
+
end
|
44
|
+
%w(0 1e10 @10).each do |name|
|
45
|
+
cp = CmdParse.new(name)
|
46
|
+
assert_equal(true, !cp._identifier,
|
47
|
+
"should not have been able to parse of #{name}")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_parse_method
|
52
|
+
[['Object', [:constant]],
|
53
|
+
['AA::B', [:constant] * 2],
|
54
|
+
['Aa::Bb::C', [:constant] * 3],
|
55
|
+
['A::B::C::D', [:constant] * 4],
|
56
|
+
['A::B.c', [:constant, :constant, :variable]],
|
57
|
+
['A.b.c.d', [:constant] + [:variable] * 3],
|
58
|
+
['@ivar', [:instance]],
|
59
|
+
['@@classvar', [:classvar]],
|
60
|
+
['$global', [:global]],
|
61
|
+
['$global.meth', [:global, :variable]],
|
62
|
+
['@ivar.meth', [:instance, :variable]],
|
63
|
+
].each do |name, types|
|
64
|
+
cp = CmdParse.new(name)
|
65
|
+
assert cp._class_module_chain, "should be able to parse of #{name}"
|
66
|
+
m = cp.result
|
67
|
+
assert_equal m.type, types[0], "parse type of #{name}"
|
68
|
+
1.upto(types.size-1) do |i|
|
69
|
+
assert m, "Chain item #{i} of #{name} should not be nil"
|
70
|
+
m = m.chain[1]
|
71
|
+
assert_equal m.type, types[i], "parse type of #{name}"
|
72
|
+
end
|
73
|
+
assert_nil m.chain, "chain item #{types.size} in #{cp.result} should be nil"
|
74
|
+
end
|
75
|
+
['A(5)'].each do |name|
|
76
|
+
cp = CmdParse.new(name)
|
77
|
+
cp._class_module_chain
|
78
|
+
assert_not_equal(name, cp.result.name,
|
79
|
+
"should not have been able to parse of #{name}")
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
include Trepan::CmdParser
|
84
|
+
def test_method_name
|
85
|
+
# require_relative '../../lib/trepanning'
|
86
|
+
def five; 5 end
|
87
|
+
%w(five RubyVM::InstructionSequence.new Kernel.eval
|
88
|
+
Testing.testing Kernel::eval File.basename).each do |str|
|
89
|
+
meth = meth_for_string(str, binding)
|
90
|
+
assert meth.kind_of?(Method), "#{str} method's class should be Method, not #{meth.class}"
|
91
|
+
end
|
92
|
+
x = File
|
93
|
+
def x.five; 5; end
|
94
|
+
%w(x.basename x.five).each do |str|
|
95
|
+
meth = meth_for_string(str, binding)
|
96
|
+
assert meth.kind_of?(Method), "#{str} method's class should be Method, not #{meth.class}"
|
97
|
+
end
|
98
|
+
%w(Array.map).each do |str|
|
99
|
+
meth = meth_for_string(str, binding)
|
100
|
+
assert meth.kind_of?(UnboundMethod), "#{meth.class}"
|
101
|
+
end
|
102
|
+
%w(O5).each do |str|
|
103
|
+
meth = meth_for_string(str, binding)
|
104
|
+
assert_equal nil, meth, "should have found a method for #{str}"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require_relative '../../app/cmd_parser'
|
4
|
+
|
5
|
+
class TestAppCmdParser < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
@cp = CmdParse.new('', true)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_parse_filename
|
11
|
+
[
|
12
|
+
['filename', 'filename'],
|
13
|
+
['"this is a filename"', 'this is a filename'],
|
14
|
+
['this\ is\ another\ filename', 'this is another filename'],
|
15
|
+
['C\:filename', 'C:filename']
|
16
|
+
].each do |name, expect|
|
17
|
+
@cp.setup_parser(name, true)
|
18
|
+
res = @cp._filename
|
19
|
+
assert_equal(expect, @cp.result)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require_relative '../../app/complete'
|
4
|
+
|
5
|
+
class TestAppUtil < Test::Unit::TestCase
|
6
|
+
include Trepan::Complete
|
7
|
+
def test_complete
|
8
|
+
hash = {'ab' => 1, 'aac' => 2, 'aa' => 3, 'a' => 4}
|
9
|
+
ary = hash.keys.sort
|
10
|
+
[[[], 'b'], [ary, 'a'], [%w(aa aac), 'aa'],
|
11
|
+
[ary, ''], [['ab'], 'ab'], [[], 'abc']].each do |result, prefix|
|
12
|
+
assert_equal(result, complete_token(ary, prefix),
|
13
|
+
"Trouble matching #{ary}.inspect on #{prefix.inspect}")
|
14
|
+
end
|
15
|
+
[[ary, 'a'], [%w(aa aac), 'aa'],
|
16
|
+
[['ab'], 'ab'], [[], 'abc']].each do |result_keys, prefix|
|
17
|
+
result = result_keys.map {|key| [key, hash[key]]}
|
18
|
+
assert_equal(result, complete_token_with_next(hash, prefix),
|
19
|
+
"Trouble matching #{hash}.inspect on #{prefix.inspect}")
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_next_token
|
25
|
+
x = ' now is the time'
|
26
|
+
[[0, [ 5, 'now']],
|
27
|
+
[2, [ 5, 'now']],
|
28
|
+
[5, [ 8, 'is']],
|
29
|
+
[8, [13, 'the']],
|
30
|
+
[9, [13, 'the']],
|
31
|
+
[13, [19, 'time']],
|
32
|
+
[19, [19, '']],
|
33
|
+
].each do |pos, expect|
|
34
|
+
assert_equal expect, next_token(x, pos)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'stringio'
|
4
|
+
require_relative '../../app/condition'
|
5
|
+
|
6
|
+
class TestAppCondition < Test::Unit::TestCase
|
7
|
+
include Trepan::Condition
|
8
|
+
|
9
|
+
def test_basic
|
10
|
+
assert valid_condition?('1+2')
|
11
|
+
old_stderr = $stderr
|
12
|
+
new_stdout = StringIO.new
|
13
|
+
$stderr = new_stdout
|
14
|
+
assert_equal(nil, valid_condition?('1+'),
|
15
|
+
"Should have not been able to parse 1+")
|
16
|
+
$stderr = old_stderr
|
17
|
+
assert_equal(false, new_stdout.string.empty?,
|
18
|
+
"Should have gotten some sort of compile error on stderr")
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require_relative '../../app/file'
|
4
|
+
|
5
|
+
if defined?(SCRIPT_ISEQS__) && SCRIPT_ISEQS__.is_a?(Hash)
|
6
|
+
SCRIPT_ISEQS__.clear
|
7
|
+
else
|
8
|
+
SCRIPT_ISEQS__ = {}
|
9
|
+
end
|
10
|
+
if defined?(ISEQS__) && ISEQS__.is_a?(Hash)
|
11
|
+
ISEQS__.clear
|
12
|
+
else
|
13
|
+
ISEQS__ = {}
|
14
|
+
end
|
15
|
+
|
16
|
+
# To have something to work with.
|
17
|
+
load 'tmpdir.rb'
|
18
|
+
|
19
|
+
class TestAppISEQ < Test::Unit::TestCase
|
20
|
+
include Trepanning
|
21
|
+
|
22
|
+
def test_find_iseqs
|
23
|
+
iseqs = find_iseqs(ISEQS__, "tmpdir")
|
24
|
+
assert_equal(false, iseqs.empty?)
|
25
|
+
iseqs = find_iseqs(ISEQS__, "tmpdir@#{__FILE__}")
|
26
|
+
assert_equal(true, iseqs.empty?)
|
27
|
+
iseqs = find_iseqs(ISEQS__, "tmpdir@tmpdir.rb")
|
28
|
+
assert_equal(false, iseqs.empty?)
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -30,17 +30,25 @@ class TestAppOptions < Test::Unit::TestCase
|
|
30
30
|
assert_equal(orig_cd, @options[:chdir])
|
31
31
|
assert_not_equal('', @stderr.string)
|
32
32
|
assert_equal('', @stdout.string)
|
33
|
+
File.unlink tf.path
|
33
34
|
# FIXME: add test where directory isn't executable.
|
34
35
|
end
|
35
36
|
|
36
37
|
def test_binary_opts
|
37
|
-
%w(nx).each do |name|
|
38
|
+
%w(nx readline).each do |name|
|
38
39
|
setup
|
39
40
|
o = ["--#{name}"]
|
40
41
|
rest = @opts.parse o
|
41
42
|
assert_equal('', @stderr.string)
|
42
43
|
assert_equal(true, @options[name.to_sym])
|
43
44
|
end
|
45
|
+
# --no- options
|
46
|
+
%w(readline).each do |name|
|
47
|
+
o = ["--no-#{name}"]
|
48
|
+
rest = @opts.parse o
|
49
|
+
assert_equal('', @stderr.string)
|
50
|
+
assert_equal(false, @options[name.to_sym])
|
51
|
+
end
|
44
52
|
end
|
45
53
|
|
46
54
|
def test_help_and_version_opts
|
data/test/unit/test-app-util.rb
CHANGED
@@ -0,0 +1,46 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require_relative '../../processor/command/base/cmd'
|
4
|
+
|
5
|
+
class Trepan
|
6
|
+
class Command::Test < Trepan::Command
|
7
|
+
NAME = 'test'
|
8
|
+
CATEGORY = 'testcategory'
|
9
|
+
completion %w(a aa ab ba aac)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class TestBaseCommand < Test::Unit::TestCase
|
14
|
+
|
15
|
+
class MockCmdProcessor
|
16
|
+
# The below functions aren't tested/called, but they are the
|
17
|
+
# methods required by a command and are placeholders for when we
|
18
|
+
# do start testing.
|
19
|
+
def initialize(dbgr)
|
20
|
+
end
|
21
|
+
def confirm(message, default)
|
22
|
+
p ['confirm: ', message, default]
|
23
|
+
end
|
24
|
+
def errmsg(message, opts)
|
25
|
+
p ['err:', message, opts]
|
26
|
+
end
|
27
|
+
def msg(message, opts)
|
28
|
+
p [message, opts]
|
29
|
+
end
|
30
|
+
def msg_nocr(message, opts)
|
31
|
+
p ['nocr: ', message, opts]
|
32
|
+
end
|
33
|
+
def section(message, opts)
|
34
|
+
p ['section: ', message, opts]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def setup
|
39
|
+
@proc = MockCmdProcessor.new(nil)
|
40
|
+
@cmd = Trepan::Command::Test.new(@proc)
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_base_completion
|
44
|
+
assert_equal(%w(aa aac), @cmd.complete('aa'))
|
45
|
+
end
|
46
|
+
end
|
@@ -5,12 +5,12 @@ require_relative '../../processor/main'
|
|
5
5
|
require_relative '../../processor/command/exit'
|
6
6
|
require_relative '../../processor/command/base/subcmd'
|
7
7
|
|
8
|
-
# Mock debugger stub. FIXME: put in
|
8
|
+
# Mock debugger stub. FIXME: put in common helper routine.
|
9
9
|
class Trepan
|
10
10
|
end
|
11
11
|
|
12
12
|
$errors = []
|
13
|
-
class
|
13
|
+
class TestBaseSubCommand < Test::Unit::TestCase
|
14
14
|
|
15
15
|
def setup
|
16
16
|
$errors = []
|
@@ -56,4 +56,13 @@ class TestBaseCommandHelp < Test::Unit::TestCase
|
|
56
56
|
assert_equal('unset', @exit_subcmd.show_onoff(nil))
|
57
57
|
assert_equal('??', @exit_subcmd.show_onoff(5))
|
58
58
|
end
|
59
|
+
|
60
|
+
def test_prefix_set
|
61
|
+
Trepanning::Subcommand.set_name_prefix('/tmp/show_subcmd/foo.rb',
|
62
|
+
self.class)
|
63
|
+
assert_equal('foo', NAME, "should have set NAME")
|
64
|
+
assert_equal('show foo', CMD)
|
65
|
+
assert_equal(%w(show foo), PREFIX)
|
66
|
+
end
|
67
|
+
|
59
68
|
end
|