mirror of
https://github.com/boostorg/python.git
synced 2026-02-02 21:12:15 +00:00
Enable tests in CMake build and fix relative path problems.
As reported in #46, tests were not being built with CMake due to a typo. But they were also broken, because the relative path to the dynamic library used in the link commands for the test Python modules wasn't appropriate for running the tests from the source directory. Instead, we now copy the Python test scripts to the build directory and run them there.
This commit is contained in:
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8.3)
|
||||
|
||||
project( boost.numpy )
|
||||
|
||||
set(BUILD_TEST ON CACHE BOOL "Build Boost.NumPy Tests")
|
||||
set(BUILD_TESTS ON CACHE BOOL "Build Boost.NumPy Tests")
|
||||
set(BUILD_EXAMPLES ON CACHE BOOL "Build Boost.NumPy Examples")
|
||||
|
||||
# put our local cmake find scripts at the beginning of the cmake
|
||||
|
||||
@@ -16,11 +16,19 @@ set( TestCommand ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${runCmakeTest} )
|
||||
|
||||
# custom macro with most of the redundant code for making a python test
|
||||
macro( addPythonTest _name _srcpy )
|
||||
ADD_CUSTOM_TARGET(
|
||||
${_srcpy} ALL
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_srcpy}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/${_srcpy}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${_srcpy}
|
||||
)
|
||||
|
||||
# make the pyd library link against boost_numpy python and boost
|
||||
TARGET_LINK_LIBRARIES(${_name} boost_numpy)
|
||||
|
||||
|
||||
# make a test of the module using the python source file in the test directory
|
||||
ADD_TEST(${_name} ${TestCommand} ${TEST_SOURCE_DIR}/${_srcpy})
|
||||
ADD_TEST(${_name} ${TestCommand} ${CMAKE_CURRENT_BINARY_DIR}/${_srcpy})
|
||||
|
||||
# set the regex to use to recognize a failure since `python testfoo.py`
|
||||
# does not seem to return non-zero with a test failure
|
||||
|
||||
Reference in New Issue
Block a user