[CMake] [CTest] ADD_TEST and working directory

Mathieu Malaterre mathieu.malaterre at gmail.com
Thu Apr 26 11:19:28 EDT 2007


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,

-- 
Mathieu


More information about the CMake mailing list