[CMake] Compilation failure req'd for successful test
Brad King
brad.king at kitware.com
Tue Apr 26 13:39:05 EDT 2005
Walter E Brown wrote:
> As part of a project's testing, we need to ensure that a compilation
> failure will correctly occur under specific circumstances. In
> particular, we wish at ctest time:
>
> - to compile (but not link) a specific program that we expect to fail
> compilation, then
>
> - to capture the detailed output of that compilation into a file, and
> then
>
> - to run some other program (perhaps a tool like grep or perhaps a
> custom script) that inspects that attempted compilation's output for
> certain characteristics of interest, and finally
>
> - to indicate the success or failure of the test based on the results
> of such inspection.
>
> Alas, it is unclear to us how to set this up; neither the book nor the
> online help seem on point. Can someone advise us, preferably with
> sample cmake/ctest code that we can use as a model?
Currently there is no easy way to do this. You may have to create a
program that drives this process itself and then add the program as the
test. It can use "ctest --build-and-test ..." to drive the build and
then capture the exit code and output. You can look at
CMake/Source/kwsys (and even copy the library) to get some nice
cross-platform process execution code to help achieve this.
In the long run this should be a ctest feature accessible through an
option like "--build-fail-compile". Please add it as a feature request
here:
http://www.cmake.org/Bug
Thanks,
-Brad
More information about the CMake
mailing list