1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* common.mk : rename yarv-test-[all/each] to compare-test[/-each].

purpose of "compare-test" rule is to compare ruby (trunk) and
matzruby (branches/matzruby) binary in miniruby level.  MATZRUBY
parameter means an path to miniruby of matzruby binary.  to do this
comparison test, you should build matzruby branch.
* yarvtest/yarvtest.rb : fix to use command line option as
command names to be compared.
* yarvtest/runner.rb : remove a debug output.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2007-01-04 11:30:37 +00:00
parent 31d815aacf
commit 3e5b3dac1f
4 changed files with 137 additions and 150 deletions

View file

@ -1,3 +1,16 @@
Thu Jan 4 20:01:29 2007 Koichi Sasada <ko1@atdot.net>
* common.mk : rename yarv-test-[all/each] to compare-test[/-each].
purpose of "compare-test" rule is to compare ruby (trunk) and
matzruby (branches/matzruby) binary in miniruby level. MATZRUBY
parameter means an path to miniruby of matzruby binary. to do this
comparison test, you should build matzruby branch.
* yarvtest/yarvtest.rb : fix to use command line option as
command names to be compared.
* yarvtest/runner.rb : remove a debug output.
Thu Jan 4 19:12:27 2007 Koichi Sasada <ko1@atdot.net> Thu Jan 4 19:12:27 2007 Koichi Sasada <ko1@atdot.net>
* common.mk : fix to use test.rb script in build directory. * common.mk : fix to use test.rb script in build directory.

View file

@ -523,6 +523,7 @@ blockinlining.$(OBJEXT): {$(VPATH)}yarv.h {$(VPATH)}yarvcore.h vm_opts.h
BASERUBY = ruby BASERUBY = ruby
MATZRUBY = ruby
INSNS2VMOPT = $(CPPFLAGS) --srcdir=$(srcdir) INSNS2VMOPT = $(CPPFLAGS) --srcdir=$(srcdir)
@ -559,11 +560,11 @@ incs:
docs: docs:
$(BASERUBY) -I$(srcdir) $(srcdir)/tool/makedocs.rb $(INSNS2VMOPT) $(BASERUBY) -I$(srcdir) $(srcdir)/tool/makedocs.rb $(INSNS2VMOPT)
yarv-test-all: miniruby$(EXEEXT) compare-test: miniruby$(EXEEXT)
$(BASERUBY) -I$(srcdir) $(srcdir)/yarvtest/runner.rb $(OPT) yarv=$(MINIRUBY) ruby=$(BASERUBY) $(BASERUBY) -I$(srcdir) $(srcdir)/yarvtest/runner.rb $(OPT) ruby=$(MINIRUBY) matzruby=$(MATZRUBY)
yarv-test-each: miniruby$(EXEEXT) compare-test-each: miniruby$(EXEEXT)
$(BASERUBY) -I$(srcdir) $(srcdir)/yarvtest/test_$(ITEM).rb $(OPT) yarv=$(MINIRUBY) ruby=$(BASERUBY) $(BASERUBY) -I$(srcdir) $(srcdir)/yarvtest/test_$(ITEM).rb $(OPT) ruby=$(MINIRUBY) matzruby=$(MATZRUBY)
allload: miniruby$(EXEEXT) allload: miniruby$(EXEEXT)
$(MINIRUBY) -I$(srcdir) $(srcdir)/tool/allload.rb `$(BASERUBY) -rrbconfig -e 'print Config::CONFIG["rubylibdir"]'` $(MINIRUBY) -I$(srcdir) $(srcdir)/tool/allload.rb `$(BASERUBY) -rrbconfig -e 'print Config::CONFIG["rubylibdir"]'`

View file

@ -1,10 +1,9 @@
require 'test/unit' require 'test/unit'
if $0 == __FILE__ if $0 == __FILE__
# exit Test::Unit::AutoRunner.run(false, File.dirname($0)) # exit Test::Unit::AutoRunner.run(false, File.dirname($0))
Dir.glob(File.dirname($0) + '/test_*'){|file| Dir.glob(File.dirname($0) + '/test_*'){|file|
p file require file
require file }
} end
end

View file

