Skip to content

Commit

Permalink
BUG: Teach 'slicer_add_python_unittest' to add module search paths
Browse files Browse the repository at this point in the history
This commit allows scripted module test within extension to successfully
load dependent modules.

Fixes https://issues.slicer.org/view.php?id=4242

svn-url: http://viewvc.slicer.org/viewvc.cgi/Slicer4?view=revision&revision=25783
git-svn-id: http://svn.slicer.org/Slicer4/trunk@25783 3bd1e089-480b-0410-8dfb-8563597acbee
  • Loading branch information
ihnorton authored and jcfr committed Mar 11, 2017
1 parent 18445af commit f07a6c3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
13 changes: 11 additions & 2 deletions CMake/SlicerMacroPythonTesting.cmake
Expand Up @@ -18,6 +18,12 @@
#
################################################################################

set(UNITTEST_LIB_PATHS
"--additional-module-paths"
${CMAKE_BINARY_DIR}/${Slicer_QTSCRIPTEDMODULES_LIB_DIR}
${CMAKE_BINARY_DIR}/${Slicer_CLIMODULES_LIB_DIR}
${CMAKE_BINARY_DIR}/${Slicer_QTLOADBLEMODULES_LIB_DIR}
)

macro(slicer_add_python_test)
set(options)
Expand All @@ -33,7 +39,9 @@ macro(slicer_add_python_test)
COMMAND ${Slicer_LAUNCHER_EXECUTABLE}
--no-splash
--testing
${Slicer_ADDITIONAL_LAUNCHER_SETTINGS} ${MY_SLICER_ARGS}
${Slicer_ADDITIONAL_LAUNCHER_SETTINGS}
${UNITTEST_LIB_PATHS}
${MY_SLICER_ARGS}
--python-script ${MY_SCRIPT} ${MY_SCRIPT_ARGS}
)
set_property(TEST py_${MY_TESTNAME_PREFIX}${test_name} PROPERTY RUN_SERIAL TRUE)
Expand All @@ -55,8 +63,9 @@ macro(slicer_add_python_unittest)
--no-splash
--testing
${Slicer_ADDITIONAL_LAUNCHER_SETTINGS}
--python-code "import slicer.testing\\; slicer.testing.runUnitTest(['${CMAKE_CURRENT_BINARY_DIR}', '${_script_source_dir}'], '${test_name}')"
${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)
endmacro()
1 change: 0 additions & 1 deletion Modules/Scripted/SegmentEditor/CMakeLists.txt
Expand Up @@ -37,6 +37,5 @@ slicer_add_python_unittest(
# TODO: slicer_add_python_unittest should take care of adding the additional module paths
SLICER_ARGS
--disable-cli-modules
--additional-module-paths ${MODULE_BUILD_DIR} ${CMAKE_BINARY_DIR}/${Slicer_QTSCRIPTEDMODULES_LIB_DIR}
)

0 comments on commit f07a6c3

Please sign in to comment.