I recently converted my project to configure with cmake, and am now trying to
get the tests to run under ctest. I may be doing this completely incorrectly,
so let me know if anything you see below looks like a bad idea.
All my tests use a particular program to check the output of the tests against
the correct output. The tests output in a particular format, so I have to use
a particular 'diff' program to compare them. This program was not developed by
me, and is not part of the project. So, I wrote a FindXXXX.cmake file to find
the program and supply the location.
So, I have the path to the diff program as XXXX_BINDIR.
My tests are all driven by a generic script. This script takes a couple of
command line arguments to get the important paths for running the test and
checking the results. Like this:
add_test (test1 ${TEST_SCRIPT_DIR}/test.sh
${PROJECT_BINARY_DIR}/bin/meos ${CMAKE_CURRENT_SOURCE_DIR} test1.input)
If it's not obvious, test.sh is the test script. The first argument is the
path to the binary I'm testing, the second is the directory where both the
input files and expected output files can be found, and the last is the name of
the input for this test.
So, I could pass the path to the 'diff' program as another command line
argument, but that's already beginning to become cumbersome. It's seems more
reasonable just to stick it in the system PATH variable.
I can do that like this:
set_property(TEST test1 PROPERTY ENVIRONMENT PATH="${XXXX_BINDIR}:$ENV{PATH}")
The only annoying thing is, I have to have that line for EVERY test. I have
lots of tests. I would rather set that path for ALL the tests. But I can't
seem to find a way to do that. This doesn't work:
set_property(GLOBAL PROPERTY ENVIRONMENT PATH="${XXXX_BINDIR}:$ENV{PATH}")
Is there a way to set up the environment for all the tests in one line?
Thanks,
Jim
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake