Skip to content

Commit

Permalink
Sync to template
Browse files Browse the repository at this point in the history
  • Loading branch information
jschueller committed Nov 15, 2023
1 parent 8da18ac commit cc234ba
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 104 deletions.
10 changes: 3 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,10 @@ if (BUILD_PYTHON)
endif ()
endif ()

if (DEFINED PYTHON_SITE_PACKAGES)
set (OTMORRIS_PYTHON_MODULE_PATH "${PYTHON_SITE_PACKAGES}")
if (WIN32)
set (OTMORRIS_PYTHON_MODULE_PATH Lib/site-packages CACHE PATH "site-packages dir")
else ()
if (WIN32)
set (OTMORRIS_PYTHON_MODULE_PATH Lib/site-packages)
else ()
set (OTMORRIS_PYTHON_MODULE_PATH ${CMAKE_INSTALL_LIBDIR}/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages)
endif ()
set (OTMORRIS_PYTHON_MODULE_PATH ${CMAKE_INSTALL_LIBDIR}/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages CACHE PATH "site-packages dir")
endif ()
endif ()
endif ()
Expand Down
79 changes: 26 additions & 53 deletions lib/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,63 +5,36 @@ endif ()

set (CHECK_ENVIRONMENT)

set ( CHECK_TO_BE_RUN )
macro ( ot_check_test TESTNAME )
set ( TESTNAME_TGT t_${TESTNAME} )
set ( TESTNAME_SRC ${TESTNAME_TGT}.cxx )
set ( TESTNAME_SRCS ${TESTNAME_SRC} )
add_executable ( ${TESTNAME_TGT} EXCLUDE_FROM_ALL ${TESTNAME_SRCS} )
add_dependencies ( tests ${TESTNAME_TGT} )
target_link_libraries ( ${TESTNAME_TGT} otmorris )
set (CHECK_TO_BE_RUN)
macro (ot_check_test TESTNAME)
set (TEST_TARGET t_${TESTNAME})
add_executable (${TEST_TARGET} EXCLUDE_FROM_ALL ${TEST_TARGET}.cxx)
add_dependencies(tests ${TEST_TARGET})
target_link_libraries (${TEST_TARGET} PRIVATE otmorris)
if (MINGW AND CMAKE_SIZEOF_VOID_P EQUAL 4)
target_link_libraries (${TESTNAME_TGT} CRT_fp8)
target_link_libraries (${TEST_TARGET} PRIVATE CRT_fp8)
endif ()
set_target_properties ( ${TESTNAME_TGT} PROPERTIES
UNITY_BUILD OFF
INSTALL_RPATH "${CMAKE_BINARY_DIR}/lib/src;${CMAKE_INSTALL_RPATH}" )
set ( TESTNAME_LOC ${CMAKE_CURRENT_BINARY_DIR}/${TESTNAME_TGT}${CMAKE_EXECUTABLE_SUFFIX} )
set ( _CMD )
set ( _PRE )
set ( _POST )
set ( _PARAMS )
set ( _IGNOREOUT OFF )
foreach ( _ARG ${ARGN} )
string ( TOUPPER ${_ARG} ARG )
if ( ${ARG} MATCHES PRE )
set ( _CMD PRE )
elseif ( ${ARG} MATCHES POST )
set ( _CMD POST )
elseif ( ${ARG} MATCHES PARAMS )
set ( _CMD PARAMS )
elseif ( ${ARG} MATCHES IGNOREOUT )
set ( _IGNOREOUT ON )
else ( ${ARG} MATCHES PRE )
if ( ${_CMD} MATCHES PRE )
set ( _PRE "${_PRE} ${_ARG} && " )
elseif ( ${_CMD} MATCHES POST )
set ( _POST "${_POST} && ${_ARG}" )
elseif ( ${_CMD} MATCHES PARAMS )
set ( _PARAMS "${_PARAMS} ${_ARG}" )
endif ( ${_CMD} MATCHES PRE )
set ( _CMD )
endif ( ${ARG} MATCHES PRE )
endforeach ( _ARG )
set_target_properties (${TEST_TARGET} PROPERTIES
UNITY_BUILD OFF
INSTALL_RPATH "${PROJECT_BINARY_DIR}/lib/src;${CMAKE_INSTALL_RPATH}")
set (_IGNOREOUT OFF)
foreach (_ARG ${ARGN})
if (${_ARG} MATCHES IGNOREOUT)
set (_IGNOREOUT ON)
endif ()
endforeach ()

