Commit c3122c88 authored by KOBAYASHI Shuji's avatar KOBAYASHI Shuji

Do not raise an exception when bintest fail

- An exception do not raise when mrbtest fail.
- There are no useful informations in exception message and backtrace.
parent ad0a8888
...@@ -29,32 +29,20 @@ print_hint(void) ...@@ -29,32 +29,20 @@ print_hint(void)
printf("mrbtest - Embeddable Ruby Test\n\n"); printf("mrbtest - Embeddable Ruby Test\n\n");
} }
static int
check_error(mrb_state *mrb)
{
/* Error check */
/* $ko_test and $kill_test should be 0 */
mrb_value ko_test = mrb_gv_get(mrb, mrb_intern_lit(mrb, "$ko_test"));
mrb_value kill_test = mrb_gv_get(mrb, mrb_intern_lit(mrb, "$kill_test"));
return mrb_fixnum_p(ko_test) && mrb_fixnum(ko_test) == 0 && mrb_fixnum_p(kill_test) && mrb_fixnum(kill_test) == 0;
}
static int static int
eval_test(mrb_state *mrb) eval_test(mrb_state *mrb)
{ {
/* evaluate the test */ /* evaluate the test */
mrb_funcall(mrb, mrb_top_self(mrb), "report", 0); mrb_value result = mrb_funcall(mrb, mrb_top_self(mrb), "report", 0);
/* did an exception occur? */ /* did an exception occur? */
if (mrb->exc) { if (mrb->exc) {
mrb_print_error(mrb); mrb_print_error(mrb);
mrb->exc = 0; mrb->exc = 0;
return EXIT_FAILURE; return EXIT_FAILURE;
} }
else if (!check_error(mrb)) { else {
return EXIT_FAILURE; return mrb_bool(result) ? EXIT_SUCCESS : EXIT_FAILURE;
} }
return EXIT_SUCCESS;
} }
static void static void
......
...@@ -213,7 +213,7 @@ end ...@@ -213,7 +213,7 @@ end
## ##
# Report the test result and print all assertions # Report the test result and print all assertions
# which were reported broken. # which were reported broken.
def report() def report
t_print("\n") t_print("\n")
$asserts.each do |msg| $asserts.each do |msg|
...@@ -232,6 +232,8 @@ def report() ...@@ -232,6 +232,8 @@ def report()
t_time = Time.now - $test_start t_time = Time.now - $test_start
t_print(" Time: #{t_time.round(2)} seconds\n") t_print(" Time: #{t_time.round(2)} seconds\n")
end end
$ko_test == 0 && $kill_test == 0
end end
## ##
......
...@@ -39,4 +39,4 @@ ARGV.each do |gem| ...@@ -39,4 +39,4 @@ ARGV.each do |gem|
end end
end end
load 'test/report.rb' exit report
report
if $ko_test > 0 or $kill_test > 0
raise "mrbtest failed (KO:#{$ko_test}, Crash:#{$kill_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