Skip to content

Commit

Permalink
COMP: Fix setting module paths associated with slicer_add_python test…
Browse files Browse the repository at this point in the history
…ing macros

This commit is a follow-up of f07a6c3 (BUG: Teach 'slicer_add_python_unittest'
to add module search paths).

It ensures that arguments like "--disable-modules", "--disable-*-modules",
"--disable-builtin-modules" or "--disable-builtin-*-modules" that are
associated with SLICER_ARGS works as expected when running Slicer built-in
tests.
  • Loading branch information
jcfr committed May 30, 2023
1 parent 37e1eb9 commit 18346ff
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions CMake/SlicerMacroPythonTesting.cmake
Expand Up @@ -34,13 +34,15 @@ macro(slicer_add_python_test)
if(NOT IS_ABSOLUTE ${MY_SCRIPT})
set(MY_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/${MY_SCRIPT}")
endif()
if(NOT Slicer_SOURCE_DIR)
list(APPEND MY_SLICER_ARGS ${UNITTEST_LIB_PATHS})
endif()
ExternalData_add_test(${Slicer_ExternalData_DATA_MANAGEMENT_TARGET}
NAME py_${MY_TESTNAME_PREFIX}${test_name}
COMMAND ${Slicer_LAUNCHER_EXECUTABLE}
--no-splash
--testing
${Slicer_ADDITIONAL_LAUNCHER_SETTINGS}
${UNITTEST_LIB_PATHS}
${MY_SLICER_ARGS}
--python-script ${MY_SCRIPT} ${MY_SCRIPT_ARGS}
)
Expand All @@ -57,14 +59,16 @@ macro(slicer_add_python_unittest)
if("${_script_source_dir}" STREQUAL "")
set(_script_source_dir ${CMAKE_CURRENT_SOURCE_DIR})
endif()
if(NOT Slicer_SOURCE_DIR)
list(APPEND MY_SLICER_ARGS ${UNITTEST_LIB_PATHS})
endif()
ExternalData_add_test(${Slicer_ExternalData_DATA_MANAGEMENT_TARGET}
NAME py_${MY_TESTNAME_PREFIX}${test_name}
COMMAND ${Slicer_LAUNCHER_EXECUTABLE}
--no-splash
--testing
${Slicer_ADDITIONAL_LAUNCHER_SETTINGS}
${MY_SLICER_ARGS}
${UNITTEST_LIB_PATHS}
--python-code "import slicer.testing\\; slicer.testing.runUnitTest(['${CMAKE_CURRENT_BINARY_DIR}', '${_script_source_dir}'], '${test_name}')"
)
set_property(TEST py_${MY_TESTNAME_PREFIX}${test_name} PROPERTY RUN_SERIAL TRUE)
Expand Down

0 comments on commit 18346ff

Please sign in to comment.