[CMake] How to emulate autotools "make check"?

Eric Noulard eric.noulard at gmail.com
Thu Mar 19 08:47:23 EDT 2009


2009/3/19 Marcel Loose <loose at astron.nl>:
> Hi all,
>
> I've been searching for a way to implement "make check" the GNU
> Autotools way. That is: tests are not compiled and linked as part of the
> "all" target, but as part of the "check" target.
>
> I followed section 10.5 "Using CTest to Drive Complex Tests" of the book
> "Mastering CMake" and I looked at the Tests directory of the CMake
> distribution. From that I created my little toy project "Hello".
>
> Now the problem is: it doesn't work. For details, see below.


[...]

> $ cat test/CMakeLists.txt
> include_directories(${CMAKE_SOURCE_DIR}/src)
> add_test(t_hello ${CMAKE_CTEST_COMMAND}
>  --build-and-test
>  "${CMAKE_CURRENT_SOURCE_DIR}"
>  "${CMAKE_BINARY_SOURCE_DIR}"
>  --build-generator ${CMAKE_GENERATOR}
>  --build-makeprogram ${CMAKE_MAKE_PROGRAM}
>  --build-project t_hello
>  --test-command t_hello)

Then your test is command is to ... run ctest on the same project?
This looks like a endless recursion that will call ctest for ever?


> $ ctest -V

Step 1: you call ctest...

> UpdateCTestConfiguration
> from :/export/home/loose/work/hello/build/DartConfiguration.tcl
> Parse Config
> file:/export/home/loose/work/hello/build/DartConfiguration.tcl
> Start processing tests
> UpdateCTestConfiguration
> from :/export/home/loose/work/hello/build/DartConfiguration.tcl
> Parse Config
> file:/export/home/loose/work/hello/build/DartConfiguration.tcl
> Test project /export/home/loose/work/hello/build
> Constructing a list of tests
> Done constructing a list of tests
> Changing directory into /export/home/loose/work/hello/build/test
>  1/  1 Testing t_hello

then you test is to .... call ctest ...

> Test command: /usr/bin/ctest
> --build-and-test /export/home/loose/work/hello/test  --build-generator
> Unix\ Makefiles --build-makeprogram /usr/bin/gmake --build-project
> t_hello --test-command t_hello

Here you call t_hello which would (if ever it suceed)
call ctest....

> Test timeout computed to be: 1500
> Could not find executable t_hello

Hopefully there is no t_hello executable its a ctest "test name".



-- 
Erk


More information about the CMake mailing list