53 set(oneValueArgs EXECUTABLE_ARGS PASS_FILE PASS_REGULAR_EXPRESSION FAIL_REGULAR_EXPRESSION PASS_FILE_OUTPUT TEST_SUFFIX PROJECT_NAME)
54 set(multiValueArgs
"")
55 cmake_parse_arguments(CAMITK_ADD_TEST
"${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
57 math(EXPR CAMITK_TEST_ID
"${CAMITK_TEST_ID} + 1")
58 set(CAMITK_TEST_NAME
"${CAMITK_ADD_TEST_PROJECT_NAME}${CAMITK_ADD_TEST_TEST_SUFFIX}${CAMITK_TEST_ID}")
59 set(CAMITK_TEST_LIST ${CAMITK_TEST_LIST} ${CAMITK_TEST_NAME})
61 # determine cmake macro path
62 if (NOT EXISTS ${SDK_TOP_LEVEL_SOURCE_DIR})
63 #
this macro is called outside the sdk
64 set(CAMITK_CMAKE_MACRO_PATH ${CAMITK_CMAKE_DIR}/macros/
camitk/test)
65 if(NOT IS_DIRECTORY ${CAMITK_CMAKE_MACRO_PATH})
66 # inside communityedition but not in sdk (modeling or imaging)
67 set(CAMITK_CMAKE_MACRO_PATH ${CMAKE_SOURCE_DIR}/sdk/cmake/modules/macros/
camitk/test)
70 # directly use the macro source dir 71 set(CAMITK_CMAKE_MACRO_PATH ${SDK_TOP_LEVEL_SOURCE_DIR}/cmake/modules/macros/
camitk/test)
74 # create test output directory 75 set(CAMITK_TEST_OUTPUT_DIR
"${CMAKE_BINARY_DIR}/Testing/Temporary/${CAMITK_TEST_NAME}")
76 execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CAMITK_TEST_OUTPUT_DIR})
78 # check which test is to be done
79 if(CAMITK_ADD_TEST_PASS_FILE)
80 add_test(NAME ${CAMITK_TEST_NAME}
81 COMMAND ${CMAKE_COMMAND}
82 -DCAMITK_TEST_COMMAND=${CAMITK_INIT_TEST_EXECUTABLE}
83 -DCAMITK_TEST_COMMAND_ARG=${CAMITK_ADD_TEST_EXECUTABLE_ARGS}
84 -DCAMITK_TEST_PASS_FILE=${CAMITK_ADD_TEST_PASS_FILE}
85 -DCAMITK_TEST_OUTPUT_DIR=${CAMITK_TEST_OUTPUT_DIR}
86 -DCAMITK_TEST_NAME=${CAMITK_TEST_NAME}
87 -P ${CAMITK_CMAKE_MACRO_PATH}/CamiTKTestPassFile.cmake
89 elseif(CAMITK_ADD_TEST_PASS_FILE_OUTPUT)
90 add_test(NAME ${CAMITK_TEST_NAME}
91 COMMAND ${CMAKE_COMMAND}
92 -DCAMITK_TEST_COMMAND=${CAMITK_INIT_TEST_EXECUTABLE}
93 -DCAMITK_TEST_COMMAND_ARG=${CAMITK_ADD_TEST_EXECUTABLE_ARGS}
94 -DCAMITK_TEST_PASS_FILE=${CAMITK_ADD_TEST_PASS_FILE_OUTPUT}
95 -DCAMITK_TEST_OUTPUT_DIR=${CAMITK_TEST_OUTPUT_DIR}
96 -DCAMITK_TEST_NAME=${CAMITK_TEST_NAME}
97 -P ${CAMITK_CMAKE_MACRO_PATH}/CamiTKTestCompareFile.cmake
100 # set output files for more advanced checking/debugging 101 set(CAMITK_TEST_COMMAND_FILE ${CAMITK_TEST_OUTPUT_DIR}/command) # which command is run to test the exectable
103 execute_process(COMMAND ${CMAKE_COMMAND} -E
remove -f ${CAMITK_TEST_COMMAND_FILE} )
104 file(WRITE ${CAMITK_TEST_COMMAND_FILE}
"Test command: ${CAMITK_INIT_TEST_EXECUTABLE} ${CAMITK_ADD_TEST_EXECUTABLE_ARGS}\nPASS_REGULAR_EXPRESSION: '${CAMITK_ADD_TEST_PASS_REGULAR_EXPRESSION}'\n")
106 if(CAMITK_ADD_TEST_EXECUTABLE_ARGS)
107 # expands all arguments 108 string(REPLACE
" " "" CAMITK_TEST_COMMAND_ARG_LIST ${CAMITK_ADD_TEST_EXECUTABLE_ARGS})
110 set(CAMITK_TEST_COMMAND_ARG_LIST)
113 # add the simple test command 114 add_test(NAME ${CAMITK_TEST_NAME}
115 COMMAND ${CAMITK_INIT_TEST_EXECUTABLE} ${CAMITK_TEST_COMMAND_ARG_LIST}
118 # add properties
if needed
119 if(CAMITK_ADD_TEST_PASS_REGULAR_EXPRESSION)
120 set_tests_properties(${CAMITK_TEST_NAME} PROPERTIES PASS_REGULAR_EXPRESSION ${CAMITK_ADD_TEST_PASS_REGULAR_EXPRESSION})
122 if(CAMITK_ADD_TEST_FAIL_REGULAR_EXPRESSION)
123 set_tests_properties(${CAMITK_TEST_NAME} PROPERTIES FAIL_REGULAR_EXPRESSION ${CAMITK_ADD_TEST_FAIL_REGULAR_EXPRESSION})
128 # set the label for tests 129 if( CAMITK_ADD_TEST_PROJECT_NAME )
130 set_tests_properties( ${CAMITK_TEST_NAME} PROPERTIES LABELS ${CAMITK_ADD_TEST_PROJECT_NAME} )#associate tests to
a project name in CDash
132 set_tests_properties( ${CAMITK_TEST_NAME} PROPERTIES LABELS ${CAMITK_TEST_BASENAME} )
iwyu out CACHE PATH Output filename for include what you use set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${IWYU_EXECUTABLE}) if(NOT EXISTS $
Definition: CamiTKIncludeWhatYouUse.h:22
camitk_add_test()
camitk_add_test is a macro to add a new test to the CTest infrastructure It encapsulates CMake add_te...
Definition: CamiTKAddTest.h:51
Definition: Action.cpp:36
cmake modules macros camitk test endif() add_custom_target(camitk-ce-iwyu COMMAND $
Definition: CamiTKIncludeWhatYouUse.h:37
test result execute_process(COMMAND ${CMAKE_COMMAND} -E remove -f ${CAMITK_TEST_COMMAND_FILE} ${CAMITK_TEST_COMMAND_RESULT_FILE} ${CAMITK_TEST_COMMAND_OUTPUT_FILE} ${CAMITK_TEST_PASS_FILE_COMMAND_FILE} ${CAMITK_TEST_PASS_FILE_OUTPUT_FILE} ${CAMITK_TEST_PASS_FILE_RESULT_FILE}) file(WRITE $
Definition: CamiTKTestPassFile.h:21
if(${CMAKE_VERSION} VERSION_GREATER "3.3" OR ${CMAKE_VERSION} VERSION_EQUAL "3.3") option(CAMITK_INCLUDE_WHAT_YOU_USE "Enable the header analysis on you code