diff options
| author | take_cheeze <[email protected]> | 2014-03-10 04:45:28 +0900 |
|---|---|---|
| committer | take_cheeze <[email protected]> | 2014-03-10 04:45:28 +0900 |
| commit | 77fba20480ef7ecfc8e32acd74a7a389d8f5d1a2 (patch) | |
| tree | f2c158988029e5daccb8abf9fc09b6f2bc3eaa37 /tasks | |
| parent | c740a78e5c1eddc8563ec8f6a82e948f93b56493 (diff) | |
| download | mruby-77fba20480ef7ecfc8e32acd74a7a389d8f5d1a2.tar.gz mruby-77fba20480ef7ecfc8e32acd74a7a389d8f5d1a2.zip | |
reduce mrb_open calls in mrbgem test
Diffstat (limited to 'tasks')
| -rw-r--r-- | tasks/mrbgem_spec.rake | 4 | ||||
| -rw-r--r-- | tasks/mrbgems_test.rake | 40 |
2 files changed, 44 insertions, 0 deletions
diff --git a/tasks/mrbgem_spec.rake b/tasks/mrbgem_spec.rake index daf0bec3a..60d6672f0 100644 --- a/tasks/mrbgem_spec.rake +++ b/tasks/mrbgem_spec.rake @@ -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 diff --git a/tasks/mrbgems_test.rake b/tasks/mrbgems_test.rake index bad2d1a12..c66db9bdd 100644 --- a/tasks/mrbgems_test.rake +++ b/tasks/mrbgems_test.rake @@ -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 |
