Commit d1403f03 authored by jcfr's avatar jcfr

COMP: Add SlicerMacroPythonTesting file

It contains the following helper macros:
  SLICER_ADD_PYTHON_TEST
  SLICER_ADD_PYTHON_UNITTEST

git-svn-id: http://svn.slicer.org/Slicer4/trunk@16700 3bd1e089-480b-0410-8dfb-8563597acbee
parent 6a6bd695
#
# Python code
# Check if '--python-code' / 'slicer.testing' works as expected
#
ADD_TEST(
......@@ -34,63 +34,27 @@ ADD_TEST(
SET_TESTS_PROPERTIES(py_nomainwindow_SlicerPythonCodeTest4 PROPERTIES WILL_FAIL TRUE)
#
# Python scripts
# Check if '--python-scripts' / 'slicer.testing' works as expected
#
SET(TEST_NOMAINWINDOW_SCRIPTS
SlicerTestingExitSuccessTest.py
SlicerTestingExitFailureTest.py
)
SET(TEST_SCRIPTS
${TEST_NOMAINWINDOW_SCRIPTS}
)
MACRO(SLICER_ADD_PYTHON_TEST)
set(options)
set(oneValueArgs TESTNAME_PREFIX SLICER_ARGS SCRIPT)
set(multiValueArgs SCRIPT_ARGS)
cmake_parse_arguments(MY "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
get_filename_component(test_name ${MY_SCRIPT} NAME_WE)
ADD_TEST(
NAME py_${MY_TESTNAME_PREFIX}${test_name}
COMMAND ${Slicer_LAUNCH_COMMAND} $<TARGET_FILE:SlicerQT${SlicerQT_EXE_SUFFIX}>
--no-splash --ignore-slicerrc ${MY_SLICER_ARGS} --python-script ${CMAKE_CURRENT_SOURCE_DIR}/${MY_SCRIPT} ${MY_SCRIPT_ARGS}
)
ENDMACRO()
FOREACH(script ${TEST_NOMAINWINDOW_SCRIPTS})
SLICER_ADD_PYTHON_TEST(SCRIPT ${script} SLICER_ARGS --no-main-window TESTNAME_PREFIX nomainwindow_)
#SET_TESTS_PROPERTIES(py_${test_name} PROPERTIES RUN_SERIAL TRUE)
ENDFOREACH()
SLICER_ADD_PYTHON_TEST(
SCRIPT SlicerTestingExitSuccessTest.py
SLICER_ARGS --no-main-window TESTNAME_PREFIX nomainwindow_)
SLICER_ADD_PYTHON_TEST(
SCRIPT SlicerTestingExitFailureTest.py
SLICER_ARGS --no-main-window TESTNAME_PREFIX nomainwindow_)
SET_TESTS_PROPERTIES(py_nomainwindow_SlicerTestingExitFailureTest PROPERTIES WILL_FAIL TRUE)
FOREACH(script ${TEST_SCRIPTS})
SLICER_ADD_PYTHON_TEST(SCRIPT ${script})
#SET_TESTS_PROPERTIES(py_${test_name} PROPERTIES RUN_SERIAL TRUE)
ENDFOREACH()
SLICER_ADD_PYTHON_TEST(SCRIPT SlicerTestingExitSuccessTest.py)
SLICER_ADD_PYTHON_TEST(SCRIPT SlicerTestingExitFailureTest.py)
SET_TESTS_PROPERTIES(py_SlicerTestingExitFailureTest PROPERTIES WILL_FAIL TRUE)
#
# Unittests
# Check if 'slicer.testing.runUnitTest()' works as expected
#
MACRO(SLICER_ADD_PYTHON_UNITTEST)
set(options)
set(oneValueArgs TESTNAME_PREFIX SCRIPT)
set(multiValueArgs SLICER_ARGS)
cmake_parse_arguments(MY "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
get_filename_component(test_name ${MY_SCRIPT} NAME_WE)
ADD_TEST(
NAME py_${MY_TESTNAME_PREFIX}${test_name}
COMMAND ${Slicer_LAUNCH_COMMAND} $<TARGET_FILE:SlicerQT${SlicerQT_EXE_SUFFIX}>
--no-splash --ignore-slicerrc ${MY_SLICER_ARGS}
--python-code "import slicer.testing; slicer.testing.runUnitTest('${CMAKE_CURRENT_SOURCE_DIR}', '${test_name}')"
)
ENDMACRO()
SLICER_ADD_PYTHON_UNITTEST(
SCRIPT SlicerUnitTestTest.py
SLICER_ARGS --no-main-window --disable-cli-module --disable-loadable-module
......
################################################################################
#
# Program: 3D Slicer
#
# Copyright (c) 2010 Kitware Inc.
#
# See Doc/copyright/copyright.txt
# or http://www.slicer.org/copyright/copyright.txt for details.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This file was originally developed by Jean-Christophe Fillion-Robin, Kitware Inc.
# and was partially funded by NIH grant 3P41RR013218-12S1
#
################################################################################
MACRO(SLICER_ADD_PYTHON_TEST)
set(options)
set(oneValueArgs TESTNAME_PREFIX SLICER_ARGS SCRIPT)
set(multiValueArgs SCRIPT_ARGS)
cmake_parse_arguments(MY "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
get_filename_component(test_name ${MY_SCRIPT} NAME_WE)
ADD_TEST(
NAME py_${MY_TESTNAME_PREFIX}${test_name}
COMMAND ${Slicer_LAUNCH_COMMAND} $<TARGET_FILE:SlicerQT${SlicerQT_EXE_SUFFIX}>
--no-splash --ignore-slicerrc ${MY_SLICER_ARGS} --python-script ${CMAKE_CURRENT_SOURCE_DIR}/${MY_SCRIPT} ${MY_SCRIPT_ARGS}
)
ENDMACRO()
MACRO(SLICER_ADD_PYTHON_UNITTEST)
set(options)
set(oneValueArgs TESTNAME_PREFIX SCRIPT)
set(multiValueArgs SLICER_ARGS)
cmake_parse_arguments(MY "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
get_filename_component(test_name ${MY_SCRIPT} NAME_WE)
ADD_TEST(
NAME py_${MY_TESTNAME_PREFIX}${test_name}
COMMAND ${Slicer_LAUNCH_COMMAND} $<TARGET_FILE:SlicerQT${SlicerQT_EXE_SUFFIX}>
--no-splash --ignore-slicerrc ${MY_SLICER_ARGS}
--python-code "import slicer.testing; slicer.testing.runUnitTest('${CMAKE_CURRENT_SOURCE_DIR}', '${test_name}')"
)
ENDMACRO()
......@@ -284,6 +284,7 @@ IF(BUILD_TESTING)
SET(Slicer_LAUNCH_COMMAND ${Slicer_LAUNCHER_EXECUTABLE} --launcher-no-splash --launch)
INCLUDE(CTest)
INCLUDE(SlicerMacroPythonTesting)
INCLUDE(MIDAS)
SET(MIDAS_REST_URL "http://midas.kitware.com/api/rest" CACHE STRING "The MIDAS server where testing data resides")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment