[CMake] ctest 'magic string' -> failure

Alan W. Irwin irwin at beluga.phys.uvic.ca
Wed Aug 13 21:47:45 EDT 2008


On 2008-08-13 20:20-0500 Matthew Woehlke wrote:

> Is there any way to arrange for running ctest to mark a test as failed if it 
> outputs a particular string? I'm using ctest to write unit tests for a 
> library that has some debugging facilities where if something goes wrong, it 
> dumps an error message, but doesn't cause the function to fail, so I can't 
> detect it in the test program. (And, no, changing the library is NOT an 
> option.)
>
> Alternatively, there /is/ a hook to make the messages trip an abort()... is 
> there a way to make 'make test'/'ctest' set an environment variable for all 
> tests it runs? Or would I be stuck remembering to set it before calling 'make 
> test'/'ctest'?

If you run your tests as shell scripts, then you can set the exit code of
the shell script depending on any condition you like, and ctest will respond
to all non-zero exit codes as a failed test.  Note, setting up ctest this
way works cross-platform because there are shells (e.g., bash) available for
windows (or so I am told by those PLplot developers who run ctest for PLplot
on windows).

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list