[CMake] ADD_TEST comparing the command input with a file content

Bill Hoffman bill.hoffman at kitware.com
Fri Jul 4 09:21:14 EDT 2008


William Candillon wrote:
> Hi,
> 
> I'm using the ADD_TEST command to test the output of my executable like this:
> ADD_TEST(test mycommand)
> SET_TEST_PROPERTIES(test PROPERTIES PASS_REGULAR_EXPRESSION "foo")
> 
> However, I would like to compare the output with the content of a
> file. Is there a platform independent way to do that without writing a
> perl script for example ?
> 

You can do something like this:

add_test(test1 mycommand file1 file2)
add_test(test2 ${CMAKE_COMMAND} -E compare_files file1 file2)


-Bill


More information about the CMake mailing list