diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/CMakeLists.txt | 42 | ||||
| -rw-r--r-- | test/Makefile | 129 | ||||
| -rw-r--r-- | test/mrbtest.rake | 32 |
3 files changed, 32 insertions, 171 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt deleted file mode 100644 index 45031fc72..000000000 --- a/test/CMakeLists.txt +++ /dev/null @@ -1,42 +0,0 @@ -# build standalone mrbtest runner containing all *.rb tests - -if(NOT CMAKE_CROSSCOMPILING) - - file(GLOB MRBTEST_SRC_RB "assert.rb" "t/*.rb") - - # generate a single rb file from all existing test *.rb - add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/mrbtest.rbtmp" - DEPENDS xpcat - COMMAND xpcat -o "${CMAKE_CURRENT_BINARY_DIR}/mrbtest.rbtmp" ${MRBTEST_SRC_RB} - ) - - # mruby compile and generate C byte array representation - add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/mrbtest.ctmp" - DEPENDS mrbc "${CMAKE_CURRENT_BINARY_DIR}/mrbtest.rbtmp" - COMMAND mrbc -Bmrbtest_irep -o"${CMAKE_CURRENT_BINARY_DIR}/mrbtest.ctmp" - "${CMAKE_CURRENT_BINARY_DIR}/mrbtest.rbtmp" - ) - - # aggregate mruby's *.rb test files as a single C file - add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/mrbtest.c" - DEPENDS xpcat init_mrbtest.c "${CMAKE_CURRENT_BINARY_DIR}/mrbtest.ctmp" - COMMAND xpcat -o "${CMAKE_CURRENT_BINARY_DIR}/mrbtest.c" - "${CMAKE_CURRENT_SOURCE_DIR}/init_mrbtest.c" - "${CMAKE_CURRENT_BINARY_DIR}/mrbtest.ctmp" - ) - - add_executable(mrbtest - EXCLUDE_FROM_ALL - "${CMAKE_CURRENT_SOURCE_DIR}/driver.c" - "${CMAKE_CURRENT_BINARY_DIR}/mrbtest.c" - ) - target_link_libraries(mrbtest libmruby_static ${MRUBY_LIBS}) - - add_custom_target(test - DEPENDS mrbtest - COMMAND "${CMAKE_CURRENT_BINARY_DIR}/mrbtest" - ) - -endif() - -# vim: ts=2 sts=2 sw=2 et diff --git a/test/Makefile b/test/Makefile deleted file mode 100644 index 95690a60b..000000000 --- a/test/Makefile +++ /dev/null @@ -1,129 +0,0 @@ -# Makefile description. -# basic build file for the mruby testing environment mrbtest - -# project-specific macros -# extension of the executable-file is modifiable(.exe .out ...) -MRUBY_ROOT := .. -BASEDIR = . -TARGET := mrbtest -LIBR := ../lib/libmruby.a - -ifeq ($(strip $(ENABLE_GEMS)),) - # by default GEMs are deactivated - ENABLE_GEMS = false -endif - -ifeq ($(ENABLE_GEMS),false) - GEM_ARCHIVE_FILES = -else - GEMDIR := ../mrbgems - GEMDLIB := $(GEMDIR)/g/mrbgemtest.ctmp - MAKEFILE_GEM_LIST := $(MRUBY_ROOT)/mrbgems/g/MakefileGemList - ifeq ($(wildcard $(MAKEFILE_GEM_LIST)),) - GEM_ARCHIVE_FILES = - else - include $(MAKEFILE_GEM_LIST) - endif -endif - -MLIB := $(TARGET).o -CLIB := $(TARGET).c -INIT := init_$(TARGET).c -DLIB := $(TARGET).ctmp -RLIB := $(TARGET).rbtmp -DEPLIB := $(TARGET).d driver.d -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 - -ifeq ($(strip $(COMPILE_MODE)),) - # default compile option - COMPILE_MODE = debug -endif - -ALL_CFLAGS = -Wall -Werror-implicit-function-declaration $(CFLAGS) -ifeq ($(OS),Windows_NT) - MAKE_FLAGS = CC=$(CC) LL=$(LL) ALL_CFLAGS='$(ALL_CFLAGS)' LDFLAGS='$(LDFLAGS)' -else - MAKE_FLAGS = CC='$(CC)' LL='$(LL)' ALL_CFLAGS='$(ALL_CFLAGS)' LDFLAGS='$(LDFLAGS)' -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 - -RAKE = ../minirake - - -############################## -# generic build targets, rules - -.PHONY : test -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) : generate-mrbgems-test $(OBJS) $(LIBR) $(GEM_ARCHIVE_FILES) - $(LL) -o $@ $(LDFLAGS) $(OBJS) $(LIBR) $(GEM_ARCHIVE_FILES) $(LIBS) - -generate-mrbgems-test : -ifeq ($(ENABLE_GEMS),true) - @$(RAKE) mrbgems_prepare_test -endif - --include $(OBJS:.o=.d) - -# objects compiled from source -$(OBJS) : %.o : %.c - $(CC) $(ALL_CFLAGS) -MMD $(INCLUDES) -c $< -o $@ - -# Compile C source from merged mruby source -$(CLIB) : $(DLIB) $(INIT) $(GEMDLIB) - $(CAT) $(INIT) $(DLIB) $(GEMDLIB) > $@ - -$(DLIB) : $(RLIB) $(MRBC) - $(MRBC) -Bmrbtest_irep -o$@ $(RLIB) - -# merge mruby sources -$(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/mrbtest.rake b/test/mrbtest.rake new file mode 100644 index 000000000..1d416df2c --- /dev/null +++ b/test/mrbtest.rake @@ -0,0 +1,32 @@ +dir = File.dirname(__FILE__).sub(%r|^\./|, '') + +MRuby.each_target do + exec = exefile("#{build_dir}/#{dir}/mrbtest") + clib = "#{build_dir}/#{dir}/mrbtest.c" + mlib = clib.ext('o') + mrbs = Dir.glob("#{dir}/t/*.rb") + init = "#{dir}/init_mrbtest.c" + asslib = "#{dir}/assert.rb" + + objs = ["#{build_dir}/#{dir}/driver.o", mlib] + + file exec => objs + gems.map{ |g| g.testlib } + ["#{build_dir}/lib/libmruby.a"] do |t| + link t.name, t.prerequisites, [], gems.map { |g| g.mruby_libs } + end + + file mlib => [clib] + file clib => [exefile("#{build_dir}/bin/mrbc"), init, asslib] + mrbs do |t| + open(clib, 'w') do |f| + f.puts File.read(init) + compile_mruby f, [asslib] + mrbs, 'mrbtest_irep' + gems.each do |g| + f.puts "void GENERATED_TMP_mrb_#{g.funcname}_gem_test(mrb_state *mrb);" + end + f.puts "void mrbgemtest_init(mrb_state* mrb) {" + gems.each do |g| + f.puts " GENERATED_TMP_mrb_#{g.funcname}_gem_test(mrb);" + end + f.puts "}" + end + end +end
\ No newline at end of file |
