From 7080f5d681c238138e11009bc16cb2b4144e5611 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Tue, 16 Mar 2010 04:07:38 +0000 Subject: [PATCH] Use ctest to run unit tests. run "make test" to run them. Note, anything "use"ing another file or loading a module will fail. Need to come up with some cross platform mechanism for specifying include dirs to solve this. Current thought: using environment variables "CHAI_USE_PATH" and "CHAI_MODULE_PATH" --- CMakeLists.txt | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ec158c..69eab0c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,8 @@ project(chaiscript) FIND_LIBRARY(READLINE_LIBRARY NAMES readline PATH /usr/lib /usr/local/lib /opt/local/lib) +enable_testing() + MESSAGE(STATUS "Detecting readline support") if (READLINE_LIBRARY) MESSAGE(STATUS "Found: ${READLINE_LIBRARY}") @@ -25,21 +27,33 @@ include_directories(include) find_package(Boost 1.36.0 COMPONENTS thread) -if (Boost_FOUND) - include_directories(${Boost_INCLUDE_DIRS}) - add_executable(chaiscript_eval src/main.cpp) - #add_executable(dispatchkit_test contrib/test/dispatchkit_test.cpp) - target_link_libraries(chaiscript_eval dl ${Boost_LIBRARIES} ${READLINE_LIB}) +if (NOT Boost_FOUND) + message(FATAL_ERROR "Can not find Boost") +endif(NOT Boost_FOUND) - add_library(test MODULE src/test_module.cpp) - target_link_libraries(test ${Boost_LIBRARIES}) - add_library(stl_extra MODULE src/stl_extra.cpp) - target_link_libraries(stl_extra ${Boost_LIBRARIES}) - install(TARGETS chaiscript_eval DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/bin) +include_directories(${Boost_INCLUDE_DIRS}) +add_executable(chaiscript_eval src/main.cpp) +#add_executable(dispatchkit_test contrib/test/dispatchkit_test.cpp) +target_link_libraries(chaiscript_eval dl ${Boost_LIBRARIES} ${READLINE_LIB}) + +add_library(test MODULE src/test_module.cpp) +target_link_libraries(test ${Boost_LIBRARIES}) + +add_library(stl_extra MODULE src/stl_extra.cpp) +target_link_libraries(stl_extra ${Boost_LIBRARIES}) + +file(GLOB UNIT_TESTS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/unittests/ ${CMAKE_CURRENT_SOURCE_DIR}/unittests/*.chai) + + + +foreach(filename ${UNIT_TESTS}) + message(STATUS "Adding test ${filename}") + add_test(${filename} chaiscript_eval ${CMAKE_CURRENT_SOURCE_DIR}/unittests/unit_test.inc ${CMAKE_CURRENT_SOURCE_DIR}/unittests/${filename}) +endforeach(filename) + + +install(TARGETS chaiscript_eval DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/bin) -else(Boost_FOUND) - message(FATAL_ERROR "Can not find Boost") -endif(Boost_FOUND)