[CMake] Conditional post test behavior

Tyler tyler at cryptio.net
Mon May 9 10:28:08 EDT 2011


I think the canonical way to do this is by handling this logic in a
wrapper script.

add_test -> wrapper script -> run test
                                            -> check status and delete if OK

hth,
tyler

On Sat, May 7, 2011 at 3:13 PM, Belcourt, K. Noel <kbelco at sandia.gov> wrote:
> Hi,
>
> I apologize if this has been asked and answered.  Is there a way to execute
> some commands after a test has run where the commands can be different
> depending on whether the test passes or not?  Here's my test.
>
> add_test(
>  NAME ex7_2_fmelcor
>  WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
>  COMMAND fmelcor.x ex7_variant2.inp
> )
>
> Because these tests generate enormous files (in both quantity and size) and
> run for very long times (days in some cases) I want all generated files to
> be deleted after the test runs, but only if the test passes.  If the test
> fails, I need to leave the files around so I can use them to debug the test.
>  So can I conditionally call this file remove function only if the test
> passes?
>
> file(REMOVE ${Ex7_2_Files})
>
> Is there CMake support for this that I'm not seeing or is this even
> possible?
>
> -- Noel
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>


More information about the CMake mailing list