Commit c6aa87c8 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #2924 from zzak/mruby-test

Extract mrbtest to binary gem
parents e35c3aff 87564dc9
...@@ -26,9 +26,6 @@ load "#{MRUBY_ROOT}/mrblib/mrblib.rake" ...@@ -26,9 +26,6 @@ load "#{MRUBY_ROOT}/mrblib/mrblib.rake"
load "#{MRUBY_ROOT}/tasks/mrbgems.rake" load "#{MRUBY_ROOT}/tasks/mrbgems.rake"
load "#{MRUBY_ROOT}/tasks/libmruby.rake" load "#{MRUBY_ROOT}/tasks/libmruby.rake"
load "#{MRUBY_ROOT}/tasks/mrbgems_test.rake"
load "#{MRUBY_ROOT}/test/mrbtest.rake"
load "#{MRUBY_ROOT}/tasks/benchmark.rake" load "#{MRUBY_ROOT}/tasks/benchmark.rake"
############################## ##############################
...@@ -117,10 +114,12 @@ task :all => depfiles do ...@@ -117,10 +114,12 @@ task :all => depfiles do
end end
desc "run all mruby tests" desc "run all mruby tests"
task :test => ["all"] + MRuby.targets.values.map { |t| t.build_mrbtest_lib_only? ? t.libfile("#{t.build_dir}/test/mrbtest") : t.exefile("#{t.build_dir}/test/mrbtest") } do task :test => ["all"] do
MRuby.each_target do MRuby.each_target do
if gems.find { |v| v.name == 'mruby-test' }
run_test unless build_mrbtest_lib_only? run_test unless build_mrbtest_lib_only?
end end
end
end end
desc "clean all built and in-repo installed artifacts" desc "clean all built and in-repo installed artifacts"
......
...@@ -108,6 +108,16 @@ MRuby::Build.new('host-debug') do |conf| ...@@ -108,6 +108,16 @@ MRuby::Build.new('host-debug') do |conf|
# conf.enable_bintest # conf.enable_bintest
end end
MRuby::Build.new('test') do |conf|
toolchain :gcc
enable_debug
conf.enable_bintest
conf.gembox 'default'
conf.gem :core => "mruby-test"
end
# Define cross build settings # Define cross build settings
# MRuby::CrossBuild.new('32bit') do |conf| # MRuby::CrossBuild.new('32bit') do |conf|
# toolchain :gcc # toolchain :gcc
......
...@@ -4,6 +4,6 @@ MRuby::GemBox.new do |conf| ...@@ -4,6 +4,6 @@ MRuby::GemBox.new do |conf|
Dir.glob("#{root}/mrbgems/mruby-*/mrbgem.rake") do |x| Dir.glob("#{root}/mrbgems/mruby-*/mrbgem.rake") do |x|
g = File.basename File.dirname x g = File.basename File.dirname x
conf.gem :core => g unless g =~ /^mruby-(print|sprintf|bin-debugger)$/ conf.gem :core => g unless g =~ /^mruby-(print|sprintf|bin-debugger|test)$/
end end
end end
MRuby.each_target do MRuby::Gem::Specification.new('mruby-test') do |spec|
gem_table = gems.generate_gem_table self spec.license = 'MIT'
spec.author = 'mruby developers'
spec.summary = 'mruby test'
gems.each do |g| build.bins << 'mrbtest'
spec.add_dependency('mruby-compiler', :core => 'mruby-compiler')
clib = "#{build_dir}/mrbtest.c"
mlib = clib.ext(exts.object)
mrbs = Dir.glob("#{MRUBY_ROOT}/test/t/*.rb")
exec = exefile("#{build.build_dir}/bin/mrbtest")
libmruby = libfile("#{build.build_dir}/lib/libmruby")
libmruby_core = libfile("#{build.build_dir}/lib/libmruby_core")
mrbtest_lib = libfile("#{build_dir}/mrbtest")
mrbtest_objs = []
driver_obj = objfile("#{build_dir}/driver")
driver = "#{spec.dir}/driver.c"
assert_c = "#{build_dir}/assert.c"
assert_rb = "#{MRUBY_ROOT}/test/assert.rb"
assert_lib = assert_c.ext(exts.object)
mrbtest_objs << assert_lib
file assert_lib => assert_c
file assert_c => [build.mrbcfile, assert_rb] do |t|
open(t.name, 'w') do |f|
mrbc.run f, assert_rb, 'mrbtest_assert_irep'
end
end
gem_table = build.gems.generate_gem_table self
build.gems.each do |g|
test_rbobj = g.test_rbireps.ext(exts.object) test_rbobj = g.test_rbireps.ext(exts.object)
g.test_objs << test_rbobj g.test_objs << test_rbobj
dep_list = gems.tsort_dependencies(g.test_dependencies, gem_table).select(&:generate_functions) dep_list = build.gems.tsort_dependencies(g.test_dependencies, gem_table).select(&:generate_functions)
file test_rbobj => g.test_rbireps file test_rbobj => g.test_rbireps
file g.test_rbireps => [g.test_rbfiles].flatten + [File.join(g.dir, 'mrbgem.rake'), g.build.mrbcfile, __FILE__, "#{MRUBY_ROOT}/tasks/mrbgem_spec.rake"] do |t| file g.test_rbireps => [g.test_rbfiles].flatten + [File.join(g.dir, 'mrbgem.rake'), g.build.mrbcfile, "#{MRUBY_ROOT}/tasks/mrbgem_spec.rake"] do |t|
FileUtils.mkdir_p File.dirname(t.name) FileUtils.mkdir_p File.dirname(t.name)
open(t.name, 'w') do |f| open(t.name, 'w') do |f|
g.print_gem_test_header(f) g.print_gem_test_header(f)
...@@ -91,4 +124,51 @@ MRuby.each_target do ...@@ -91,4 +124,51 @@ MRuby.each_target do
end end
end end
end end
build.gems.each do |v|
mrbtest_objs.concat v.test_objs
end
file mrbtest_lib => mrbtest_objs do |t|
build.archiver.run t.name, t.prerequisites
end
unless build.build_mrbtest_lib_only?
file exec => [driver_obj, mlib, mrbtest_lib, libmruby_core, libmruby] do |t|
gem_flags = build.gems.map { |g| g.linker.flags }
gem_flags_before_libraries = build.gems.map { |g| g.linker.flags_before_libraries }
gem_flags_after_libraries = build.gems.map { |g| g.linker.flags_after_libraries }
gem_libraries = build.gems.map { |g| g.linker.libraries }
gem_library_paths = build.gems.map { |g| g.linker.library_paths }
build.linker.run t.name, t.prerequisites, gem_libraries, gem_library_paths, gem_flags, gem_flags_before_libraries
end
end
init = "#{spec.dir}/init_mrbtest.c"
file mlib => clib
file clib => [build.mrbcfile, init] do |t|
_pp "GEN", "*.rb", "#{clib.relative_path}"
FileUtils.mkdir_p File.dirname(clib)
open(clib, 'w') do |f|
f.puts %Q[/*]
f.puts %Q[ * This file contains a list of all]
f.puts %Q[ * test functions.]
f.puts %Q[ *]
f.puts %Q[ * IMPORTANT:]
f.puts %Q[ * This file was generated!]
f.puts %Q[ * All manual changes will get lost.]
f.puts %Q[ */]
f.puts %Q[]
f.puts IO.read(init)
mrbc.run f, mrbs, 'mrbtest_irep'
build.gems.each do |g|
f.puts %Q[void GENERATED_TMP_mrb_#{g.funcname}_gem_test(mrb_state *mrb);]
end
f.puts %Q[void mrbgemtest_init(mrb_state* mrb) {]
build.gems.each do |g|
f.puts %Q[ GENERATED_TMP_mrb_#{g.funcname}_gem_test(mrb);]
end
f.puts %Q[}]
end
end
end end
...@@ -249,7 +249,7 @@ EOS ...@@ -249,7 +249,7 @@ EOS
def run_test def run_test
puts ">>> Test #{name} <<<" puts ">>> Test #{name} <<<"
mrbtest = exefile("#{build_dir}/test/mrbtest") mrbtest = exefile("#{build_dir}/bin/mrbtest")
sh "#{filename mrbtest.relative_path}#{$verbose ? ' -v' : ''}" sh "#{filename mrbtest.relative_path}#{$verbose ? ' -v' : ''}"
puts puts
run_bintest if @enable_bintest run_bintest if @enable_bintest
......
MRuby.each_target do
current_dir = File.dirname(__FILE__).relative_path_from(Dir.pwd)
relative_from_root = File.dirname(__FILE__).relative_path_from(MRUBY_ROOT)
current_build_dir = "#{build_dir}/#{relative_from_root}"
exec = exefile("#{current_build_dir}/mrbtest")
clib = "#{current_build_dir}/mrbtest.c"
mlib = clib.ext(exts.object)
mrbs = Dir.glob("#{current_dir}/t/*.rb")
init = "#{current_dir}/init_mrbtest.c"
ass_c = "#{current_build_dir}/assert.c"
ass_lib = ass_c.ext(exts.object)
mrbtest_lib = libfile("#{current_build_dir}/mrbtest")
mrbtest_objs = [mlib, ass_lib]
gems.each do |v|
mrbtest_objs.concat v.test_objs
end
file mrbtest_lib => mrbtest_objs do |t|
archiver.run t.name, t.prerequisites
end
unless build_mrbtest_lib_only?
driver_obj = objfile("#{current_build_dir}/driver")
file exec => [driver_obj, mrbtest_lib, libfile("#{build_dir}/lib/libmruby")] do |t|
gem_flags = gems.map { |g| g.linker.flags }
gem_flags_before_libraries = gems.map { |g| g.linker.flags_before_libraries }
gem_flags_after_libraries = gems.map { |g| g.linker.flags_after_libraries }
gem_libraries = gems.map { |g| g.linker.libraries }
gem_library_paths = gems.map { |g| g.linker.library_paths }
linker.run t.name, t.prerequisites, gem_libraries, gem_library_paths, gem_flags, gem_flags_before_libraries
end
end
file ass_lib => ass_c
file ass_c => ["#{current_dir}/assert.rb", __FILE__] do |t|
FileUtils.mkdir_p File.dirname t.name
open(t.name, 'w') do |f|
mrbc.run f, [t.prerequisites.first], 'mrbtest_assert_irep'
end
end
file mlib => clib
file clib => [mrbcfile, init, __FILE__] + mrbs do |t|
_pp "GEN", "*.rb", "#{clib.relative_path}"
FileUtils.mkdir_p File.dirname(clib)
open(clib, 'w') do |f|
f.puts %Q[/*]
f.puts %Q[ * This file contains a list of all]
f.puts %Q[ * test functions.]
f.puts %Q[ *]
f.puts %Q[ * IMPORTANT:]
f.puts %Q[ * This file was generated!]
f.puts %Q[ * All manual changes will get lost.]
f.puts %Q[ */]
f.puts %Q[]
f.puts IO.read(init)
mrbc.run f, mrbs, 'mrbtest_irep'
gems.each do |g|
f.puts %Q[void GENERATED_TMP_mrb_#{g.funcname}_gem_test(mrb_state *mrb);]
end
f.puts %Q[void mrbgemtest_init(mrb_state* mrb) {]
gems.each do |g|
f.puts %Q[ GENERATED_TMP_mrb_#{g.funcname}_gem_test(mrb);]
end
f.puts %Q[}]
end
end
end
assert('__FILE__') do assert('__FILE__') do
file = __FILE__ file = __FILE__.split('test/')[1]
assert_true 'test/t/syntax.rb' == file || 'test\t\syntax.rb' == file assert_true 't/syntax.rb' == file || 't\syntax.rb' == file
end end
assert('__LINE__') do assert('__LINE__') do
......
...@@ -38,3 +38,13 @@ MRuby::Build.new('cxx_abi') do |conf| ...@@ -38,3 +38,13 @@ MRuby::Build.new('cxx_abi') do |conf|
build_mrbc_exec build_mrbc_exec
end end
MRuby::Build.new('test') do |conf|
toolchain :gcc
enable_debug
conf.enable_bintest
conf.gembox 'full-core'
conf.gem :core => "mruby-test"
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment