Private
Public Access
2
0
Files
mraa/tests/CMakeLists.txt
Brendan Le Foll 1d37d3b162 tests/CMakeLists.txt: Clean up cmake tests to work with python 2&3
Adds additional checks and PYTHON_DEFAULT_INTERP var that is used to
find the correct python binary as well as checks to see if the
_python2-mraa or _python3-mraa targets have been built by checking
mraa.py. This does assume that this is all that is needed as checking
for TARGET() is not enough as the target is always 'valid'. We prefer
python2 and will only run the java tests if we can find python2

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
2017-05-30 19:31:34 +02:00

35 lines
1.7 KiB
CMake

if (PYTHON2INTERP_FOUND AND BUILDSWIGJAVA)
add_test (NAME check_clean COMMAND ${PYTHON_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/check_clean.py
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_test (NAME check_samplenames COMMAND ${PYTHON_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/check_samplenames.py
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif ()
if (BUILDSWIGPYTHON)
if (PYTHON2INTERP_FOUND AND EXISTS "${CMAKE_BINARY_DIR}/src/python/python2/mraa.py")
set (PYTHON_DEFAULT_PYTHONPATH "${CMAKE_BINARY_DIR}/src/python/python2")
set (PYTHON_DEFAULT_INTERP "${PYTHON2_EXECUTABLE}")
elseif (PYTHON3INTERP_FOUND AND EXISTS "${CMAKE_BINARY_DIR}/src/python/python3/mraa.py")
set (PYTHON_DEFAULT_PYTHONPATH "${CMAKE_BINARY_DIR}/src/python/python3")
set (PYTHON_DEFAULT_INTERP "${PYTHON3_EXECUTABLE}")
else ()
message (STATUS "Could not run tests since python interpreter or python bindings not built")
endif ()
if (MOCKPLAT)
add_subdirectory (mock)
else ()
add_test (NAME py_general COMMAND ${PYTHON_DEFAULT_INTERP} ${CMAKE_CURRENT_SOURCE_DIR}/general_checks.py)
set_tests_properties(py_general PROPERTIES ENVIRONMENT "PYTHONPATH=${PYTHON_DEFAULT_PYTHONPATH}")
add_test (NAME py_platform COMMAND ${PYTHON_DEFAULT_INTERP} ${CMAKE_CURRENT_SOURCE_DIR}/platform_checks.py)
set_tests_properties(py_platform PROPERTIES ENVIRONMENT "PYTHONPATH=${PYTHON_DEFAULT_PYTHONPATH}")
add_test (NAME py_gpio COMMAND ${PYTHON_DEFAULT_INTERP} ${CMAKE_CURRENT_SOURCE_DIR}/gpio_checks.py)
set_tests_properties(py_gpio PROPERTIES ENVIRONMENT "PYTHONPATH=${PYTHON_DEFAULT_PYTHONPATH}")
endif ()
endif ()