[CMake] specifying complex test behavior

Eric Noulard eric.noulard at gmail.com
Sun Mar 18 13:16:46 EDT 2012


2012/3/18 Ajay Panyala <ajay at csc.lsu.edu>:
> Hello,
>
> Is it possible to specify complex behavior for
> determining if a test was successful.
>
> For example, if we have
>
> add_test(Differ executable args)
>
> I want to specify that the test named Differ
> is successful if the output obtained by running
> the specified executable matches a certain file,
> i.e the diff of the output and a specified file is empty.

Then you should probably write a test driver script that does just that and do

add_test(NAME Differ COMMAND driverScript referenceFile
$<TARGET_FILE:executable> args)

so that the "driverScript" will call "executable" with "args" and compare
its output to "referenceFile".

In your case this script may probably written as a CMake script using

execute_process
and
cmake -E compare_files

etc...

> I am not sure how set_property should be specified in
> such cases. Clearly using set_property by specifying a
> regular expression is not sufficient.



-- 
Erk
Le gouvernement représentatif n'est pas la démocratie --
http://www.le-message.org


More information about the CMake mailing list