[CMake] Testing exceptions through CTest

Kedzierski, Artur CIV NSWC Corona, PA53 artur.kedzierski at navy.mil
Wed Nov 7 22:46:46 EST 2007


	You're right. Library's destructor was calling
a function that was returning an exception. That in 
turn called terminate() killing the process.
	Thank You for your help. Now I have CTest failing the
test as it is supposed to.



--
Artur Kedzierski

-----Original Message-----
From: Bill Hoffman [mailto:bill.hoffman at kitware.com] 
Sent: Wednesday, November 07, 2007 18:50
To: Kedzierski, Artur CIV NSWC Corona, PA53
Cc: CMake Mailing List
Subject: Re: [CMake] Testing exceptions through CTest

Kedzierski, Artur CIV NSWC Corona, PA53 wrote:
>         Hi,
> 
>         I am writing CTest unit tests for a library I've created.
> I've utilized CREATE_TEST_SOURCELIST as described in Mastering CMake
book.
> In one of the test, I pass an invalid value to make sure that an 
> exception is thrown.
> In my test program I have a try-catch around the function call that 
> passes that invalid
> value and inside of the 'catch' I simple return EXIT_FAILURE. For that

> test, I've
> used SET_TESTS_PROPERTIES(... PROPERTIES WILL_FAIL  TRUE). Now,
> when I run 'make test', the test doesn't pass with a message 
> '***Exception: Other'.
>         How can I tell ctest that the exception is expected? I.e. I
need 
> something like
> 'WILL_EXCEPT' property that I could pass to set_tests_properties.
> 

If you are catching the exception, then cmake should not know about it. 
This sounds like an un-caught exception or some sort of crash.

-Bill


More information about the CMake mailing list