Skip to content
Snippets Groups Projects
Commit 25d7b002 authored by Gigg, Martyn Anthony's avatar Gigg, Martyn Anthony
Browse files

Include helper code for Python unit tests... Refs #6219.

in an analogous way that it is done with cxxtest_add_test.
parent 1ff8b35c
No related branches found
No related tags found
No related merge requests found
......@@ -25,9 +25,22 @@ macro ( PYUNITTEST_ADD_TEST _pyunit_testname_file )
set ( _pyunit_testfiles ${_pyunit_testfiles} ${_pyunit_outputdir}/${_pyunit_file} )
endforeach (part ${ARGN})
# The TESTHELPER_PY_FILES variable can be used outside of this macro
# to include any helper classes that are not run through the python unittest generator
set ( _testhelper_files "" )
foreach (part ${TESTHELPER_PY_FILES})
get_filename_component(_testhelper_file ${part} NAME)
add_custom_command ( OUTPUT ${_pyunit_outputdir}/${_testhelper_file}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${part}
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/${part}
${_pyunit_outputdir}/${_testhelper_file} )
set ( _testhelper_files ${_testhelper_files} ${_pyunit_outputdir}/${_testhelper_file} )
endforeach (part ${ARGN})
# Main test target
add_custom_target ( ${_pyunit_testname_file}
DEPENDS ${_pyunit_testfiles}
DEPENDS ${_pyunit_testfiles} ${_testhelper_files}
COMMAND ${PYTHON_EXECUTABLE} ${PYUNITTEST_GEN_EXEC}
-o ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/${_pyunit_testname_file}
-d ${_pyunit_outputdir}
......
......@@ -55,6 +55,7 @@ add_subdirectory ( mantid )
###########################################################################
# Python algorithms
###########################################################################
clean_orphaned_pyc_files ( ${CMAKE_CURRENT_SOURCE_DIR}/PythonAlgorithms )
add_compile_py_target( PythonAlgorithms ${CMAKE_CURRENT_SOURCE_DIR}/PythonAlgorithms )
add_dependencies( PythonAPIModule PythonAlgorithms )
......@@ -146,27 +147,16 @@ set ( TEST_PY_FILES
test/python/WorkspaceValidatorsTest.py
)
set ( PYTEST_HELPERS test/python/testhelpers.py )
# python unit tests
if (PYUNITTEST_FOUND)
# pyunittest_add_test macro understands the TESTHELPER_PY_FILES variable. It is scoped to this file
# so does not need to be cleared
set ( TESTHELPER_PY_FILES test/python/testhelpers.py )
pyunittest_add_test ( VanillaPythonInterfaceTest.py ${TEST_PY_FILES} )
# Helpers
set ( VANILLA_TEST_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/VanillaPythonInterfaceTest )
set ( PYTEST_HELPER_INSTALLS "" )
foreach( PYTEST_HELPER ${PYTEST_HELPERS} )
get_filename_component(helper_file ${PYTEST_HELPER} NAME)
add_custom_command ( OUTPUT ${VANILLA_TEST_DIR}/${helper_file}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${PYTEST_HELPER}
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/${PYTEST_HELPER}
${VANILLA_TEST_DIR}/${helper_file} )
set ( PYTEST_HELPER_INSTALLS ${PYTEST_HELPER_INSTALLS} ${VANILLA_TEST_DIR}/${helper_file} )
endforeach( PYTEST_HELPER ${PYTEST_HELPERS} )
add_custom_target ( PythonTestHelpers DEPENDS ${PYTEST_HELPER_INSTALLS} )
# Test Dependencies
add_dependencies ( VanillaPythonInterfaceTest.py PythonInterface Algorithms PythonTestHelpers )
add_dependencies ( VanillaPythonInterfaceTest.py PythonInterface Algorithms )
add_dependencies ( FrameworkTests VanillaPythonInterfaceTest.py )
# Add to the 'UnitTests' group in VS
set_property ( TARGET VanillaPythonInterfaceTest.py PROPERTY FOLDER "UnitTests" )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment