/usr/share/camitk-3.3/cmake/macros/CamiTKTestCompareFile.cmake is in libcamitk3-dev 3.3.2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #!
#! This CMake file run a command and put the output in
#! a given file
#! \note
#! You have to call camitk_test_init(..) first to prepare all variables
# Description: compare two files with the same name but not present in the same directory. The two full paths are provided by pre-edited variables
# Inspired from http://stackoverflow.com/questions/3305545/how-to-adapt-my-unit-tests-to-cmake-and-ctest
# and http://www.cmake.org/pipermail/cmake/2009-July/030619.html
# declare outputfiles
get_filename_component(OUTFILE ${CAMITK_TEST_PASS_FILE} NAME )
set(CAMITK_TEST_COMMAND_OUTPUT_FILE ${CAMITK_TEST_OUTPUT_DIR}/${OUTFILE}) # the output of the tested command goes in this files
# remove previous savings
execute_process(COMMAND ${CMAKE_COMMAND} -E remove -f ${CAMITK_TEST_COMMAND_OUTPUT_FILE} )
# expands all arguments
set( CAMITK_TEST_COMMAND_ARG "${CAMITK_TEST_COMMAND_ARG} -d ${CAMITK_TEST_OUTPUT_DIR}" ) #space before -d is important here #-d is the directory where the output file will be saved
string(REPLACE " " ";" CAMITK_TEST_COMMAND_ARG_LIST ${CAMITK_TEST_COMMAND_ARG})
execute_process(
COMMAND ${CAMITK_TEST_COMMAND} ${CAMITK_TEST_COMMAND_ARG_LIST})
# Then compare the files
execute_process(
COMMAND ${CMAKE_COMMAND} -E compare_files ${CAMITK_TEST_PASS_FILE} ${CAMITK_TEST_COMMAND_OUTPUT_FILE}
RESULT_VARIABLE CAMITK_TEST_PASS_FILE_RESULT
)
# check result
if( CAMITK_TEST_PASS_FILE_RESULT )
message(SEND_ERROR "${CAMITK_TEST_NAME}: ${CAMITK_TEST_COMMAND_OUTPUT_FILE} does not match ${CAMITK_TEST_PASS_FILE}" )
endif()
|