Commit 1e74ac21 authored by Kasper Marstal's avatar Kasper Marstal
Browse files

ENH: Split tests into Testing/Unit and Testing/Integration directories

parent 4c58fa39
......@@ -57,4 +57,4 @@ if( NOT CMAKE_PROJECT_NAME STREQUAL "SuperElastix" )
include( ${ELASTIX_USE_FILE} )
endif()
add_subdirectory( SuperElastixCommandLineInterface )
\ No newline at end of file
add_subdirectory( CommandLineInterface )
\ No newline at end of file
......@@ -17,8 +17,6 @@
#
#=========================================================================
set( APPLICATION ApplicationSuperElastixCLI )
set( ${APPLICATION}_TARGET_NAME SuperElastix )
set( ${APPLICATION}_SOURCE_FILES
......@@ -40,7 +38,3 @@ set( ${APPLICATION}_MODULE_DEPENDENCIES
ModuleItkSmoothingRecursiveGaussianImageFilter
ModuleSinksAndSources
)
set( ${APPLICATION}_INTEGRATION_TESTS
--conf ../Configuration/itkv4_SVF_ANTsCC.json --in FixedImage=../Data/coneA2d64.mhd MovingImage=../Data/coneB2d64.mhd --out ResultImage=2A_image_itkv4_NC.mhd ResultDisplacementField=2A_deformation_itkv4_NC.mhd
)
\ No newline at end of file
......@@ -34,7 +34,7 @@ set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(BOOST_LIBRARYDIR ${BOOST_ROOT}/stage/lib)
find_package(Boost COMPONENTS program_options system filesystem REQUIRED)
find_package(Boost COMPONENTS program_options system filesystem REQUIRED QUIET )
include_directories(${Boost_INCLUDE_DIR})
# Compile executable
......@@ -44,12 +44,11 @@ target_link_libraries( SuperElastix ${SUPERELASTIX_LIBRARIES} ${Boost_LIBRARIES}
# InstallDemo copies SuperElastix executable, image data, configuration files and bat/bash scripts to the INSTALLDEMO_PREFIX directory
set( INSTALLDEMO_PREFIX ${PROJECT_BINARY_DIR}/Demo CACHE PATH "Demo files will be copied to this directory" )
set(INSTALLDEMO_PREFIX ${PROJECT_BINARY_DIR}/Demo CACHE PATH "Path where to copy the Demo files")
#add_custom_target( InstallDemo EXCLUDE_FROM_ALL DEPENDS SuperElastix)
#Demo Image data
# Download demo data
include( ExternalData )
# Get the demo image data: from superelastix-build or otherwise download
list( APPEND ExternalData_URL_TEMPLATES
"file://${PROJECT_BINARY_DIR}/../SuperElastix-build/ExternalData/Objects/%(algo)/%(hash)"
......@@ -67,53 +66,61 @@ foreach( DemoDataContentLink ${DemoDataContentLinks} )
list( APPEND InstallDemoFileNames ${InstallDemoFileName} )
endforeach()
#Create target and reference the external data
# Create target and reference the external data
ExternalData_Add_Target( InstallDemo )
#add_custom_target( InstallDemo EXCLUDE_FROM_ALL DEPENDS SuperElastix)
add_dependencies(InstallDemo SuperElastix )
set_target_properties(InstallDemo PROPERTIES EXCLUDE_FROM_ALL TRUE)
add_dependencies( InstallDemo SuperElastix )
set_target_properties( InstallDemo PROPERTIES EXCLUDE_FROM_ALL TRUE )
foreach(InstallDemoFileName ${InstallDemoFileNames})
add_custom_command(TARGET InstallDemo POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${INSTALLDEMO_PREFIX}/Data
COMMAND ${CMAKE_COMMAND} -E copy ${InstallDemoFileName} ${INSTALLDEMO_PREFIX}/Data/)
add_custom_command(
TARGET InstallDemo POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${INSTALLDEMO_PREFIX}/Data
COMMAND ${CMAKE_COMMAND} -E copy ${InstallDemoFileName} ${INSTALLDEMO_PREFIX}/Data/
)
endforeach()
# Copy executable
add_custom_command(TARGET InstallDemo POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:SuperElastix> ${INSTALLDEMO_PREFIX}/$<TARGET_FILE_NAME:SuperElastix>)
add_custom_command(
TARGET InstallDemo POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:SuperElastix> ${INSTALLDEMO_PREFIX}/$<TARGET_FILE_NAME:SuperElastix>
)
# Copy Configuration files
set(ConfigFiles "itkv4_SVF_ANTsCC.json"
set( ConfigFiles
"itkv4_SVF_ANTsCC.json"
"itkv4_SVF_MSD.json"
"elastix_Bspline_NC.json"
"elastix_Bspline_MSD.json")
"elastix_Bspline_MSD.json"
)
foreach(ConfigFile ${ConfigFiles})
add_custom_command(TARGET InstallDemo POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${INSTALLDEMO_PREFIX}/Configuration
COMMAND ${CMAKE_COMMAND} -E
copy "${CMAKE_SOURCE_DIR}/../Testing/Unit/Data/Configuration/${ConfigFile}" ${INSTALLDEMO_PREFIX}/Configuration/${ConfigFile})
foreach( ConfigFile ${ConfigFiles} )
add_custom_command(
TARGET InstallDemo POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${INSTALLDEMO_PREFIX}/Configuration
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/../Testing/Data/Configuration/${ConfigFile}" ${INSTALLDEMO_PREFIX}/Configuration/${ConfigFile}
)
endforeach()
# Copy bat/bash scripts
set(ScriptFiles "1A_SuperElastix_elastix_NC" "1B_SuperElastix_elastix_MSD" "2A_SuperElastix_itkv4_NC" "2B_SuperElastix_itkv4_MSD")
set( ScriptFiles
"1A_SuperElastix_elastix_NC"
"1B_SuperElastix_elastix_MSD"
"2A_SuperElastix_itkv4_NC"
"2B_SuperElastix_itkv4_MSD"
)
if(WIN32)
foreach(ScriptFile ${ScriptFiles})
add_custom_command(TARGET InstallDemo POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${INSTALLDEMO_PREFIX}/Scripts
COMMAND ${CMAKE_COMMAND} -E
copy "${CMAKE_CURRENT_SOURCE_DIR}/Demo/Scripts_Windows/${ScriptFile}.bat" "${INSTALLDEMO_PREFIX}/Scripts/${ScriptFile}.bat")
endforeach()
else(WIN32)
foreach(ScriptFile ${ScriptFiles})
add_custom_command(TARGET InstallDemo PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${INSTALLDEMO_PREFIX}/Scripts
COMMAND ${CMAKE_COMMAND} -E
copy "${CMAKE_CURRENT_SOURCE_DIR}/Demo/Scripts_Linux/${ScriptFile}.sh" "${INSTALLDEMO_PREFIX}/Scripts/${ScriptFile}.sh")
endforeach()
foreach( ScriptFile ${ScriptFiles} )
add_custom_command(
TARGET InstallDemo POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${INSTALLDEMO_PREFIX}/Scripts
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/Demo/Scripts_Windows/${ScriptFile}.bat" "${INSTALLDEMO_PREFIX}/Scripts/${ScriptFile}.bat")
endforeach()
else( WIN32 )
foreach( ScriptFile ${ScriptFiles} )
add_custom_command(
TARGET InstallDemo PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${INSTALLDEMO_PREFIX}/Scripts
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/Demo/Scripts_Linux/${ScriptFile}.sh" "${INSTALLDEMO_PREFIX}/Scripts/${ScriptFile}.sh")
endforeach()
endif(WIN32)
#
......@@ -17,19 +17,22 @@
#
#=========================================================================
set( PROJECT GoogleBenchmark )
set( GOOGLEBENCHMARK_REPOSITORY https://github.com/google/benchmark.git )
set( GOOGLEBENCHMARK_TAG "v${GOOGLEBENCHMARK_VERSION_STRING")
ExternalProject_Add( ${PROJECT}
GIT_REPOSITORY ${GOOGLEBENCHMARK_REPOSITORY}
GIT_TAG ${GOOGLEBENCHMARK_TAG}
UPDATE_COMMAND ""
SOURCE_DIR ${PROJECT}
BINARY_DIR ${prPROJECToj}-build
CMAKE_ARGS
--no-warn-unused-cli
-DBENCHMARK_ENABLE_TESTING:BOOL=OFF
-DCMAKE_SKIP_RPATH:BOOL=ON
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
add_integration_test(
NAME SuperElastixIntegrationTest
DRIVER SuperElastix
ARGUMENTS --conf ${CMAKE_SOURCE_DIR}/Testing/Data/Configuration/itkv4_SVF_ANTsCC.json --in FixedImage=${CMAKE_BINARY_DIR}/Testing/Data/Input/coneA2d64.mhd MovingImage=${CMAKE_BINARY_DIR}/Testing/Data/Input/coneB2d64.mhd --out ResultImage=2A_image_itkv4_NC.mhd ResultDisplacementField=2A_deformation_itkv4_NC.mhd
)
# Possible grand challenge CMake interface:
#
# add_grand_challenge_submission(
# NAME username
# DRIVER GrandChallengeDriver
# ARGUMENTS ...
# )
#
# The CMake mechanism would be similar to that of integration tests, except
# we would allow users to write their own driver and/or use an executable that
# contains additional functionality for saving results. The macro would also
# invoke a script that uploads results and configurition files to website.
......@@ -36,6 +36,10 @@ macro( _selxapplication_check_name APPLICATION )
endmacro()
macro( _selxapplications_initialize )
if( SUPERELASTIX_APPLICATIONS )
message( FATAL "Applications have already been initialized. _selxapplications_initialize() may only be called once." )
endif()
set( SUPERELASTIX_APPLICATIONS )
file( GLOB_RECURSE APPLICATION_CMAKE_FILES RELATIVE "${CMAKE_SOURCE_DIR}"
......@@ -55,6 +59,7 @@ macro( _selxapplications_initialize )
set( ${APPLICATION}_SOURCE_DIR ${CMAKE_SOURCE_DIR}/${${APPLICATION}_PATH} )
set( ${APPLICATION}_BINARY_DIR ${CMAKE_BINARY_DIR}/${${APPLICATION}_PATH} )
set( ${APPLICATION}_TEST_DIR ${CMAKE_SOURCE_DIR}/${${APPLICATION}_PATH}/test )
# Collect header files for Visual Studio Project
# http://stackoverflow.com/questions/8316104/specify-how-cmake-creates-visual-studio-project
......@@ -107,6 +112,18 @@ macro( _selxapplication_link_libraries TARGET LIBRARIES )
target_link_libraries( ${${TARGET}} ${${LIBRARIES}} )
endmacro()
macro( add_integration_test )
cmake_parse_arguments( add_integration_test "" "NAME;DRIVER" "ARGUMENTS" ${ARGN} )
add_test(
NAME ${add_integration_test_NAME}
COMMAND ${add_integration_test_DRIVER} ${add_integration_test_ARGUMENTS}
)
endmacro()
# TODO: Allow application developers to use arbitrarty test drivers. We
# currently CMake for scripting and executable itself to execute tests.
# Most users will probably prefer not to use CMake for scripting.
# ---------------------------------------------------------------------
# Public macros
......@@ -117,17 +134,16 @@ endmacro()
macro( enable_applications APPLICATIONS )
foreach( APPLICATION ${${APPLICATIONS}} )
message( STATUS "APPLICATION: ${APPLICATION}" )
enable_application( ${APPLICATION} )
endforeach()
endmacro()
macro( disable_application APPLICATION )
_selxapplication_disable( ${APPLICATION} )
_selxapplication_disable( ${APPLICATION} "user" )
endmacro()
macro( disable_applications APPLICATIONS )
foreach( APPLICATION ${${APPLICATIONS}} )
disable_application( ${APPLICATION} "user" )
disable_application( ${APPLICATION} )
endforeach()
endmacro()
......@@ -36,6 +36,10 @@ macro( _selxmodule_check_name MODULE )
endmacro()
macro( _selxmodules_initialize )
if( SUPERELASTIX_MODULES )
message( FATAL "Modules have already been initialized. _selxmodules_initialize() may only be called once." )
endif()
set( SUPERELASTIX_MODULES )
set( SUPERELASTIX_INCLUDE_DIRS )
set( SUPERELASTIX_LIBRARIES )
......@@ -91,7 +95,7 @@ macro( _selxmodule_enable MODULE UPSTREAM )
_selxmodule_link_libraries( ${MODULE} ModuleCore )
endif()
if( SUPERELASTIX_BUILD_TESTING AND ${MODULE}_TEST_SOURCE_FILES )
if( BUILD_TESTING AND ${MODULE}_TEST_SOURCE_FILES )
list( APPEND SUPERELASTIX_TEST_SOURCE_FILES ${${MODULE}_TEST_SOURCE_FILES} )
endif()
......
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