[CMake] CTest + Catch Framework

Nils Gladitz nilsgladitz at gmail.com
Wed Jan 28 04:19:31 EST 2015


On 28.01.2015 01:38, Robert Dailey wrote:
> I suspect that per David's suggestion, CTest would essentially do what
> you're doing but in a more thorough manner (based on the test
> framework used). So essentially CTest will need:
>
> - A new command line parameter that specifies the test framework
> - Functionality to parse the contents of source files provided to the
> target the test is assigned to
>
> I'll try to look into this when I can. David, if you have more
> specific requirements or pointers please do share them here. Thanks
> for the input everyone.
>

CMake generates "CTestTestfile.cmake" files which contain the code that 
defines tests during execution of ctest itself.

Those "CTestTestfile.cmake" files could use execute_process() to query 
test binaries for their contained tests and then add tests appropriately.
With that approach there would be no need to parse source files.

This can already be done in a hackish way by using the 
TEST_INCLUDE_FILE[1] directory property.
file(GENERATE) can be used to create per-test-binary/per-configuration 
snippets with executable locations ($<TARGET_FILE>) which then can be 
globbed for and included by CTestTestfile.cmake.

I would still opt for implementing support for this in cmake itself 
though since the entire logic could be contained in the generated 
"CTestTestfile.cmake"s.
Perhaps with a couple of properties that would define how to e.g. query 
the list of tests and the required parameter to run a specific test; 
that way it could be made to work irregardless of which test framework 
is being used.

Nils

[1] http://www.cmake.org/cmake/help/v3.1/prop_dir/TEST_INCLUDE_FILE.html


More information about the CMake mailing list