Merge pull request #155 from rolk/153_datafiles

Make `make test` work on release builds
This commit is contained in:
Bård Skaflestad 2013-02-20 05:20:57 -08:00
commit 42e1fc6d10
3 changed files with 27 additions and 12 deletions

View File

@ -242,7 +242,7 @@ opm_compile_satellites (opm-core tests "" "^test_([^/]*)$")
add_custom_target (check
COMMAND ${CMAKE_CTEST_COMMAND}
DEPENDS tests
COMMENT Checking if library is functional
COMMENT "Checking if library is functional"
VERBATIM
)

View File

@ -32,6 +32,7 @@ macro (opm_dist_clean opm)
${tutorial_DEBUG}
install_manifest.txt
${${opm}_STYLESHEET_COPIED}
${tests_INPUT_FILES}
)
# only remove these files if they were actually copied
if (NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)

View File

@ -39,11 +39,18 @@
# opm_compile_satellites (opm-core test "" "^test_([^/]*)$")
#
macro (opm_compile_satellites opm satellite excl_all test_regexp)
# if we are going to build the tests always, then make sure that
# the datafiles are present too
if (NOT (${excl_all} MATCHES "EXCLUDE_ALL"))
set (_incl_all "ALL")
else (NOT (${excl_all} MATCHES "EXCLUDE_ALL"))
set (_incl_all "")
endif (NOT (${excl_all} MATCHES "EXCLUDE_ALL"))
# if a set of datafiles has been setup, pull those in
add_custom_target (${satellite} ${_incl_all})
if (${satellite}_DATAFILES)
add_custom_target (${satellite} DEPENDS ${${satellite}_DATAFILES})
else (${satellite}_DATAFILES)
add_custom_target (${satellite})
add_dependencies (${satellite} ${${satellite}_DATAFILES})
endif (${satellite}_DATAFILES)
# compile each of these separately
@ -71,11 +78,18 @@ macro (opm_compile_satellites opm satellite excl_all test_regexp)
if (NOT ${test_regexp} STREQUAL "")
string (REGEX REPLACE "${test_regexp}" "\\1" _sat_FANCY "${_sat_NAME}")
get_target_property (_sat_LOC ${_sat_NAME} LOCATION)
if (CMAKE_VERSION VERSION_LESS "2.8.4")
add_test (
NAME ${_sat_FANCY}
COMMAND ${CMAKE_COMMAND} -E chdir "${PROJECT_BINARY_DIR}/${${satellite}_DIR}" ${_sat_LOC}
)
else (CMAKE_VERSION VERSION_LESS "2.8.4")
add_test (${_sat_FANCY} ${_sat_LOC})
# run the test in the directory where the data files are
set_tests_properties (${_sat_FANCY} PROPERTIES
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/${${satellite}_DIR}
)
endif (CMAKE_VERSION VERSION_LESS "2.8.4")
endif(NOT ${test_regexp} STREQUAL "")
endforeach (_sat_FILE)
endmacro (opm_compile_satellites opm prefix)
@ -85,7 +99,7 @@ endmacro (opm_compile_satellites opm prefix)
#
# provides these output variables:
#
# ${satellite_INPUT_FILES} List of all files that are copied
# ${satellite}_INPUT_FILES List of all files that are copied
# ${satellite}_DATAFILES Name of target which copies these files
#
# Example:
@ -100,7 +114,7 @@ macro (opm_data satellite target files)
# provide datafiles as inputs for the tests, by copying them
# to a tests/ directory in the output tree (if different)
set (${satellite}_INPUT_FILES)
file (GLOB ${satellite}_DATA "tests/*.xml")
file (GLOB ${satellite}_DATA ${files})
if (NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
foreach (input_datafile IN LISTS ${satellite}_DATA)
file (RELATIVE_PATH rel_datafile "${PROJECT_SOURCE_DIR}" ${input_datafile})