if (_IGNOREOUT)
set ( COMMAND "( ${CMAKE_CROSSCOMPILING_EMULATOR} ${TESTNAME_LOC} ${_PARAMS} > /dev/null )" )
else (_IGNOREOUT)
set ( TESTNAME_OUT ${TESTNAME_TGT}.expout )
set ( OUTFILE_LOC ${CMAKE_CURRENT_SOURCE_DIR}/${TESTNAME_OUT} )
set ( COMMAND "( ${CMAKE_CROSSCOMPILING_EMULATOR} ${TESTNAME_LOC} ${_PARAMS} > ${CMAKE_CURRENT_BINARY_DIR}/${TESTNAME_TGT}.out ) && diff -u --strip-trailing-cr ${OUTFILE_LOC} ${CMAKE_CURRENT_BINARY_DIR}/${TESTNAME_TGT}.out" )
endif (_IGNOREOUT)

if (_PRE OR _POST)
set ( COMMAND "${_PRE}${COMMAND}${_POST}" )
endif (_PRE OR _POST)

add_test ( cppcheck_${TESTNAME} "sh" "-c" "${COMMAND}" )
set_tests_properties ( cppcheck_${TESTNAME} PROPERTIES ENVIRONMENT "${CHECK_ENVIRONMENT}" )
list ( APPEND CHECK_TO_BE_RUN ${TESTNAME_TGT} )
add_test (NAME cppcheck_${TESTNAME} COMMAND ${TEST_TARGET})
else ()
set (OUTFILE_LOC ${CMAKE_CURRENT_SOURCE_DIR}/${TEST_TARGET}.expout)
if (NOT EXISTS ${OUTFILE_LOC})
message (SEND_ERROR "Missing file ${OUTFILE_LOC}")
endif ()
add_test (NAME cppcheck_${TESTNAME} COMMAND "sh" "-c" "(${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:${TEST_TARGET}> > ${CMAKE_CURRENT_BINARY_DIR}/${TEST_TARGET}.out) && diff -u --strip-trailing-cr ${OUTFILE_LOC} ${CMAKE_CURRENT_BINARY_DIR}/${TEST_TARGET}.out")
endif ()
set_tests_properties (cppcheck_${TESTNAME} PROPERTIES ENVIRONMENT "${CHECK_ENVIRONMENT}")
list (APPEND CHECK_TO_BE_RUN ${TEST_TARGET})
endmacro ()

include_directories ( ${INTERNAL_INCLUDE_DIRS} )
Expand Down
61 changes: 17 additions & 44 deletions python/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,54 +12,28 @@ set ( PYINSTALLCHECK_ENVIRONMENT "OPENTURNS_CONFIG_PATH=${INSTALL_DESTDIR}${SYSC
)


