TestDriverPython.cmake.in 930 Bytes
Newer Older
1 2 3
SET(python_runtime @PYTHON_EXECUTABLE@)
SET(python_binary_dir @CMAKE_CURRENT_BINARY_DIR@)

4
SET(ENV{PYTHONPATH} "${PYTHONPATH}${SEPARATOR}$ENV{PYTHONPATH}")
5

6
MESSAGE("| Calling:\t${python_runtime} ${EXECUTABLE} ${ARGUMENTS}")
7 8 9 10 11 12 13 14
EXECUTE_PROCESS(
    	COMMAND ${python_runtime} ${EXECUTABLE}.pyc ${ARGUMENTS}
		WORKING_DIRECTORY ${python_binary_dir}
    		RESULT_VARIABLE python_result
    		OUTPUT_VARIABLE python_output
 		ERROR_VARIABLE python_error
)

15 16 17 18 19 20 21 22 23
MESSAGE("| Call Result:\t${python_result}")
MESSAGE("| Call Output: Begin\n${python_output}")
MESSAGE("| Call Output: End")
IF(python_error)
	MESSAGE("Call Error: Begin\n${python_error}")
	MESSAGE("Call Error: End")
ENDIF(python_error)
MESSAGE("| Call Ended")
MESSAGE("----------------------------------------------------------")
24

25
# Let's make sure that if the test failed, it failed with CTest too
26 27 28 29
IF(python_result)
	MESSAGE(SEND_ERROR "${python_result}")
ENDIF(python_result)