mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
reduce mrb_open calls in mrbgem test
This commit is contained in:
@@ -73,4 +73,4 @@ assert('Array#shuffle!(random)') do
|
||||
ary2.shuffle! Random.new 345
|
||||
|
||||
ary1 != [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] and 10.times { |x| ary1.include? x } and ary1 == ary2
|
||||
end
|
||||
end
|
||||
|
||||
@@ -43,6 +43,10 @@ module MRuby
|
||||
MRuby::Gem.current = self
|
||||
end
|
||||
|
||||
def run_test_in_other_mrb_state?
|
||||
not test_preload.nil? or not test_objs.empty?
|
||||
end
|
||||
|
||||
def cxx_abi_enabled?
|
||||
@cxx_abi_enabled
|
||||
end
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
MRuby.each_target do
|
||||
no_mrb_open_test_gem = []
|
||||
|
||||
gems.each do |g|
|
||||
unless g.run_test_in_other_mrb_state?
|
||||
no_mrb_open_test_gem << g
|
||||
next
|
||||
end
|
||||
|
||||
test_rbobj = g.test_rbireps.ext(exts.object)
|
||||
|
||||
file test_rbobj => g.test_rbireps
|
||||
@@ -100,4 +107,37 @@ MRuby.each_target do
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
no_mrb_open_test = "#{build_dir}/test/no_mrb_open_test"
|
||||
no_mrb_open_test_rbfiles = no_mrb_open_test_gem.reduce([]) { |res, v|
|
||||
res += v.test_rbfiles
|
||||
}
|
||||
file "#{no_mrb_open_test}.o" => "#{no_mrb_open_test}.c"
|
||||
file "#{no_mrb_open_test}.c" => no_mrb_open_test_rbfiles do |t|
|
||||
open(t.name, 'w') do |f|
|
||||
f.puts %Q[/*]
|
||||
f.puts %Q[ * This file contains a test code for following gems:]
|
||||
no_mrb_open_test_gem.each { |g| f.puts %Q[ * #{g.name}] }
|
||||
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 %Q[\#include "mruby.h"]
|
||||
f.puts %Q[\#include "mruby/irep.h"]
|
||||
|
||||
f.puts %Q[]
|
||||
|
||||
mrbc.run f, no_mrb_open_test_rbfiles, "no_mrb_open_gem_test_irep"
|
||||
|
||||
f.puts %Q[]
|
||||
|
||||
f.puts %Q[void no_mrb_open_mrbgem_test(mrb_state *mrb) {]
|
||||
f.puts %Q[ mrb_load_irep(mrb, no_mrb_open_gem_test_irep);]
|
||||
f.puts %Q[}]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
+7
-1
@@ -12,9 +12,11 @@ MRuby.each_target do
|
||||
ass_lib = ass_c.ext(exts.object)
|
||||
|
||||
mrbtest_lib = libfile("#{current_build_dir}/mrbtest")
|
||||
file mrbtest_lib => [mlib, ass_lib, gems.map(&:test_objs), gems.map { |g| g.test_rbireps.ext(exts.object) }].flatten do |t|
|
||||
gem_test_files = gems.select { |g| g.run_test_in_other_mrb_state? }.map { |g| g.test_rbireps.ext(exts.object) }
|
||||
file mrbtest_lib => [mlib, ass_lib, gems.map(&:test_objs), gem_test_files].flatten do |t|
|
||||
archiver.run t.name, t.prerequisites
|
||||
end
|
||||
file mrbtest_lib => "#{build_dir}/test/no_mrb_open_test.o"
|
||||
|
||||
unless build_mrbtest_lib_only?
|
||||
driver_obj = objfile("#{current_build_dir}/driver")
|
||||
@@ -53,12 +55,16 @@ MRuby.each_target do
|
||||
f.puts IO.read(init)
|
||||
mrbc.run f, mrbs, 'mrbtest_irep'
|
||||
gems.each do |g|
|
||||
next unless g.run_test_in_other_mrb_state?
|
||||
f.puts %Q[void GENERATED_TMP_mrb_#{g.funcname}_gem_test(mrb_state *mrb);]
|
||||
end
|
||||
f.puts %Q[void no_mrb_open_mrbgem_test(mrb_state *mrb);]
|
||||
f.puts %Q[void mrbgemtest_init(mrb_state* mrb) {]
|
||||
gems.each do |g|
|
||||
next unless g.run_test_in_other_mrb_state?
|
||||
f.puts %Q[ GENERATED_TMP_mrb_#{g.funcname}_gem_test(mrb);]
|
||||
end
|
||||
f.puts %Q[ no_mrb_open_mrbgem_test(mrb);]
|
||||
f.puts %Q[}]
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user