tasks/test.rake in webroar-0.2.6 vs tasks/test.rake in webroar-0.3.0

- old
+ new

@@ -64,13 +64,23 @@ test_obj.each { |obj_file,src_file| cmd = "#{COMPILER} #$inc_flags #$CFLAGS #$flags #$debug_flags -c #{src_file} -o #{obj_file}" sh cmd } + tests_obj_files = FileList[File.join(TEST_OBJ_DIR,"*.o")] - out_file = File.join(UNIT_TEST_DIR, 'test_ext.so') - cmd = "#{COMPILER} #$libs #{tests_obj_files} -shared -o #{out_file}" + + if RUBY_PLATFORM =~ /darwin/ + out_file = File.join(UNIT_TEST_DIR, 'test_ext.dylib') + lib_flags = $libs + $LIBS + lib_flags += " #{ENV['library_flags']}" if ENV['library_flags'] + cmd = "#{COMPILER} #$libs #{tests_obj_files} -dynamiclib -o #{out_file}" + else + out_file = File.join(UNIT_TEST_DIR, 'test_ext.so') + cmd = "#{COMPILER} #$libs #{tests_obj_files} -shared -o #{out_file}" + end + sh cmd end desc "Build and executes unit test" task :unit_test do @@ -85,12 +95,21 @@ puts "Done." system("rake clean >>#{File.join(UNIT_TEST_DIR,'testcases.log')} 2>>#{File.join(UNIT_TEST_DIR,'testcases.log')}") puts "Running test cases ..." puts "" $LOAD_PATH.unshift(UNIT_TEST_DIR) - require 'test_ext' Dir.chdir(UNIT_TEST_DIR) - Test::Test.run + + if RUBY_PLATFORM =~ /darwin/ + require 'dl' + dl = DL::dlopen(File.join(UNIT_TEST_DIR,'test_ext.dylib')) + run_test = dl.sym("run_test",'0') + run_test.call() + else + require 'test_ext' + Test::Test.run + end + puts "\nPlease refer 'test\\unit\\test.log' for the detailed report." else puts "Compilation error. Please refer 'testcases.log' for details." end Dir.chdir(WEBROAR_ROOT)