changed: move IFEM testing macros to separate file
fixes issues encountered while compiling library standalone git-svn-id: http://svn.sintef.no/trondheim/IFEM/trunk@2944 e10b68d5-8a6e-419e-a041-bce267b0401d
This commit is contained in:
@@ -113,6 +113,7 @@ add_dependencies(doc lib_doc)
|
||||
if(IFEM_AS_SUBMODULE OR IFEM_COMMON_APP_BUILD)
|
||||
set(TEST_APPS ${TEST_APPS} PARENT_SCOPE)
|
||||
else()
|
||||
set(IFEM_PATH ${PROJECT_SOURCE_DIR})
|
||||
add_check_target()
|
||||
endif()
|
||||
|
||||
|
||||
@@ -180,34 +180,7 @@ IF(VERBOSE_DEBUG GREATER 0)
|
||||
ENDIF(VERBOSE_DEBUG GREATER 0)
|
||||
SET(IFEM_CXX_FLAGS "${IFEM_CXX_FLAGS} -DReal=double")
|
||||
|
||||
FUNCTION(IFEM_ADD_TEST name binary)
|
||||
SEPARATE_ARGUMENTS(MEMCHECK_COMMAND)
|
||||
IF(IFEM_TEST_EXTRA)
|
||||
SET(test-name "${binary}+${IFEM_TEST_EXTRA}+${name}")
|
||||
ELSE()
|
||||
SET(test-name "${binary}+${name}")
|
||||
ENDIF()
|
||||
IF(IFEM_TEST_MEMCHECK)
|
||||
ADD_TEST("${test-name}" regtest.sh "${MEMORYCHECK_COMMAND} --log-file=valgrindlog ${EXECUTABLE_OUTPUT_PATH}/${binary}" ${PROJECT_SOURCE_DIR}/${TEST_SUBDIR}/Test/${name} ${ARGN})
|
||||
ELSE(IFEM_TEST_MEMCHECK)
|
||||
ADD_TEST("${test-name}" regtest.sh ${EXECUTABLE_OUTPUT_PATH}/${binary} ${PROJECT_SOURCE_DIR}/${TEST_SUBDIR}/Test/${name} ${ARGN})
|
||||
ENDIF(IFEM_TEST_MEMCHECK)
|
||||
ENDFUNCTION(IFEM_ADD_TEST)
|
||||
|
||||
SET(IFEM_CONFIGURED 1)
|
||||
|
||||
macro(IFEM_add_test_app path workdir name)
|
||||
FILE(GLOB TEST_SRCS ${path})
|
||||
add_executable(${name}-test EXCLUDE_FROM_ALL ${IFEM_PATH}/src/IFEM-test.C ${TEST_SRCS})
|
||||
gtest_add_tests($<TARGET_FILE:${name}-test> ${workdir} ${TEST_SRCS})
|
||||
list(APPEND TEST_APPS ${name}-test)
|
||||
target_link_libraries(${name}-test ${ARGN} gtest)
|
||||
endmacro()
|
||||
|
||||
macro(IFEM_add_unittests IFEM_PATH)
|
||||
add_subdirectory(${IFEM_PATH}/3rdparty/gtest gtest EXCLUDE_FROM_ALL)
|
||||
IFEM_add_test_app("${IFEM_PATH}/src/Utility/Test/*.C;${IFEM_PATH}/src/ASM/Test/*.C"
|
||||
${IFEM_PATH}
|
||||
IFEM
|
||||
IFEM ${IFEM_DEPLIBS})
|
||||
endmacro()
|
||||
if(NOT IFEM_TESTING_INCLUDED)
|
||||
include(IFEMTesting)
|
||||
endif()
|
||||
|
||||
@@ -240,14 +240,6 @@ function(gtest_add_tests executable working_dir)
|
||||
set(UNIT_TEST_NUMBER ${UNIT_TEST_NUMBER} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
macro(add_check_target)
|
||||
ifem_add_unittests(${IFEM_PATH})
|
||||
foreach(test_number RANGE 1 ${UNIT_TEST_NUMBER})
|
||||
list(GET UNIT_TEST${test_number} 0 name)
|
||||
list(GET UNIT_TEST${test_number} 1 dir)
|
||||
list(GET UNIT_TEST${test_number} 2 -1 cmd)
|
||||
add_test(NAME ${name} WORKING_DIRECTORY ${dir} COMMAND ${cmd})
|
||||
endforeach()
|
||||
add_custom_target(check ${CMAKE_CTEST_COMMAND} WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
|
||||
add_dependencies(check ${TEST_APPS})
|
||||
endmacro()
|
||||
if(NOT IFEM_TESTING_INCLUDED)
|
||||
include(IFEMTesting)
|
||||
endif()
|
||||
|
||||
43
cmake/Modules/IFEMTesting.cmake
Normal file
43
cmake/Modules/IFEMTesting.cmake
Normal file
@@ -0,0 +1,43 @@
|
||||
macro(IFEM_add_test_app path workdir name)
|
||||
FILE(GLOB TEST_SRCS ${path})
|
||||
add_executable(${name}-test EXCLUDE_FROM_ALL ${IFEM_PATH}/src/IFEM-test.C ${TEST_SRCS})
|
||||
gtest_add_tests($<TARGET_FILE:${name}-test> ${workdir} ${TEST_SRCS})
|
||||
list(APPEND TEST_APPS ${name}-test)
|
||||
target_link_libraries(${name}-test ${ARGN} gtest)
|
||||
endmacro()
|
||||
|
||||
macro(IFEM_add_unittests IFEM_PATH)
|
||||
add_subdirectory(${IFEM_PATH}/3rdparty/gtest gtest EXCLUDE_FROM_ALL)
|
||||
IFEM_add_test_app("${IFEM_PATH}/src/Utility/Test/*.C;${IFEM_PATH}/src/ASM/Test/*.C"
|
||||
${IFEM_PATH}
|
||||
IFEM
|
||||
IFEM ${IFEM_DEPLIBS})
|
||||
endmacro()
|
||||
|
||||
function(IFEM_add_test name binary)
|
||||
separate_arguments(MEMCHECK_COMMAND)
|
||||
if(IFEM_TEST_EXTRA)
|
||||
set(test-name "${binary}+${IFEM_TEST_EXTRA}+${name}")
|
||||
else()
|
||||
set(test-name "${binary}+${name}")
|
||||
endif()
|
||||
if(IFEM_TEST_MEMCHECK)
|
||||
add_test("${test-name}" regtest.sh "${MEMORYCHECK_COMMAND} --log-file=valgrindlog ${EXECUTABLE_OUTPUT_PATH}/${binary}" ${PROJECT_SOURCE_DIR}/${TEST_SUBDIR}/Test/${name} ${ARGN})
|
||||
else(IFEM_TEST_MEMCHECK)
|
||||
add_test("${test-name}" regtest.sh ${EXECUTABLE_OUTPUT_PATH}/${binary} ${PROJECT_SOURCE_DIR}/${TEST_SUBDIR}/Test/${name} ${ARGN})
|
||||
endif(IFEM_TEST_MEMCHECK)
|
||||
endfunction()
|
||||
|
||||
macro(add_check_target)
|
||||
ifem_add_unittests(${IFEM_PATH})
|
||||
foreach(test_number RANGE 1 ${UNIT_TEST_NUMBER})
|
||||
list(GET UNIT_TEST${test_number} 0 name)
|
||||
list(GET UNIT_TEST${test_number} 1 dir)
|
||||
list(GET UNIT_TEST${test_number} 2 -1 cmd)
|
||||
add_test(NAME ${name} WORKING_DIRECTORY ${dir} COMMAND ${cmd})
|
||||
endforeach()
|
||||
add_custom_target(check ${CMAKE_CTEST_COMMAND} WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
|
||||
add_dependencies(check ${TEST_APPS})
|
||||
endmacro()
|
||||
|
||||
set(IFEM_TESTING_INCLUDED 1)
|
||||
Reference in New Issue
Block a user