I am using Google Tests to create unit tests for our software.  We are
using CMake (version 4.6-patch 2)  for building the unit tests
executable.  Since the list of unit tests is expected to grow to
thousands of tests, I am looking for a way to automate creating a file
(say testlist) on the fly that will contain the list of all our unit
tests specified using the CTest ADD_TEST command. My thought was to use
INCLUDE(testlist) to read in the list of tests at the appropriate point
in the CMakeLists.txt file(i.e, just after calling ENABLE_TESTING().

 

I have a shell (bash) script (addtestscrpt) that needs to run the unit
tests executable to get the list of all unit tests and then put ADD_TEST
for each of those tests into a file which would look like this:

 

ADD_TEST(DDSCfgTest.ctr ${EXECUTABLE_OUTPUT_PATH}/${BIN_NAME}
--gtest_filter=DDSCfgTest.ctr)

ADD_TEST(DDSCfgTest.ReadBool ${EXECUTABLE_OUTPUT_PATH}/${BIN_NAME}
--gtest_filter=DDSCfgTest.ReadBool)

ADD_TEST(DDSCfgTest.ReadInt ${EXECUTABLE_OUTPUT_PATH}/${BIN_NAME}
--gtest_filter=DDSCfgTest.ReadInt)

 

The problem that I'm having is that I need the unit tests executable to
generate the list of all tests and then INCLUDE the list in a
CMakeList.txt file after the unit tests executable is built. 

 

I tried using ADD_CUSTOM_COMMAND with POST_BUILD to run my shell script
(COMMAND ./addtestscript) which runs and creates the list of ADD_TEST()
commands and puts them in a file. But I don't know how to include this
file in the ADD_CUSTOM_COMMAND

 

The closest I got was:

 

ADD_CUSTOM_COMMAND(TARGET ${BIN_NAME}

    POST_BUILD

    WORKING_DIRECTORY ${SRC_DIR}

    COMMAND bash ./addtestscrpt

    COMMAND ${CMAKE_COMMAND} ${SRC_DIR}/DDSCommonTests/CMakeLists.txt

)

where ${SRC_DIR}/DDSCommonTests/CMakeLists.txt

contains

ENABLE_TESTING()

INCLUDE(${SRC_DIR)/testlist)

 

but this doesn't work presumably because CTest needs to know about the
CTestTestfile.cmake in this directory, again in the post_build step.

 

Is there any way to a) Add the INCLUDE(testlist) to the
ADD_CUSTOM_COMMAND or b) tell CTest to read the CTestTestfile.cmake from
that directory or c) Any other way of solving this?

 

Thanks.

 

 

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to