Commit 38a03a61 authored by Emmanuel Promayon's avatar Emmanuel Promayon
Browse files

NEW component extension can add more autotest of an action

use case: a CEP provides a new component extension and wants to check
its integration in previously defined actions. It is now possible to add
additional autotest using the testfiles provided by this new component
extension.
parent b98cdbb4
......@@ -26,3 +26,8 @@ set_tests_properties("component-itkimage-level3-3" PROPERTIES WILL_FAIL true)
set_tests_properties("component-itkimage-level3-19" PROPERTIES WILL_FAIL true)
# TODO check why ITK cannot save LittleEndianZ.img.gz properly
set_tests_properties("component-itkimage-level3-20" PROPERTIES WILL_FAIL true)
# Additional test for SDK actions: this will add auto test for the given actions using the itkimage component
camitk_additional_action_test(ACTION_EXTENSIONS cropvolume imagelut imageresampling multipicking pixelcolorchanger reconstruction reorientimage showin3d volumerendering
TEST_FILES BigEndian.hdr BigEndian.img BigEndianCompressed1.hdr BigEndianCompressed1.img biorad.pic cthead1.lsm LittleEndian1.hdr LittleEndian1.img LittleEndianCompressed1.hdr LittleEndianCompressed1.img LittleEndianZ1.hdr mini-complex-slow1.nrrd mini-ten-nomask-slow1.nrrd mini-vector-slow1.nrrd ramp1.gipl
)
......@@ -28,6 +28,7 @@ include(camitk/cdash/projects/CamiTKSubProjectValidate)
# -- CamiTK test macros (see also http://www.org/cmake/help/v2.8.8/cmake.html#section_PropertiesonTests)
include(camitk/test/CamiTKInitTest)
include(camitk/test/CamiTKAddTest)
include(camitk/test/CamiTKAdditionalActionTest)
# -- packaging macros
include(camitk/packaging/CamiTKOpenSourcePackaging)
......
......@@ -945,10 +945,10 @@ macro(camitk_extension)
foreach( ACTION_TESTDATA_FILE ${TESTFILES})
# Test procedure: Open a file - load an action extension - Apply an action on the component wrapping the file
camitk_add_test( EXECUTABLE_ARGS "-i ${ACTION_TESTDATA_FILE} -a ${EXTENSION_PLUGIN_FILE}"
TEST_SUFFIX "-level1-"
PROJECT_NAME ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
)
camitk_add_test(EXECUTABLE_ARGS "-i ${ACTION_TESTDATA_FILE} -a ${EXTENSION_PLUGIN_FILE}"
TEST_SUFFIX "-level1-"
PROJECT_NAME ${${TYPE_EXTENSION_CMAKE}_TARGET_NAME}
)
camitk_parse_test_add(NAME ${CAMITK_TEST_NAME} LEVEL 1 DESCRIPTION "Open a file, load the action and apply it on the component.")
endforeach()
endif()
......
......@@ -49,10 +49,10 @@
#
#! @sa camitk_init_test
macro(camitk_add_test)
#set(options "")
set(options "")
set(oneValueArgs EXECUTABLE_ARGS PASS_FILE PASS_REGULAR_EXPRESSION FAIL_REGULAR_EXPRESSION PASS_FILE_OUTPUT TEST_SUFFIX PROJECT_NAME)
#set(multiValueArgs "")
cmake_parse_arguments(CAMITK_ADD_TEST "" "${oneValueArgs}" "" ${ARGN} )
set(multiValueArgs "")
cmake_parse_arguments(CAMITK_ADD_TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
math(EXPR CAMITK_TEST_ID "${CAMITK_TEST_ID} + 1")
set(CAMITK_TEST_NAME "${CAMITK_ADD_TEST_PROJECT_NAME}${CAMITK_ADD_TEST_TEST_SUFFIX}${CAMITK_TEST_ID}")
......
#!
#! @ingroup group_sdk_cmake_camitk_test
#!
#! camitk_additional_action_test is a macro to create additional level1 test of CamiTK action
#! to the CTest infrastructure.
#!
#! It should be used when a CEP introduces a new component (with new test files)
#! and an existing action should be run using this new component and test files.
#!
#! Usage:
#! \code
#! camitk_additional_action_test(ACTION_EXTENSIONS action1 action2 ...
#! [TEST_FILES file1 file2 ...]
#! [TEST_SUFFIX name]
#! )
#! \endcode
#!
#! \param ACTION_EXTENSIONS List of the action extension that will be additionnaly tested with the given
#! test files. Only the action extension name (note the full library/dll name nor
#! the path should be given. This macro checks the existence of the extension
#! library/dll in the following directories (in this order) : build dir;
#! user install dir and global install dir. The first one found is used for the tests.
#! \param TEST_FILES Optional. List of files to use for testing. If not set, then all the files in the
#! testdata dir are used.
#! If provided, only the filenames are required (not the absolute paths) and
#! all the given files should be in the testdata subdir.
#! \param TEST_SUFFIX Optional. suffix name for the additional test. default value is the name of the
#! current component extension.
#!
#! @sa camitk_extension
macro(camitk_additional_action_test)
if (NOT PACKAGING_NSIS AND BUILD_TESTING)
set(options "")
set(oneValueArgs TEST_SUFFIX)
set(multiValueArgs ACTION_EXTENSIONS TEST_FILES)
cmake_parse_arguments(CAMITK_ADDITIONAL_ACTION_TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
if ()
set(CAMITK_ADDITIONAL_ACTION_TEST_SUFFIX ${CAMITK_ADDITIONAL_ACTION_TEST_TEST_SUFFIX})
else()
set(CAMITK_ADDITIONAL_ACTION_TEST_SUFFIX ${EXTENSION_NAME})
endif()
# loop over actions
# if (action extension exists in repository) CAMITK_USER_PRIVATE_LIB_DIR CAMITK_PRIVATE_LIB_DIR CAMITK_BUILD_PRIVATE_LIB_DIR
# loop over test files
# add test
# math(EXPR CAMITK_ADDITIONNAL_TEST_ID "${CAMITK_ADDITIONNAL_TEST_ID} + 1")
foreach(ACTION_EXTENSION ${CAMITK_ADDITIONAL_ACTION_TEST_ACTION_EXTENSIONS})
# determine the extension full file name depending on the plateform
if (MSVC)
set(EXTENSION_FILE "actions/${ACTION_EXTENSION}${CAMITK_DEBUG_POSTFIX}.dll")
elseif(APPLE)
set(EXTENSION_FILE "$actions/lib${ACTION_EXTENSION}.dylib")
else()
# Must be Linux
set(EXTENSION_FILE "actions/lib${ACTION_EXTENSION}.so")
endif()
# check if action can be found in (this order) : build dir (CAMITK_BUILD_PRIVATE_LIB_DIR),
# user install (CAMITK_USER_PRIVATE_LIB_DIR, and global install (CAMITK_PRIVATE_LIB_DIR)
set(EXTENSION_PLUGIN_FILE ${CAMITK_BUILD_PRIVATE_LIB_DIR}/${EXTENSION_FILE})
if (NOT EXISTS ${EXTENSION_PLUGIN_FILE})
set(EXTENSION_PLUGIN_FILE ${CAMITK_USER_PRIVATE_LIB_DIR}/${EXTENSION_FILE})
if (NOT EXISTS ${EXTENSION_PLUGIN_FILE})
set(EXTENSION_PLUGIN_FILE ${CAMITK_PRIVATE_LIB_DIR}/${EXTENSION_FILE})
if (NOT EXISTS ${EXTENSION_PLUGIN_FILE})
message(SEND_ERROR "Action extension \"${ACTION_EXTENSION}\" not found: no additional test added")
return()
endif()
endif()
endif()
message(STATUS "Adding additional test for action extension: ${ACTION_EXTENSION}")
if (CAMITK_SDK_BUILD)
camitk_init_test(application-testactions)
else()
camitk_init_test(camitk-testactions)
endif()
camitk_parse_test_add_separator(EXTENSION_TYPE actions EXTENSION_NAME ${ACTION_EXTENSION})
# Retrieve the files in testdata directory - a test will be applied for each of these files
# or use only the given files
if (CAMITK_ADDITIONAL_ACTION_TEST_TEST_FILES)
# add testdata dir to filename
set(TESTFILES)
foreach(COMPONENT_TESTDATA_FILE ${CAMITK_ADDITIONAL_ACTION_TEST_TEST_FILES})
list(APPEND TESTFILES ${CMAKE_CURRENT_SOURCE_DIR}/testdata/${COMPONENT_TESTDATA_FILE})
endforeach()
else()
get_subdirectoryfiles( ${CMAKE_CURRENT_SOURCE_DIR}/testdata TESTFILES )
endif()
foreach( ACTION_TESTDATA_FILE ${TESTFILES})
# Test procedure: Open a file - load an action extension - Apply an action on the component wrapping the file
camitk_add_test(EXECUTABLE_ARGS "-i ${ACTION_TESTDATA_FILE} -a ${EXTENSION_PLUGIN_FILE}"
TEST_SUFFIX "-additional-${CAMITK_ADDITIONAL_ACTION_TEST_SUFFIX}-level1-"
PROJECT_NAME "action-${ACTION_EXTENSION}"
)
camitk_parse_test_add(NAME ${CAMITK_TEST_NAME} LEVEL 1 DESCRIPTION "Open a file, load the action and apply it on the component.")
endforeach()
endforeach()
endif()
endmacro()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment