Avoid using C struct dump for test Ruby code.

Files under `test/t` and `mrbgem/*/test` are for tests, not for actual
execution. So symbols in those files need not to be pre-allocated. This
change slightly reduce the memory consumption.
parent 82046ff2
......@@ -108,14 +108,14 @@ mkdir_p "#{MRUBY_ROOT}/build"
cfiles = (
Dir.glob("#{MRUBY_ROOT}/src/*.c")+
Dir.glob("#{MRUBY_ROOT}/mrbgems/**/*.c")+
Dir.glob("#{MRUBY_ROOT}/build/repos/**/{src,test,core}/*.c")
Dir.glob("#{MRUBY_ROOT}/build/repos/**/{src,core}/*.c")
).uniq
rbfiles = (
Dir.glob("#{MRUBY_ROOT}/{mrblib,test,test/t}/**/*.rb")+
Dir.glob("#{MRUBY_ROOT}/mrbgems/*/{mrblib,test}/**/*.rb")+
Dir.glob("#{MRUBY_ROOT}/build/repos/**/{mrblib,test}/**/*.rb")
Dir.glob("#{MRUBY_ROOT}/mrblib/**/*.rb")+
Dir.glob("#{MRUBY_ROOT}/mrbgems/*/mrblib/**/*.rb")+
Dir.glob("#{MRUBY_ROOT}/build/repos/**/mrblib/**/*.rb")
).uniq
psfiles = Dir.glob("#{MRUBY_ROOT}/{mrblib,mrbgems,test,build/repos}/**/presym")
psfiles = Dir.glob("#{MRUBY_ROOT}/{mrblib,mrbgems,build/repos}/**/presym")
symbols = []
psfiles.each do |file|
symbols += File.readlines(file).grep_v(/^# /)
......
......@@ -310,16 +310,16 @@ module MRuby
def initialize(build)
super
@command = nil
@compile_options = "-S -B%{funcname} -o-"
@compile_options = "-B%{funcname} -o-"
end
def run(out, infiles, funcname)
def run(out, infiles, funcname, cdump = true)
@command ||= @build.mrbcfile
infiles = [infiles].flatten
infiles.each do |f|
_pp "MRBC", f.relative_path, nil, :indent => 2
end
cmd = %Q["#{filename @command}" #{@compile_options % {:funcname => funcname}} #{filename(infiles).map{|f| %Q["#{f}"]}.join(' ')}]
cmd = %Q["#{filename @command}" #{cdump ? "-S" : ""} #{@compile_options % {:funcname => funcname}} #{filename(infiles).map{|f| %Q["#{f}"]}.join(' ')}]
puts cmd if Rake.verbose
IO.popen(cmd, 'r+') do |io|
out.puts io.read
......
......@@ -18,7 +18,7 @@
#include <mruby/variable.h>
#include <mruby/array.h>
extern const struct RProc mrbtest_assert_proc[];
extern const uint8_t mrbtest_assert_irep[];
void mrbgemtest_init(mrb_state* mrb);
void mrb_init_test_vformat(mrb_state* mrb);
......@@ -300,7 +300,7 @@ main(int argc, char **argv)
}
mrb_init_test_driver(mrb, verbose);
mrb_load_proc(mrb, mrbtest_assert_proc);
mrb_load_irep(mrb, mrbtest_assert_irep);
mrbgemtest_init(mrb);
ret = eval_test(mrb);
mrb_close(mrb);
......
......@@ -28,7 +28,7 @@ MRuby::Gem::Specification.new('mruby-test') do |spec|
file assert_c => [assert_rb, build.mrbcfile] do |t|
mkdir_p File.dirname(t.name)
open(t.name, 'w') do |f|
mrbc.run f, assert_rb, 'mrbtest_assert_proc'
mrbc.run f, assert_rb, 'mrbtest_assert_irep', false
end
end
......@@ -56,12 +56,12 @@ MRuby::Gem::Specification.new('mruby-test') do |spec|
f.puts %Q[ * All manual changes will get lost.]
f.puts %Q[ */]
if test_preload.nil?
f.puts %Q[extern const struct RProc mrbtest_assert_proc[];]
f.puts %Q[extern const uint8_t mrbtest_assert_irep[];]
else
g.build.mrbc.run f, test_preload, "gem_test_#{g.funcname}_preload"
g.build.mrbc.run f, test_preload, "gem_test_irep_#{g.funcname}_preload", false
end
g.test_rbfiles.flatten.each_with_index do |rbfile, i|
g.build.mrbc.run f, rbfile, "gem_test_#{g.funcname}_#{i}_proc"
g.build.mrbc.run f, rbfile, "gem_test_irep_#{g.funcname}_#{i}", false
end
f.puts %Q[void mrb_#{g.funcname}_gem_test(mrb_state *mrb);] unless g.test_objs.empty?
dep_list.each do |d|
......@@ -90,9 +90,9 @@ MRuby::Gem::Specification.new('mruby-test') do |spec|
end
f.puts %Q[ mrb_init_test_driver(mrb2, mrb_test(mrb_gv_get(mrb, mrb_intern_lit(mrb, "$mrbtest_verbose"))));]
if test_preload.nil?
f.puts %Q[ mrb_load_proc(mrb2, mrbtest_assert_proc);]
f.puts %Q[ mrb_load_irep(mrb2, mrbtest_assert_irep);]
else
f.puts %Q[ mrb_load_proc(mrb2, gem_test_#{g.funcname}_preload);]
f.puts %Q[ mrb_load_irep(mrb2, gem_test_irep_#{g.funcname}_preload);]
end
f.puts %Q[ if (mrb2->exc) {]
f.puts %Q[ mrb_print_error(mrb2);]
......@@ -113,7 +113,7 @@ MRuby::Gem::Specification.new('mruby-test') do |spec|
f.puts %Q[ mrb_#{g.funcname}_gem_test(mrb2);] if g.custom_test_init?
f.puts %Q[ mrb_load_proc(mrb2, gem_test_#{g.funcname}_#{i}_proc);]
f.puts %Q[ mrb_load_irep(mrb2, gem_test_irep_#{g.funcname}_#{i});]
f.puts %Q[ ]
f.puts %Q[ mrb_t_pass_result(mrb, mrb2);]
......
# List of symbols that cannot be detected by Rakefile
# Those symbols are not defined (to cause exceptions)
doesNotExistAsAMethodNameForVerySure
UnknownConstant
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