1 #-- declare outputfiles
8 set(CAMITK_TEST_COMMAND_FILE ${CAMITK_TEST_OUTPUT_DIR}/command) # which command is run to test the exectable
9 set(CAMITK_TEST_COMMAND_RESULT_FILE ${CAMITK_TEST_OUTPUT_DIR}/command-result) # the exit result (0=success, 1=failure) of the tested command goes in
this file
10 set(CAMITK_TEST_COMMAND_OUTPUT_FILE ${CAMITK_TEST_OUTPUT_DIR}/command-output) # the output of the tested command goes in
this files
11 set(CAMITK_TEST_EXPECTED_FILE_COMMAND_FILE ${CAMITK_TEST_OUTPUT_DIR}/test) # which command is run to diff the files
12 set(CAMITK_TEST_EXPECTED_FILE_OUTPUT_FILE ${CAMITK_TEST_OUTPUT_DIR}/test-output) # output of the diff cmake command
13 set(CAMITK_TEST_EXPECTED_FILE_RESULT_FILE ${CAMITK_TEST_OUTPUT_DIR}/test-result) # exit result (0=success, 1=failure)
15 # clean/remove all output files and previous test attempt
17 file(GLOB ALL_OUTPUT_FILES ${CAMITK_TEST_OUTPUT_DIR}
54 ${EXPECTED_OUTPUT_FILE}
")
58 COMMAND ${CMAKE_COMMAND} -E compare_files ${OUTPUT_FILE} ${CAMITK_TEST_OUTPUT_DIR}/${EXPECTED_OUTPUT_FILE}
59 RESULT_VARIABLE CAMITK_TEST_EXPECTED_FILE_RESULT_SINGLE
60 OUTPUT_VARIABLE CAMITK_TEST_EXPECTED_FILE_OUTPUT_SINGLE
65 # update the output variables (command, output and result)
66 set(CAMITK_TEST_EXPECTED_FILE_OUTPUT
67 "${CAMITK_TEST_EXPECTED_FILE_OUTPUT}=================================================\nComparing ${OUTPUT_FILE} with ${CAMITK_TEST_OUTPUT_DIR}/${EXPECTED_OUTPUT_FILE}\nOutput:\n${CAMITK_TEST_EXPECTED_FILE_OUTPUT_SINGLE}\n
")
68 set(CAMITK_TEST_EXPECTED_FILE_COMMAND
69 "${CAMITK_TEST_EXPECTED_FILE_COMMAND}${CMAKE_COMMAND} -E compare_files ${OUTPUT_FILE} ${CAMITK_TEST_OUTPUT_DIR}/${EXPECTED_OUTPUT_FILE}\n
")
70 if(CAMITK_TEST_EXPECTED_FILE_RESULT_SINGLE)
71 set(CAMITK_TEST_EXPECTED_FILE_OUTPUT "${CAMITK_TEST_EXPECTED_FILE_OUTPUT}Result:\n${CAMITK_TEST_NAME}: comparing ${EXPECTED_OUTPUT_FILE} failed:\nOutput file ${CAMITK_TEST_OUTPUT_DIR}/${EXPECTED_OUTPUT_FILE} is not the same as ${OUTPUT_FILE}\n\n
" )
72 set(CAMITK_TEST_EXPECTED_FILE_RESULT 1)
73 set(CAMITK_TEST_FAILED_FILE "${CAMITK_TEST_FAILED_FILE}${EXPECTED_OUTPUT_FILE}\n
")
75 set(CAMITK_TEST_EXPECTED_FILE_OUTPUT "${CAMITK_TEST_EXPECTED_FILE_OUTPUT}Result:\n${CAMITK_TEST_NAME}: comparing ${EXPECTED_OUTPUT_FILE} success!\n\n
" )
79 #-- write everything to the test-command, test-output and test-result files
80 # These information detail the results for an easier diagnostic by a human
81 file(WRITE ${CAMITK_TEST_EXPECTED_FILE_COMMAND_FILE} ${CAMITK_TEST_EXPECTED_FILE_COMMAND})
82 file(WRITE ${CAMITK_TEST_EXPECTED_FILE_OUTPUT_FILE} ${CAMITK_TEST_EXPECTED_FILE_OUTPUT})
83 file(WRITE ${CAMITK_TEST_EXPECTED_FILE_RESULT_FILE} ${CAMITK_TEST_EXPECTED_FILE_RESULT})
86 if( CAMITK_TEST_EXPECTED_FILE_RESULT )
87 message(STATUS "[FAIL]
")
88 message(FATAL_ERROR "${CAMITK_TEST_NAME}: (one or more) output file
do(es) not match the corresponding expected file.\n${CAMITK_TEST_EXPECTED_FILE_OUTPUT}
" )
90 message(STATUS "[OK]
")
test result unset(PREVIOUS_ATTEMPTS) file(GLOB ALL_OUTPUT_FILES $
Definition: CamiTKTestActionStateMachine.h:16
set(CAMITK_TEST_COMMAND_FILE ${CAMITK_TEST_OUTPUT_DIR}/command) set(CAMITK_TEST_COMMAND_RESULT_FILE $
This CMake script run the action state machine and compare the output files to the expected files The...
Definition: CamiTKTestActionStateMachine.h:8