set ( PYINSTALLCHECK_TO_BE_RUN )
macro ( ot_pyinstallcheck_test TESTNAME )
set ( TESTNAME_TGT t_${TESTNAME} )
set ( TESTNAME_SRC ${TESTNAME_TGT}.py )
set ( TESTNAME_LOC ${CMAKE_CURRENT_SOURCE_DIR}/${TESTNAME_SRC})
set ( _CMD )
set ( _PRE )
set ( _POST )
set ( _PARAMS )
set ( _IGNOREOUT OFF )
foreach ( _ARG ${ARGN} )
string ( TOUPPER ${_ARG} ARG )
if ( ${ARG} MATCHES PRE )
set ( _CMD PRE )
elseif ( ${ARG} MATCHES POST )
set ( _CMD POST )
elseif ( ${ARG} MATCHES PARAMS )
set ( _CMD PARAMS )
elseif ( ${ARG} MATCHES IGNOREOUT )
set ( _IGNOREOUT ON )
else ( ${ARG} MATCHES PRE )
if ( ${_CMD} MATCHES PRE )
set ( _PRE "${_PRE} ${_ARG} && " )
elseif ( ${_CMD} MATCHES POST )
set ( _POST "${_POST} && ${_ARG}" )
elseif ( ${_CMD} MATCHES PARAMS )
set ( _PARAMS "${_PARAMS} ${_ARG}" )
endif ( ${_CMD} MATCHES PRE )
set ( _CMD )
endif ( ${ARG} MATCHES PRE )
endforeach ( _ARG )

macro (ot_pyinstallcheck_test TESTNAME)
set (TEST_TARGET t_${TESTNAME})
set (TESTNAME_LOC ${CMAKE_CURRENT_SOURCE_DIR}/${TEST_TARGET}.py)

set (_IGNOREOUT OFF)
foreach (_ARG ${ARGN})
if (${_ARG} MATCHES IGNOREOUT)
set (_IGNOREOUT ON)
endif ()
endforeach ()

if (_IGNOREOUT)
set ( COMMAND "( ${Python_EXECUTABLE} ${TESTNAME_LOC} ${_PARAMS} > /dev/null )" )
add_test (NAME pyinstallcheck_${TESTNAME} COMMAND ${Python_EXECUTABLE} ${TESTNAME_LOC})
else ()
set ( TESTNAME_OUT ${TESTNAME_TGT}.expout )
set ( OUTFILE_LOC ${CMAKE_CURRENT_SOURCE_DIR}/${TESTNAME_OUT} )
set ( COMMAND "( ${Python_EXECUTABLE} ${TESTNAME_LOC} ${_PARAMS} > ${CMAKE_CURRENT_BINARY_DIR}/${TESTNAME_TGT}.out ) && diff -u --strip-trailing-cr ${OUTFILE_LOC} ${CMAKE_CURRENT_BINARY_DIR}/${TESTNAME_TGT}.out" )
set (OUTFILE_LOC ${CMAKE_CURRENT_SOURCE_DIR}/${TEST_TARGET}.expout)
if (NOT EXISTS ${OUTFILE_LOC})
message (SEND_ERROR "Missing file ${OUTFILE_LOC}")
endif ()
add_test (NAME pyinstallcheck_${TESTNAME} COMMAND "sh" "-c" "(${Python_EXECUTABLE} ${TESTNAME_LOC} > ${CMAKE_CURRENT_BINARY_DIR}/${TEST_TARGET}.out) && diff -u --strip-trailing-cr ${OUTFILE_LOC} ${CMAKE_CURRENT_BINARY_DIR}/${TEST_TARGET}.out")
endif ()

if (_PRE OR _POST)
set ( COMMAND "${_PRE}${COMMAND}${_POST}" )
endif (_PRE OR _POST)

add_test (pyinstallcheck_${TESTNAME} "sh" "-c" "${COMMAND}")

set_tests_properties (pyinstallcheck_${TESTNAME} PROPERTIES ENVIRONMENT "${PYINSTALLCHECK_ENVIRONMENT}")
list (APPEND PYINSTALLCHECK_TO_BE_RUN ${TESTNAME_SRC})
endmacro ()

ot_pyinstallcheck_test (MorrisExperiment_std)
Expand All @@ -82,7 +56,6 @@ if (MATPLOTLIB_FOUND)
endif ()

add_custom_target ( pyinstallcheck COMMAND ${CMAKE_CTEST_COMMAND} -R "^pyinstallcheck_"
DEPENDS ${PYINSTALLCHECK_TO_BE_RUN}
COMMENT "Run Python post-installation tests" )


0 comments on commit cc234ba

Please sign in to comment.