Skip to content

Commit

Permalink
cmake: Factorize python_parser test setup and add windows dll path
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisv committed Nov 8, 2024
1 parent 6b275d8 commit 0d81fe2
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions unittest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,18 @@ function(ADD_PINOCCHIO_UNIT_TEST name)

if(unit_test_PYTHON_PARSER)
target_link_libraries(${TEST_NAME} PUBLIC ${PROJECT_NAME}_python_parser)
add_windows_dll_path_to_test(${TEST_NAME})
get_test_property(${TEST_NAME} ENVIRONMENT ENV_VARIABLES)
compute_pythonpath(PYTHON_ENV_VARIABLES "bindings/python")
list(APPEND ENV_VARIABLES ${PYTHON_ENV_VARIABLES})
if(WIN32)
# This line is mandatory because of Github action. The test run well on Windows + Conda. This
# hide something wrong. Maybe the test is linking against the wrong Python library or call the
# wrong interpreter.
get_filename_component(_PYTHONHOME ${PYTHON_EXECUTABLE} PATH)
list(APPEND ENV_VARIABLES "PYTHONHOME=${_PYTHONHOME}")
endif()
set_tests_properties(${TEST_NAME} PROPERTIES ENVIRONMENT "${ENV_VARIABLES}")
endif()

modernize_target_link_libraries(
Expand Down Expand Up @@ -229,19 +241,6 @@ endif()

if(BUILD_WITH_PYTHON_PARSER_SUPPORT)
add_pinocchio_unit_test(python_parser PYTHON_PARSER)
get_cpp_test_name(python_parser ${CMAKE_CURRENT_SOURCE_DIR} python_parser_target)

get_test_property(${python_parser_target} ENVIRONMENT ENV_VARIABLES)
compute_pythonpath(PYTHON_ENV_VARIABLES "bindings/python")
list(APPEND ENV_VARIABLES ${PYTHON_ENV_VARIABLES})
if(WIN32)
# This line is mandatory because of Github action. The test run well on Windows + Conda. This
# hide something wrong. Maybe the test is linking against the wrong Python library or call the
# wrong interpreter.
get_filename_component(_PYTHONHOME ${PYTHON_EXECUTABLE} PATH)
list(APPEND ENV_VARIABLES "PYTHONHOME=${_PYTHONHOME}")
endif()
set_tests_properties(${python_parser_target} PROPERTIES ENVIRONMENT "${ENV_VARIABLES}")
endif()

if(BUILD_PYTHON_INTERFACE)
Expand Down

0 comments on commit 0d81fe2

Please sign in to comment.