Medical Imaging Interaction Toolkit  2018.4.99-eed36131
Medical Imaging Interaction Toolkit
mitkMacroCreateDefaultTests.cmake
Go to the documentation of this file.
1 # Create TestDriver and default tests for MITK
2 #
3 # CMake variables used:
4 #
5 # ${${KITNAME}_GUI_TESTS} : filenames of all tests that run without a parameter
6 # ${${KITNAME}_IMAGE_GUI_TESTS : filenames of all tests that run with an image filename as parameter
7 # ${${KITNAME}_TESTS} : filenames of all tests that run without a parameter
8 # ${${KITNAME}_IMAGE_TESTS : filenames of all tests that run with an image filename as parameter
9 # ${${KITNAME}_TESTIMAGES} : list of images passed as parameter for the IMAGE_TESTS
10 # ${${KITNAME}_CUSTOM_TESTS} : filenames of custom tests which are just added to the TestDriver. Execution
11 # of these has to be specified manually with the ADD_TEST CMake command.
12 #
14  # add tests which need a GUI if it is not disabled
15  if(NOT MITK_GUI_TESTS_DISABLED)
16  set( ${KITNAME}_TESTS ${${KITNAME}_TESTS} ${${KITNAME}_GUI_TESTS} )
17  set( ${KITNAME}_IMAGE_TESTS ${${KITNAME}_IMAGE_TESTS} ${${KITNAME}_IMAGE_GUI_TESTS} )
18  endif()
19 
20  #
21  # Create the TestDriver binary which contains all the tests.
22  #
23  create_test_sourcelist(MITKTEST_SOURCE ${KITNAME}TestDriver.cpp
24  ${${KITNAME}_TESTS} ${${KITNAME}_IMAGE_TESTS} ${${KITNAME}_CUSTOM_TESTS}
25  )
26  add_executable(${KITNAME}TestDriver ${MITKTEST_SOURCE})
27  set_property(TARGET ${KITNAME}TestDriver PROPERTY LABELS ${PROJECT_NAME})
28  target_link_libraries(${KITNAME}TestDriver ${${KITNAME}_CORE_LIBRARIES} ${${KITNAME}_LIBRARIES} ${LIBRARIES_FOR_${KITNAME}_CORE})
29  #
30  # Now tell CMake which tests should be run. This is done automatically
31  # for all tests in ${KITNAME}_TESTS and ${KITNAME}_IMAGE_TESTS. The IMAGE_TESTS
32  # are run for each image in the TESTIMAGES list.
33  #
34  foreach( test ${${KITNAME}_TESTS} )
35  get_filename_component(TName ${test} NAME_WE)
36  add_test(${TName} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${KITNAME}TestDriver ${TName})
37  set_property(TEST ${TName} PROPERTY LABELS ${PROJECT_NAME})
38 
39  mitkFunctionGetLibrarySearchPaths(MITK_RUNTIME_PATH_RELEASE release RELEASE)
40  mitkFunctionGetLibrarySearchPaths(MITK_RUNTIME_PATH_DEBUG debug DEBUG)
41  string (REGEX REPLACE "\;" "\\\;" MITK_RUNTIME_PATH_RELEASE "${MITK_RUNTIME_PATH_RELEASE}")
42  string (REGEX REPLACE "\;" "\\\;" MITK_RUNTIME_PATH_DEBUG "${MITK_RUNTIME_PATH_DEBUG}")
43  set_property(TEST ${TName} PROPERTY ENVIRONMENT "PATH=${MITK_RUNTIME_PATH_RELEASE}\;${MITK_RUNTIME_PATH_DEBUG}" APPEND)
44  set_property(TEST ${TName} PROPERTY SKIP_RETURN_CODE 77)
45  endforeach()
46 
47  foreach(image ${${KITNAME}_TESTIMAGES} ${ADDITIONAL_TEST_IMAGES} )
48  if(EXISTS "${image}")
49  set(IMAGE_FULL_PATH ${image})
50  else()
51  # todo: maybe search other paths as well
52  # yes, please in mitk/Testing/Data, too
53  set(IMAGE_FULL_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Data/${image})
54  endif()
55 
56  if(EXISTS "${IMAGE_FULL_PATH}")
57  foreach( test ${${KITNAME}_IMAGE_TESTS} )
58  get_filename_component(TName ${test} NAME_WE)
59  get_filename_component(ImageName ${IMAGE_FULL_PATH} NAME)
60  add_test(${TName}_${ImageName} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${KITNAME}TestDriver ${TName} ${IMAGE_FULL_PATH})
61  set_property(TEST ${TName}_${ImageName} PROPERTY LABELS ${PROJECT_NAME})
62  set_property(TEST ${TName}_${ImageName} PROPERTY ENVIRONMENT "PATH=${MITK_RUNTIME_PATH_RELEASE}\;${MITK_RUNTIME_PATH_DEBUG}" APPEND)
63  set_property(TEST ${TName}_${ImageName} PROPERTY SKIP_RETURN_CODE 77)
64  endforeach()
65  else()
66  message("!!!!! No such file: ${IMAGE_FULL_PATH} !!!!!")
67  endif()
68  endforeach()
69 endmacro()
70 
mitkFunctionGetLibrarySearchPaths(search_path, intermediate_dir)
Follow Up Storage - Class to facilitate loading/accessing structured follow-up data.
Definition: testcase.h:28
MITK_CREATE_DEFAULT_TESTS()
mitk::Image::Pointer image
static bool in(Reader::Char c, Reader::Char c1, Reader::Char c2, Reader::Char c3, Reader::Char c4)
Definition: jsoncpp.cpp:244
const std::string NAME
const std::string TARGET