Computer Assisted Medical Intervention Tool Kit  version 5.2
CamiTKAdditionalActionTest.h
Go to the documentation of this file.
33  if (NOT PACKAGING_NSIS AND BUILD_TESTING)
34  set(options "")
35  set(oneValueArgs "")
36  set(multiValueArgs ACTION_EXTENSIONS TEST_FILES)
37  cmake_parse_arguments(CAMITK_ADDITIONAL_ACTION_TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
38 
39  # COMPONENT_EXTENSION_PLUGIN_FILE
40  # determine the extension full file name depending on the plateform
41  if (MSVC)
42  set(COMPONENT_EXTENSION_PLUGIN_FILE "components/${${TYPE_EXTENSION_CMAKE}_OUTPUT_NAME}${CAMITK_DEBUG_POSTFIX}.dll")
43  elseif(APPLE)
44  set(COMPONENT_EXTENSION_PLUGIN_FILE "components/lib${${TYPE_EXTENSION_CMAKE}_OUTPUT_NAME}.dylib")
45  else()
46  # Must be Linux
47  set(COMPONENT_EXTENSION_PLUGIN_FILE "components/lib${${TYPE_EXTENSION_CMAKE}_OUTPUT_NAME}.so")
48  endif()
49 
50  # if this is not SDK, then it is required
51  if(NOT CAMITK_COMMUNITY_EDITION_BUILD)
52  set(ADDITIONAL_COMPONENT_EXTENSION_ARG "-c ${CAMITK_BUILD_PRIVATE_LIB_DIR}/${COMPONENT_EXTENSION_PLUGIN_FILE}")
53  endif()
54 
55  # loop over actions
56  # if (action extension exists in repository) CAMITK_USER_PRIVATE_LIB_DIR CAMITK_PRIVATE_LIB_DIR CAMITK_BUILD_PRIVATE_LIB_DIR
57  # loop over test files
58  # add test
59  # math(EXPR CAMITK_ADDITIONNAL_TEST_ID "${CAMITK_ADDITIONNAL_TEST_ID} + 1")
60  foreach(ACTION_EXTENSION ${CAMITK_ADDITIONAL_ACTION_TEST_ACTION_EXTENSIONS})
61  # determine the extension full file name depending on the plateform
62  if (MSVC)
63  set(EXTENSION_FILE "actions/${ACTION_EXTENSION}${CAMITK_DEBUG_POSTFIX}.dll")
64  elseif(APPLE)
65  set(EXTENSION_FILE "$actions/lib${ACTION_EXTENSION}.dylib")
66  else()
67  # Must be Linux
68  set(EXTENSION_FILE "actions/lib${ACTION_EXTENSION}.so")
69  endif()
70 
71  # check if action can be found in (this order) : build dir (CAMITK_BUILD_PRIVATE_LIB_DIR),
72  # local user install (CAMITK_USER_PRIVATE_LIB_DIR, and global install (CAMITK_PRIVATE_LIB_DIR)
73  set(ACTION_EXTENSION_PLUGIN_FILE ${CAMITK_BUILD_PRIVATE_LIB_DIR}/${EXTENSION_FILE})
74  set(ACTION_EXTENSION_TARGET "action-${ACTION_EXTENSION}")
75  # The action should already be compiled.
76  # if the action does not yet exists, if there is a target of the current project
77  # that will build it, then it is ok as well.
78  # otherwise, it should be already installed locally or globally
79  if ((NOT EXISTS ${ACTION_EXTENSION_PLUGIN_FILE}) AND (NOT TARGET ${ACTION_EXTENSION_TARGET}))
80  set(ACTION_EXTENSION_PLUGIN_FILE ${CAMITK_USER_PRIVATE_LIB_DIR}/${EXTENSION_FILE})
81  if (NOT EXISTS ${ACTION_EXTENSION_PLUGIN_FILE})
82  set(ACTION_EXTENSION_PLUGIN_FILE ${CAMITK_PRIVATE_LIB_DIR}/${EXTENSION_FILE})
83  if (NOT EXISTS ${ACTION_EXTENSION_PLUGIN_FILE})
84  message(SEND_ERROR "Action extension \"${ACTION_EXTENSION}\" not found: no additional test added")
85  return()
86  endif()
87  endif()
88  endif()
89 
90  message(STATUS "Adding additional autotest for action-${ACTION_EXTENSION}")
91  if (CAMITK_COMMUNITY_EDITION_BUILD)
92  camitk_init_test(application-testactions)
93  else()
94  camitk_init_test(camitk-testactions)
95  endif()
96 
97  # add a separator to the wiki page information
98  camitk_parse_test_add_separator(EXTENSION_TYPE actions EXTENSION_NAME ${ACTION_EXTENSION})
99 
100  # Retrieve the files in testdata directory - a test will be applied for each of these files
101  # or use only the given files
102  if (CAMITK_ADDITIONAL_ACTION_TEST_TEST_FILES)
103  # add testdata dir to filename
104  set(TESTFILES)
105  foreach(COMPONENT_TESTDATA_FILE ${CAMITK_ADDITIONAL_ACTION_TEST_TEST_FILES})
106  list(APPEND TESTFILES ${CMAKE_CURRENT_SOURCE_DIR}/testdata/${COMPONENT_TESTDATA_FILE})
107  endforeach()
108  else()
109  get_subdirectoryfiles( ${CMAKE_CURRENT_SOURCE_DIR}/testdata TESTFILES )
110  endif()
111 
112  foreach( ACTION_TESTDATA_FILE ${TESTFILES})
113  # Test procedure: Open a file - load an action extension - Apply an action on the component wrapping the file
114  camitk_add_test(EXECUTABLE_ARGS "-i ${ACTION_TESTDATA_FILE} -a ${ACTION_EXTENSION_PLUGIN_FILE} ${ADDITIONAL_COMPONENT_EXTENSION_ARG}"
115  TEST_SUFFIX "-additional-${ACTION_EXTENSION}-level1-"
116  PROJECT_NAME "component-${EXTENSION_NAME}"
117  )
118  # add test to the wiki page information
119  camitk_parse_test_add(NAME ${CAMITK_TEST_NAME} LEVEL 1 DESCRIPTION "Open a file, load the action and apply it on the component.")
120  endforeach()
121 
122  endforeach()
123  endif()
124 end(){)
125 
cmake modules macros camitk test endif() add_custom_target(camitk-ce-iwyu COMMAND $
Definition: CamiTKIncludeWhatYouUse.h:37
#define a
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_additional_action_test()
camitk_additional_action_test is a macro to create additional level1 test of CamiTK action to the CTe...
Definition: CamiTKAdditionalActionTest.h:32
for(int i=0;i< 4;i++)
Definition: RendererWidget.cpp:463