On 4/26/07, Mathieu Malaterre <[EMAIL PROTECTED]> wrote:
On 4/26/07, Bill Hoffman <[EMAIL PROTECTED]> wrote: > Mathieu Malaterre wrote: > > Hello, > > > > According to cmake documentation, ADD_TEST will always execute a test: > > > > The test will be run with the current > > working directory set to the CMakeList.txt files corresponding > > directory in the binary tree. > > > > In my case I need to load a python module, I decided to try > > something very simple: > > > > #1, setting the PYTHONPATH on the same line as the python executable: > > > > SET(myenv "PYTHONPATH=${LIBRARY_OUTPUT_PATH}") > > SET(my_test "from test_mymodule import *\;test_mymodule()") > > ADD_TEST(PYTHON-TEST-MYMODULE ${myenv} python -c ${my_test}) > > > > unfortunately ctest expect the first argument to be an executable. > > > > #2 > > I then tried setting properly the env var by doing: > > > > SET(ENV{PYTHONPATH} ${LIBRARY_OUTPUT_PATH}) > > SET(my_test "from test_mymodule import *\;test_mymodule()") > > ADD_TEST(PYTHON-TEST-MYMODULE python -c ${my_test}) > > > > still no luck. The test does not seems to be running correctly. > > > > Anything else to be able to automate this simple test ? > > > > Thanks for suggestion, > > > Make the test a cmake script that runs python. cmake -P myscript.cmake.sweet ! I just found out how to return the value of a cmake script back to ADD_TEST: MACRO(TEST command expected) IF("x${result}" STREQUAL "x${expected}") #MESSAGE("TEST \"${command}\" success: \"${result}\" expected: \"${expected}\"") ELSE("x${result}" STREQUAL "x${expected}") MESSAGE(SEND_ERROR "${CMAKE_CURRENT_LIST_LINE}: TEST \"${command}\" failed: \"${result}\" expected: \"${expected}\"") ENDIF("x${result}" STREQUAL "x${expected}") ENDMACRO(TEST command expected) MESSAGE(SEND_ERROR was the key.
Just for reference here it is: http://gdcm.svn.sourceforge.net/viewvc/gdcm/Sandbox/CMakeModules/UsePythonTest.cmake?view=markup -M _______________________________________________ CMake mailing list [email protected] http://www.cmake.org/mailman/listinfo/cmake
