summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--test/Makefile27
-rw-r--r--test/report.rb4
3 files changed, 31 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 797f98917..8a76394ee 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,5 +22,6 @@ cscope.out
/test/mrbtest
/test/mrbtest.c
/test/*.*tmp
+/test/mrubytest.*
CMakeFiles
CMakeCache.txt
diff --git a/test/Makefile b/test/Makefile
index 18bc79b5a..3df07b280 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -16,6 +16,13 @@ ASSLIB := $(BASEDIR)/assert.rb
MRBS := $(BASEDIR)/t/*.rb
OBJS := driver.o $(MLIB)
+# for mruby/mrbc test
+REPLIB := $(BASEDIR)/report.rb
+TESTRB := mrubytest.rb
+TESTMRB := mrubytest.mrb
+TESTRB_REP := mrubytest.rb.report
+TESTMRB_REP := mrubytest.mrb.report
+
# libraries, includes
LIBS = -lm
INCLUDES = -I$(BASEDIR)/../src -I$(BASEDIR)/../include
@@ -43,9 +50,11 @@ endif
# mruby compiler and test driver
ifeq ($(OS),Windows_NT)
MRBC = ../bin/mrbc.exe
+MRUBY= ../bin/mruby.exe
EXE := $(TARGET).exe
else
MRBC = ../bin/mrbc
+MRUBY= ../bin/mruby
EXE := $(TARGET)
endif
@@ -54,8 +63,16 @@ endif
# generic build targets, rules
.PHONY : test
-all : $(EXE)
+all : $(EXE) $(MRUBY) $(TESTRB) $(TESTMRB)
+ @echo "# exec mrbtest"
./$(EXE)
+ @echo
+ @echo "# exec mruby test with ruby script"
+ @($(MRUBY) $(TESTRB) > $(TESTRB_REP) && echo "mrubytest.rb success.") || $(CAT) $(TESTRB_REP)
+ @echo
+ @echo "# exec mruby test with mrb file"
+ @($(MRUBY) -b $(TESTMRB) > $(TESTMRB_REP) && echo "mrubytest.mrb success.") || $(CAT) $(TESTMRB_REP)
+ @echo
# executable constructed using linker from object files
$(EXE) : $(OBJS) $(LIBR)
@@ -75,8 +92,16 @@ $(CLIB) : $(RLIB) $(MRBC) $(INIT)
$(RLIB) : $(ASSLIB) $(MRBS)
$(CAT) $(ASSLIB) $(MRBS) > $@
+# Compile mrb file from mruby source
+$(TESTMRB) : $(MRBC) $(TESTRB)
+ $(MRBC) $(TESTRB)
+
+$(TESTRB) : $(ASSLIB) $(MRBS) $(REPLIB)
+ $(CAT) $(ASSLIB) $(MRBS) $(REPLIB) > $@
+
# clean up
.PHONY : clean
clean :
@echo "make: removing targets, objects and depend files of `pwd`"
-$(RM_F) $(MLIB) $(CLIB) $(RLIB) $(DLIB) $(DEPLIB) $(OBJS) $(EXE)
+ -$(RM_F) $(TESTRB) $(TESTMRB) $(TESTRB_REP) $(TESTMRB_REP)
diff --git a/test/report.rb b/test/report.rb
new file mode 100644
index 000000000..fb77fd0aa
--- /dev/null
+++ b/test/report.rb
@@ -0,0 +1,4 @@
+report
+if $ko_test > 0 or $kill_test > 0
+ raise "mrbtest failed (KO:#{$ko_test}, Crash:#{$kill_test})"
+end