summaryrefslogtreecommitdiff
path: root/yarvtest
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-01-04 11:30:37 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-01-04 11:30:37 +0000
commit3e5b3dac1f3b847161fa914f3e4cb3e85198c4a4 (patch)
treea0581d998af87a9793fb346867cc83a5557f88d9 /yarvtest
parent31d815aacf57d5d61d9e04683c6c4b9a36a4fbee (diff)
* 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
Diffstat (limited to 'yarvtest')
-rw-r--r--yarvtest/runner.rb19
-rw-r--r--yarvtest/yarvtest.rb246
2 files changed, 119 insertions, 146 deletions
diff --git a/yarvtest/runner.rb b/yarvtest/runner.rb
index 25b813e99c..003967b804 100644
--- a/yarvtest/runner.rb
+++ b/yarvtest/runner.rb
@@ -1,10 +1,9 @@
-require 'test/unit'
-
-if $0 == __FILE__
- # exit Test::Unit::AutoRunner.run(false, File.dirname($0))
- Dir.glob(File.dirname($0) + '/test_*'){|file|
- p file
- require file
- }
-end
-
+require 'test/unit'
+
+if $0 == __FILE__
+ # exit Test::Unit::AutoRunner.run(false, File.dirname($0))
+ Dir.glob(File.dirname($0) + '/test_*'){|file|
+ require file
+ }
+end
+
diff --git a/yarvtest/yarvtest.rb b/yarvtest/yarvtest.rb
index 906af727b4..20085efe19 100644
--- a/yarvtest/yarvtest.rb
+++ b/yarvtest/yarvtest.rb
@@ -1,136 +1,110 @@
-require 'test/unit'
-
-if defined? YARV_PATCHED
-require 'yarvutil'
-
-class YarvTestBase < Test::Unit::TestCase
-
- def remove_const sym
- Object.module_eval{
- remove_const sym
- }
- end
-
- def remove_method sym
- Object.module_eval{
- undef sym
- }
- end
-
- def ae str
- # puts str
- # puts YARVUtil.parse(str, $0, 0).disasm
-
- ruby = YARVUtil.eval_in_wrap(str)
- yield if block_given?
-
- yarv = YARVUtil.eval(str)
- yield if block_given?
-
- assert_equal(ruby, yarv)
- end
-
- def test_
- end
-
-end
-
-else
-
-require 'rbconfig'
-class YarvTestBase < Test::Unit::TestCase
- def initialize *args
- super
-
- if /mswin32/ !~ RUBY_PLATFORM
- @yarv = './miniruby'
- else
- @yarv = 'miniruby'
- end
- @ruby = Config::CONFIG['ruby_install_name']
- end
-
- def remove_const sym
- Object.module_eval{
- remove_const sym
- }
- end
-
- def remove_method sym
- Object.module_eval{
- undef sym
- }
- end
-
- require 'tempfile'
- def exec exec_file, program
- dir = []
- dir << ENV['RAMDISK'] if ENV['RAMDISK']
- tmpf = Tempfile.new("yarvtest_#{Process.pid}_#{Time.now.to_i}", *dir)
- tmpf.write program
- tmpf.close
- result = `#{exec_file} #{tmpf.path}`
- tmpf.open
- tmpf.close(true)
- result
- end
-
- def dump_and_exec exec_file, str
- asmstr = <<-EOASMSTR
- iseq = YARVCore::InstructionSequence.compile(<<-'EOS__')
- #{str}
- EOS__
- p YARVCore::InstructionSequence.load(iseq.to_a).eval
- EOASMSTR
-
- exec(exec_file, asmstr)
- end
-
- def exec_ exec_file, program
- exec_file.tr!('\\', '/')
- r = ''
- IO.popen("#{exec_file}", 'r+'){|io|
- #
- io.write program
- io.close_write
- begin
- while line = io.gets
- r << line
- # p line
- end
- rescue => e
- # p e
- end
- }
- r
- end
-
- def ae str
- evalstr = %{
- p eval(%q{
- #{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
+require 'test/unit'
+require 'rbconfig'
+require 'optparse'
+
+if /mswin32/ !~ RUBY_PLATFORM
+ $ruby = './miniruby'
+else
+ $ruby = 'miniruby'
+end
+$matzruby = Config::CONFIG['ruby_install_name']
+
+ARGV.each{|opt|
+ if /\Aruby=(.+)/ =~ opt
+ $ruby = $1
+ elsif /\Amatzruby=(.+)/ =~ opt
+ $matzruby = $1
+ end
+}
+
+puts "matzruby: #{`#{$matzruby} -v`}"
+puts "ruby : #{`#{$ruby} -v`}"
+
+class YarvTestBase < Test::Unit::TestCase
+ def initialize *args
+ super
+
+ end
+
+ def remove_const sym
+ Object.module_eval{
+ remove_const sym
+ }
+ end
+
+ def remove_method sym
+ Object.module_eval{
+ undef sym
+ }
+ end
+
+ require 'tempfile'
+ def exec exec_file, program
+ dir = []
+ dir << ENV['RAMDISK'] if ENV['RAMDISK']
+ tmpf = Tempfile.new("yarvtest_#{Process.pid}_#{Time.now.to_i}", *dir)
+ tmpf.write program
+ tmpf.close
+ result = `#{exec_file} #{tmpf.path}`
+ tmpf.open
+ tmpf.close(true)
+ result
+ end
+
+ def dump_and_exec exec_file, str
+ asmstr = <<-EOASMSTR
+ iseq = YARVCore::InstructionSequence.compile(<<-'EOS__')
+ #{str}
+ EOS__
+ p YARVCore::InstructionSequence.load(iseq.to_a).eval
+ EOASMSTR
+
+ exec(exec_file, asmstr)
+ end
+
+ def exec_ exec_file, program
+ exec_file.tr!('\\', '/')
+ r = ''
+ IO.popen("#{exec_file}", 'r+'){|io|
+ #
+ io.write program
+ io.close_write
+ begin
+ while line = io.gets
+ r << line
+ # p line
+ end
+ rescue => e
+ # p e
+ end
+ }
+ r
+ end
+
+ def ae str
+ evalstr = %{
+ p eval(%q{
+ #{str}
+ })
+ }
+
+ matzruby = exec($matzruby, evalstr)
+ ruby = exec($ruby, evalstr)
+
+ if $DEBUG #|| true
+ puts "matzruby (#$matzruby): #{matzruby}"
+ puts "ruby (#$ruby): #{ruby}"
+ end
+
+ assert_equal(ruby.gsub(/\r/, ''), ruby.gsub(/\r/, ''))
+
+ # store/load test
+ if false # || true
+ yarvasm = dump_and_exec($ruby, str)
+ assert_equal(ruby.gsub(/\r/, ''), yarvasm.gsub(/\r/, ''))
+ end
+ end
+
+ def test_
+ end
+end