Commit f209f781 authored by KOBAYASHI Shuji's avatar KOBAYASHI Shuji

Integrate `init_mrbtest.c` to `driver.c` in `mruby-test` mrbgem

- `mrbgemtest_init()` is needed if `DISABLE_GEMS` is enabled because core
  tests are run as part of `mruby-test` mrbgem (moreover, `DISABLE_GEMS` is
  disabled when `enable_test` is used in build config).
- For the same reason `mrb_open_core()` etc for core tests is unneeded.
parent 5cc27734
......@@ -18,8 +18,9 @@
#include <mruby/variable.h>
#include <mruby/array.h>
void
mrb_init_mrbtest(mrb_state *);
extern const uint8_t mrbtest_assert_irep[];
void mrbgemtest_init(mrb_state* mrb);
/* Print a short remark for the user */
static void
......@@ -167,7 +168,8 @@ main(int argc, char **argv)
}
mrb_init_test_driver(mrb, verbose);
mrb_init_mrbtest(mrb);
mrb_load_irep(mrb, mrbtest_assert_irep);
mrbgemtest_init(mrb);
ret = eval_test(mrb);
mrb_close(mrb);
......
#include <stdlib.h>
#include <mruby.h>
#include <mruby/irep.h>
#include <mruby/variable.h>
extern const uint8_t mrbtest_assert_irep[];
void mrbgemtest_init(mrb_state* mrb);
void mrb_init_test_driver(mrb_state* mrb, mrb_bool verbose);
void mrb_t_pass_result(mrb_state *mrb_dst, mrb_state *mrb_src);
void
mrb_init_mrbtest(mrb_state *mrb)
{
mrb_state *core_test;
mrb_load_irep(mrb, mrbtest_assert_irep);
core_test = mrb_open_core(mrb_default_allocf, NULL);
if (core_test == NULL) {
fprintf(stderr, "Invalid mrb_state, exiting %s", __FUNCTION__);
exit(EXIT_FAILURE);
}
mrb_init_test_driver(core_test, mrb_test(mrb_gv_get(mrb, mrb_intern_lit(mrb, "$mrbtest_verbose"))));
mrb_load_irep(core_test, mrbtest_assert_irep);
mrb_t_pass_result(mrb, core_test);
#ifndef DISABLE_GEMS
mrbgemtest_init(mrb);
#endif
if (mrb->exc) {
mrb_print_error(mrb);
mrb_close(mrb);
exit(EXIT_FAILURE);
}
mrb_close(core_test);
}
......@@ -144,8 +144,6 @@ MRuby::Gem::Specification.new('mruby-test') do |spec|
end
end
init = "#{spec.dir}/init_mrbtest.c"
# store the last gem selection and make the re-build
# of the test gem depending on a change to the gem
# selection
......@@ -164,7 +162,7 @@ MRuby::Gem::Specification.new('mruby-test') do |spec|
file clib => active_gems_path if active_gem_list != current_gem_list
file mlib => clib
file clib => [init, build.mrbcfile, __FILE__] do |_t|
file clib => [build.mrbcfile, __FILE__] do |_t|
_pp "GEN", "*.rb", "#{clib.relative_path}"
FileUtils.mkdir_p File.dirname(clib)
open(clib, 'w') do |f|
......@@ -177,7 +175,8 @@ MRuby::Gem::Specification.new('mruby-test') do |spec|
f.puts %Q[ * All manual changes will get lost.]
f.puts %Q[ */]
f.puts %Q[]
f.puts IO.read(init)
f.puts %Q[struct mrb_state;]
f.puts %Q[typedef struct mrb_state mrb_state;]
build.gems.each do |g|
f.puts %Q[void GENERATED_TMP_mrb_#{g.funcname}_gem_test(mrb_state *mrb);]
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