@ -1,136 +1,110 @@
require 'test/unit' require 'test/unit'
require 'rbconfig'
if defined? YARV_PATCHED require 'optparse'
require 'yarvutil'
if /mswin32/ !~ RUBY_PLATFORM
class YarvTestBase < Test::Unit::TestCase $ruby = './miniruby'
else
def remove_const sym $ruby = 'miniruby'
Object.module_eval{ end
remove_const sym $matzruby = Config::CONFIG['ruby_install_name']
}
end ARGV.each{|opt|
if /\Aruby=(.+)/ =~ opt
def remove_method sym $ruby = $1
Object.module_eval{ elsif /\Amatzruby=(.+)/ =~ opt
undef sym $matzruby = $1
} end
end }
def ae str puts "matzruby: #{`#{$matzruby} -v`}"
# puts str puts "ruby : #{`#{$ruby} -v`}"
# puts YARVUtil.parse(str, $0, 0).disasm
class YarvTestBase < Test::Unit::TestCase
ruby = YARVUtil.eval_in_wrap(str) def initialize *args
yield if block_given? super
yarv = YARVUtil.eval(str) end
yield if block_given?
def remove_const sym
assert_equal(ruby, yarv) Object.module_eval{
end remove_const sym
}
def test_ end
end
def remove_method sym
end Object.module_eval{
undef sym
else }
end
require 'rbconfig'
class YarvTestBase < Test::Unit::TestCase require 'tempfile'
def initialize *args def exec exec_file, program
super dir = []
dir << ENV['RAMDISK'] if ENV['RAMDISK']
if /mswin32/ !~ RUBY_PLATFORM tmpf = Tempfile.new("yarvtest_#{Process.pid}_#{Time.now.to_i}", *dir)
@yarv = './miniruby' tmpf.write program
else tmpf.close
@yarv = 'miniruby' result = `#{exec_file} #{tmpf.path}`
end tmpf.open
@ruby = Config::CONFIG['ruby_install_name'] tmpf.close(true)
end result
end
def remove_const sym
Object.module_eval{ def dump_and_exec exec_file, str
remove_const sym asmstr = <<-EOASMSTR
} iseq = YARVCore::InstructionSequence.compile(<<-'EOS__')
end #{str}
EOS__
def remove_method sym p YARVCore::InstructionSequence.load(iseq.to_a).eval
Object.module_eval{ EOASMSTR
undef sym
} exec(exec_file, asmstr)
end end
require 'tempfile' def exec_ exec_file, program
def exec exec_file, program exec_file.tr!('\\', '/')
dir = [] r = ''
dir << ENV['RAMDISK'] if ENV['RAMDISK'] IO.popen("#{exec_file}", 'r+'){|io|
tmpf = Tempfile.new("yarvtest_#{Process.pid}_#{Time.now.to_i}", *dir) #
tmpf.write program io.write program
tmpf.close io.close_write
result = `#{exec_file} #{tmpf.path}` begin
tmpf.open while line = io.gets
tmpf.close(true) r << line
result # p line
end end
rescue => e
def dump_and_exec exec_file, str # p e
asmstr = <<-EOASMSTR end
iseq = YARVCore::InstructionSequence.compile(<<-'EOS__') }
#{str} r
EOS__ end
p YARVCore::InstructionSequence.load(iseq.to_a).eval
EOASMSTR def ae str
evalstr = %{
exec(exec_file, asmstr) p eval(%q{
end #{str}
})
def exec_ exec_file, program }
exec_file.tr!('\\', '/')
r = '' matzruby = exec($matzruby, evalstr)
IO.popen("#{exec_file}", 'r+'){|io| ruby = exec($ruby, evalstr)
#
io.write program if $DEBUG #|| true
io.close_write puts "matzruby (#$matzruby): #{matzruby}"
begin puts "ruby (#$ruby): #{ruby}"
while line = io.gets end
r << line
# p line assert_equal(ruby.gsub(/\r/, ''), ruby.gsub(/\r/, ''))
end
rescue => e # store/load test
# p e if false # || true
end yarvasm = dump_and_exec($ruby, str)
} assert_equal(ruby.gsub(/\r/, ''), yarvasm.gsub(/\r/, ''))
r end
end end
def ae str def test_
evalstr = %{ end
p eval(%q{ end
#{str}
})
}
ruby = exec(@ruby, evalstr)
yarv = exec(@yarv, evalstr)
if $DEBUG #|| true
puts "yarv (#@yarv): #{yarv}"
puts "ruby (#@ruby): #{ruby}"
end
assert_equal(ruby.gsub(/\r/, ''), yarv.gsub(/\r/, ''))
# store/load test
if false # || true
yarvasm = dump_and_exec(@yarv, str)
assert_equal(ruby.gsub(/\r/, ''), yarvasm.gsub(/\r/, ''))
end
end
def test_
end
end
end