[CMake] ctest return code

Bill Hoffman bill.hoffman at kitware.com
Wed Feb 15 15:11:30 EST 2012


On 2/15/2012 2:44 PM, Tom Deblauwe wrote:
> Hello,
>
> In attachment a project which illustrates the problem.
>
> Just change the directory in the ctest script
> "continuous_dashboard.cmake" to where your source is.
>
> Then i run ctest in my bash script. I'm in git bash on windows now, but
> I get the problem on linux too.
>
> tdb at PCTDBP /c/werk/cmake_tests
> $ ctest -S dashboard/continuous_dashboard.cmake -VV
> \
...
> 1: Test timeout computed to be: 600
> 1/1 Test #1: testMylibTest ....................***Failed 0.05 sec
>
> 0% tests passed, 1 tests failed out of 1
>
> Total Test time (real) = 2.44 sec
>
> The following tests FAILED:
> 1 - testMylibTest (Failed)
>
> Then after ctest exits I do:
> tdb at PCTDBP /c/werk/cmake_tests
> $ echo $?
> 0
>
> As you can see: the test failed, but ctest just returns 0.
>

That is because the ctest -S script worked.  If you want it to fail, you 
will have to modify the continuous_dashboard.cmake script to look at the 
results of ctest_test and then use a message(FATAL_ERROR "tests failed") 
   if there was a failing test.

-Bill



More information about the CMake mailing list